~abentley/juju-ci-tools/client-from-config-4

« back to all changes in this revision

Viewing changes to run_deployer.py

  • Committer: Aaron Bentley
  • Date: 2016-03-18 14:47:06 UTC
  • mto: This revision was merged to the branch mainline in revision 1324.
  • Revision ID: aaron.bentley@canonical.com-20160318144706-z7wy9c21m3psi6g5
Introduce set_model_name, update tests, check controller on bootstrap.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
2
from argparse import ArgumentParser
3
3
import logging
4
 
import pickle
5
4
import subprocess
6
5
import sys
7
6
 
10
9
    boot_context,
11
10
)
12
11
from jujupy import (
13
 
    client_from_config,
 
12
    EnvJujuClient,
 
13
    SimpleEnvironment,
14
14
)
15
15
from remote import (
16
16
    remote_from_unit,
18
18
from utility import (
19
19
    add_basic_testing_arguments,
20
20
    configure_logging,
21
 
    run_command,
22
21
    scoped_environ,
23
22
)
24
23
 
36
35
    add_basic_testing_arguments(parser)
37
36
    parser.add_argument('--allow-native-deploy', action='store_true',
38
37
                        help='Let juju 2 use native bundle deploying.')
39
 
    parser.add_argument('--bundle-verification-script',
40
 
                        help='Script to verify the bundle.')
41
38
    parser.add_argument('--bundle-name', default=None,
42
39
                        help='Name of the bundle to deploy.')
43
40
    parser.add_argument('--health-cmd', default=None,
126
123
def main(argv=None):
127
124
    args = parse_args(argv)
128
125
    configure_logging(args.verbose)
 
126
    env = SimpleEnvironment.from_config(args.env)
129
127
    start_juju_path = None if args.upgrade else args.juju_bin
130
 
    client = client_from_config(args.env, start_juju_path, debug=args.debug)
 
128
    client = EnvJujuClient.by_version(env, start_juju_path, debug=args.debug)
131
129
    with boot_context(args.temp_env_name, client, None, [], args.series,
132
130
                      args.agent_url, args.agent_stream, args.logs,
133
131
                      args.keep_env, upload_tools=args.upload_tools,
134
132
                      region=args.region):
135
133
        assess_deployer(
136
134
            args, client, args.agent_timeout, args.workload_timeout)
137
 
        if args.bundle_verification_script:
138
 
            client_ser = pickle.dumps(client)
139
 
            logging.info('Calling bundle verification script {}'.format(
140
 
                args.bundle_verification_script))
141
 
            run_command([args.bundle_verification_script, client_ser])
142
135
    return 0
143
136
 
144
137