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

422.1.1 by Aaron Bentley
Support bootstrap with customized options.
1
#!/usr/bin/env python
2
from argparse import ArgumentParser
3
4
from jujuconfig import get_juju_home
663.1.2 by Aaron Bentley
Port bootstrap_from_env to EnvJujuClient, add unit tests.
5
from jujupy import (
6
    bootstrap_from_env,
7
    EnvJujuClient,
8
    SimpleEnvironment,
9
)
422.1.1 by Aaron Bentley
Support bootstrap with customized options.
10
11
12
def main():
612 by Aaron Bentley
Improve bootstrap docs, add --name option.
13
    parser = ArgumentParser(description="""
14
    Bootstrap a customized environment.  The first argument is the configured
15
    environment to use as the starting point.  Subsequent arguments are
16
    options to override, e.g. "region=lcy03".
17
    """)
18
    parser.add_argument('env', help='The environment to base deployment on.')
19
    parser.add_argument('option', nargs='*',
20
                        help='Override an environment option with value.')
21
    parser.add_argument('--name', help='A name for the new environment.')
422.1.1 by Aaron Bentley
Support bootstrap with customized options.
22
    args = parser.parse_args()
663.1.2 by Aaron Bentley
Port bootstrap_from_env to EnvJujuClient, add unit tests.
23
    env = SimpleEnvironment.from_config(args.env)
612 by Aaron Bentley
Improve bootstrap docs, add --name option.
24
    if args.name is not None:
25
        env.environment = args.name
422.1.1 by Aaron Bentley
Support bootstrap with customized options.
26
    for option in args.option:
27
        key, value = option.split('=', 1)
28
        env.config[key] = value
663.1.2 by Aaron Bentley
Port bootstrap_from_env to EnvJujuClient, add unit tests.
29
    bootstrap_from_env(get_juju_home(), EnvJujuClient.by_version(env))
422.1.1 by Aaron Bentley
Support bootstrap with customized options.
30
31
32
if __name__ == '__main__':
33
    main()