1
1
#!/usr/bin/env python
2
from deploy_stack import run_deployer
2
from argparse import ArgumentParser
6
from deploy_stack import (
20
def is_healthy(cmd_path):
21
"""Returns a boolean after running the health_checker."""
23
sub_output = subprocess.check_output(cmd_path)
24
logging.info('Health check output: {}'.format(sub_output))
27
'The health check script failed to execute with: {}'.format(
30
except subprocess.CalledProcessError as e:
31
logging.error('Non-zero exit code returned from {}: {}'.format(
33
logging.error(e.output)
39
parser = ArgumentParser()
40
parser.add_argument('bundle_path',
41
help='URL or path to a bundle')
42
parser.add_argument('env',
43
help='The juju environment to test')
44
parser.add_argument('logs', help='log directory.')
45
parser.add_argument('job_name', help='Name of the Jenkins job.')
46
parser.add_argument('--bundle-name', default=None,
47
help='Name of the bundle to deploy.')
48
parser.add_argument('--health-cmd', default=None,
49
help='A binary for checking the health of the'
51
parser.add_argument('--keep-env', action='store_true', default=False,
52
help='Keep the Juju environment after the test'
54
parser.add_argument('--agent-url', default=None,
55
help='URL to use for retrieving agent binaries.')
56
parser.add_argument('--agent-stream', default=None,
57
help='stream name for retrieving agent binaries.')
58
parser.add_argument('--series',
59
help='Name of the Ubuntu series to use.')
60
parser.add_argument('--debug', action="store_true", default=False,
61
help='Use --debug juju logging.')
62
parser.add_argument('--verbose', '-v', action="store_true", default=False,
63
help='Increase logging verbosity.')
65
parser.add_argument('--new-juju-bin', default=None,
66
help='Dirctory containing the new Juju binary.')
67
args = parser.parse_args()
68
juju_path = get_juju_path(args)
69
configure_logging(get_log_level(args))
70
env = SimpleEnvironment.from_config(args.env)
71
client = EnvJujuClient.by_version(env, juju_path, debug=args.debug)
72
with boot_context(args.job_name, client, None, [], args.series,
73
args.agent_url, args.agent_stream, args.logs,
74
args.keep_env, False):
75
client.deployer(args.bundle_path, args.bundle_name)
77
is_healthy(args.health_cmd)
3
78
if __name__ == '__main__':