1327.1.1
by Aaron Bentley
First working version of assess_mixed_images. |
1 |
#!/usr/bin/env python
|
1327.1.3
by Aaron Bentley
Get tests passing. |
2 |
"""Assess mixed deployment of images from two sets of simplestreams."""
|
1327.1.1
by Aaron Bentley
First working version of assess_mixed_images. |
3 |
|
4 |
from __future__ import print_function |
|
5 |
||
6 |
import argparse |
|
7 |
import logging |
|
8 |
import sys |
|
9 |
||
10 |
from deploy_stack import ( |
|
11 |
assess_juju_relations, |
|
12 |
BootstrapManager, |
|
13 |
)
|
|
1485.1.1
by Martin
Switch all imports of local_charm_path to using jujucharm over utility |
14 |
from jujucharm import ( |
15 |
local_charm_path, |
|
16 |
)
|
|
1327.1.1
by Aaron Bentley
First working version of assess_mixed_images. |
17 |
from utility import ( |
18 |
add_basic_testing_arguments, |
|
19 |
configure_logging, |
|
20 |
)
|
|
21 |
||
22 |
||
23 |
__metaclass__ = type |
|
24 |
||
25 |
||
26 |
log = logging.getLogger("assess_mixed_images") |
|
27 |
||
28 |
||
29 |
def assess_mixed_images(client): |
|
1345.1.3
by Seman
Deploy charm by path. |
30 |
charm_path = local_charm_path(charm='dummy-sink', juju_ver=client.version, |
31 |
series='centos7', platform='centos') |
|
32 |
client.deploy(charm_path) |
|
33 |
charm_path = local_charm_path(charm='dummy-source', |
|
34 |
juju_ver=client.version, series='trusty') |
|
35 |
client.deploy(charm_path) |
|
1327.1.1
by Aaron Bentley
First working version of assess_mixed_images. |
36 |
client.juju('add-relation', ('dummy-source', 'dummy-sink')) |
37 |
# Wait for the deployment to finish.
|
|
38 |
client.wait_for_started() |
|
39 |
assess_juju_relations(client) |
|
40 |
||
41 |
||
42 |
def parse_args(argv): |
|
43 |
"""Parse all arguments."""
|
|
1327.1.3
by Aaron Bentley
Get tests passing. |
44 |
parser = argparse.ArgumentParser( |
45 |
description="Deploy images from two sets of simplestreams.") |
|
1327.1.1
by Aaron Bentley
First working version of assess_mixed_images. |
46 |
add_basic_testing_arguments(parser) |
47 |
# Fallback behaviour fails without --bootstrap-series: Bug 1560625
|
|
48 |
parser.set_defaults(series='trusty') |
|
1416.1.1
by Aaron Bentley
Use only image-metadata-url. |
49 |
parser.add_argument('--image-metadata-url') |
1327.1.1
by Aaron Bentley
First working version of assess_mixed_images. |
50 |
return parser.parse_args(argv) |
51 |
||
52 |
||
53 |
def main(argv=None): |
|
54 |
args = parse_args(argv) |
|
55 |
configure_logging(args.verbose) |
|
56 |
bs_manager = BootstrapManager.from_args(args) |
|
57 |
client = bs_manager.client |
|
1416.1.1
by Aaron Bentley
Use only image-metadata-url. |
58 |
if args.image_metadata_url is not None: |
59 |
client.env.config['image-metadata-url'] = args.image_metadata_url |
|
1327.1.1
by Aaron Bentley
First working version of assess_mixed_images. |
60 |
with bs_manager.booted_context(args.upload_tools): |
61 |
assess_mixed_images(bs_manager.client) |
|
62 |
return 0 |
|
63 |
||
64 |
||
65 |
if __name__ == '__main__': |
|
66 |
sys.exit(main()) |