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

« back to all changes in this revision

Viewing changes to assess_mixed_images.py

  • Committer: Aaron Bentley
  • Date: 2016-03-18 03:02:01 UTC
  • mto: This revision was merged to the branch mainline in revision 1323.
  • Revision ID: aaron.bentley@canonical.com-20160318030201-ki8wfpaeawgh9oqz
assess_cs_staging pokes state server via admin model.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
"""Assess mixed deployment of images from two sets of simplestreams."""
3
 
 
4
 
from __future__ import print_function
5
 
 
6
 
import argparse
7
 
import logging
8
 
import os
9
 
import sys
10
 
 
11
 
from deploy_stack import (
12
 
    assess_juju_relations,
13
 
    BootstrapManager,
14
 
)
15
 
from utility import (
16
 
    add_basic_testing_arguments,
17
 
    configure_logging,
18
 
    local_charm_path,
19
 
)
20
 
 
21
 
 
22
 
__metaclass__ = type
23
 
 
24
 
 
25
 
log = logging.getLogger("assess_mixed_images")
26
 
 
27
 
IMG_URL = 'https://s3.amazonaws.com/temp-streams/aws-image-streams/'
28
 
 
29
 
 
30
 
def assess_mixed_images(client):
31
 
    charm_path = local_charm_path(charm='dummy-sink', juju_ver=client.version,
32
 
                                  series='centos7', platform='centos')
33
 
    client.deploy(charm_path)
34
 
    charm_path = local_charm_path(charm='dummy-source',
35
 
                                  juju_ver=client.version, series='trusty')
36
 
    client.deploy(charm_path)
37
 
    client.juju('add-relation', ('dummy-source', 'dummy-sink'))
38
 
    # Wait for the deployment to finish.
39
 
    client.wait_for_started()
40
 
    assess_juju_relations(client)
41
 
 
42
 
 
43
 
def parse_args(argv):
44
 
    """Parse all arguments."""
45
 
    parser = argparse.ArgumentParser(
46
 
        description="Deploy images from two sets of simplestreams.")
47
 
    add_basic_testing_arguments(parser)
48
 
    # Fallback behaviour fails without --bootstrap-series: Bug 1560625
49
 
    parser.set_defaults(series='trusty')
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
58
 
    client.env.config['image-metadata-url'] = IMG_URL
59
 
    key_path = os.path.join(client.env.juju_home,
60
 
                            'juju-qa-public.key')
61
 
    log.info("Using JUJU_STREAMS_PUBLICKEY_FILE=%s", key_path)
62
 
    os.environ['JUJU_STREAMS_PUBLICKEY_FILE'] = key_path
63
 
    with bs_manager.booted_context(args.upload_tools):
64
 
        assess_mixed_images(bs_manager.client)
65
 
    return 0
66
 
 
67
 
 
68
 
if __name__ == '__main__':
69
 
    sys.exit(main())