~andrewjbeach/juju-ci-tools/make-local-patcher

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
"""Assess mixed deployment of images from two sets of simplestreams."""

from __future__ import print_function

import argparse
import logging
import os
import sys

from deploy_stack import (
    assess_juju_relations,
    BootstrapManager,
)
from utility import (
    add_basic_testing_arguments,
    configure_logging,
)


__metaclass__ = type


log = logging.getLogger("assess_mixed_images")

IMG_URL = 'https://s3.amazonaws.com/temp-streams/aws-image-streams/'


def assess_mixed_images(client):
    client.deploy('local:centos7/dummy-sink')
    client.deploy('local:trusty/dummy-source')
    client.juju('add-relation', ('dummy-source', 'dummy-sink'))
    # Wait for the deployment to finish.
    client.wait_for_started()
    assess_juju_relations(client)


def parse_args(argv):
    """Parse all arguments."""
    parser = argparse.ArgumentParser(
        description="Deploy images from two sets of simplestreams.")
    add_basic_testing_arguments(parser)
    # Fallback behaviour fails without --bootstrap-series: Bug 1560625
    parser.set_defaults(series='trusty')
    return parser.parse_args(argv)


def main(argv=None):
    args = parse_args(argv)
    configure_logging(args.verbose)
    bs_manager = BootstrapManager.from_args(args)
    client = bs_manager.client
    client.env.config['image-metadata-url'] = IMG_URL
    key_path = os.path.join(client.env.juju_home,
                            'juju-qa-public.key')
    log.info("Using JUJU_STREAMS_PUBLICKEY_FILE=%s", key_path)
    os.environ['JUJU_STREAMS_PUBLICKEY_FILE'] = key_path
    with bs_manager.booted_context(args.upload_tools):
        assess_mixed_images(bs_manager.client)
    return 0


if __name__ == '__main__':
    sys.exit(main())