1210.2.1
by John George
Replace cs_staging_deploy.py with jes aware version in assess_cs_staging.py |
1 |
#!/usr/bin/env python
|
2 |
"""Assess Juju usage of the staging charm store."""
|
|
3 |
||
4 |
from __future__ import print_function |
|
5 |
||
6 |
import argparse |
|
7 |
import logging |
|
8 |
import sys |
|
9 |
||
10 |
from deploy_stack import ( |
|
11 |
BootstrapManager, |
|
12 |
)
|
|
13 |
from utility import ( |
|
14 |
add_basic_testing_arguments, |
|
15 |
configure_logging, |
|
16 |
)
|
|
17 |
||
18 |
__metaclass__ = type |
|
19 |
||
20 |
||
21 |
log = logging.getLogger("assess_cs_staging") |
|
22 |
||
23 |
||
1322.1.1
by Aaron Bentley
assess_cs_staging pokes state server via admin model. |
24 |
def _get_ssh_script(ip): |
25 |
return ( |
|
1210.2.2
by John George
Resolve assess_cs_staging review comments. |
26 |
'''sudo bash -c "echo '%s store.juju.ubuntu.com' >> /etc/hosts"'''
|
27 |
% ip) |
|
1322.1.1
by Aaron Bentley
assess_cs_staging pokes state server via admin model. |
28 |
|
29 |
||
30 |
def _set_charm_store_ip(client, ip): |
|
1493.1.1
by Martin
Rename methods and variables refering to admin model to new term controller model |
31 |
client.get_controller_client().juju('ssh', ('0', _get_ssh_script(ip))) |
1210.2.2
by John George
Resolve assess_cs_staging review comments. |
32 |
|
33 |
||
1210.2.1
by John George
Replace cs_staging_deploy.py with jes aware version in assess_cs_staging.py |
34 |
def assess_deploy(client, charm): |
35 |
"""Deploy the charm."""
|
|
36 |
client.deploy(charm) |
|
37 |
client.wait_for_started() |
|
1210.2.2
by John George
Resolve assess_cs_staging review comments. |
38 |
log.info("Deploying charm %r and waiting for started.", charm) |
1210.2.1
by John George
Replace cs_staging_deploy.py with jes aware version in assess_cs_staging.py |
39 |
|
40 |
||
41 |
def parse_args(argv): |
|
42 |
"""Parse all arguments."""
|
|
43 |
parser = argparse.ArgumentParser(description="Test staging store.") |
|
44 |
parser.add_argument('charm_store_ip', help="Charm store address.") |
|
45 |
add_basic_testing_arguments(parser) |
|
1210.2.2
by John George
Resolve assess_cs_staging review comments. |
46 |
parser.add_argument('--charm', default='ubuntu', help='Charm to deploy.') |
1210.2.1
by John George
Replace cs_staging_deploy.py with jes aware version in assess_cs_staging.py |
47 |
return parser.parse_args(argv) |
48 |
||
49 |
||
50 |
def main(argv=None): |
|
51 |
args = parse_args(argv) |
|
52 |
configure_logging(args.verbose) |
|
53 |
bs_manager = BootstrapManager.from_args(args) |
|
54 |
with bs_manager.booted_context(args.upload_tools): |
|
1210.2.2
by John George
Resolve assess_cs_staging review comments. |
55 |
_set_charm_store_ip(bs_manager.client, args.charm_store_ip) |
1210.2.1
by John George
Replace cs_staging_deploy.py with jes aware version in assess_cs_staging.py |
56 |
assess_deploy(bs_manager.client, args.charm) |
57 |
return 0 |
|
58 |
||
59 |
||
60 |
if __name__ == '__main__': |
|
61 |
sys.exit(main()) |