Esempio n. 1
0
def main():
    parser = ArgumentParser(
        description=dedent('''\
            Convert environments.yaml to 2.0 format.

            environments.yaml from JUJU_HOME will be used.
            Existing configs in the output directory will be overwritten.

            Does not support configs of type 'local'.
            '''))
    parser.add_argument('config_dir', metavar='OUTPUT_DIR',
                        help='Directory to write updated configs to.')
    args = parser.parse_args()
    clouds_credentials = JujuData('', {})
    clouds_credentials.load_yaml()
    for environment, config in get_environments().items():
        if config['type'] == 'local':
            continue
        env = JujuData(environment, config)
        env.clouds = clouds_credentials.clouds
        env.credentials = clouds_credentials.credentials
        print(environment)
        sys.stdout.flush()
        out_path = os.path.join(args.config_dir,
                                '{}.yaml'.format(environment))
        with open(out_path, 'w') as out_file:
            write_new_config(env, out_file)
Esempio n. 2
0
def main():
    parser = ArgumentParser(description=dedent('''\
            Convert environments.yaml to 2.0 format.

            environments.yaml from JUJU_HOME will be used.
            Existing configs in the output directory will be overwritten.

            Does not support configs of type 'local'.
            '''))
    parser.add_argument('config_dir',
                        metavar='OUTPUT_DIR',
                        help='Directory to write updated configs to.')
    args = parser.parse_args()
    clouds_credentials = JujuData('', {})
    clouds_credentials.load_yaml()
    for environment, config in get_environments().items():
        if config['type'] == 'local':
            continue
        env = JujuData(environment, config)
        env.clouds = clouds_credentials.clouds
        env.credentials = clouds_credentials.credentials
        print(environment)
        sys.stdout.flush()
        out_path = os.path.join(args.config_dir, '{}.yaml'.format(environment))
        with open(out_path, 'w') as out_file:
            write_new_config(env, out_file)
Esempio n. 3
0
def fake_juju_client(env=None, full_path=None, debug=False, version='2.0.0',
                     _backend=None, cls=ModelClient, juju_home=None):
    if juju_home is None:
        if env is None or env.juju_home is None:
            juju_home = 'foo'
        else:
            juju_home = env.juju_home
    if env is None:
        env = JujuData('name', {
            'type': 'foo',
            'default-series': 'angsty',
            'region': 'bar',
            }, juju_home=juju_home)
        env.credentials = {'credentials': {'foo': {'creds': {}}}}
    if _backend is None:
        backend_state = FakeControllerState()
        _backend = FakeBackend(
            backend_state, version=version, full_path=full_path,
            debug=debug)
        _backend.set_feature('jes', True)
    client = cls(
        env, version, full_path, juju_home, debug, _backend=_backend)
    client.bootstrap_replaces = {}
    return client