Ejemplo n.º 1
0
def create_juju(env_conf, provider_env):
    if JujuEnvironment.env_exists(env_conf['env-name']):
        fail(
            "Juju environment already exists. Remove it first with 'tengu destroy {}'"
            .format(env_conf['env-name']))
    try:
        machines = provider_env.machines
    except Exception as ex:  # pylint: disable=W0703
        fail("Could not get machines from manifest", ex)
    # Create Juju environment
    env_conf['juju-env-conf']['bootstrap-host'] = machines.pop(0)
    env_conf.save()
    wait_for_init(env_conf)
    return JujuEnvironment.create(env_conf['env-name'],
                                  env_conf['juju-env-conf']['bootstrap-host'],
                                  env_conf['juju-env-conf'], machines)
Ejemplo n.º 2
0
def create_juju(env_conf, provider_env):
    if JujuEnvironment.env_exists(env_conf['env-name']):
        fail("Juju environment already exists. Remove it first with 'tengu destroy {}'".format(env_conf['env-name']))
    try:
        machines = provider_env.machines
    except Exception as ex: # pylint: disable=W0703
        fail("Could not get machines from manifest", ex)
    # Create Juju environment
    env_conf['juju-env-conf']['bootstrap-host'] = machines.pop(0)
    env_conf.save()
    wait_for_init(env_conf)
    return JujuEnvironment.create(
        env_conf['env-name'],
        env_conf['juju-env-conf']['bootstrap-host'],
        env_conf['juju-env-conf'],
        machines
    )
Ejemplo n.º 3
0
def c_create_model(bundle, name, create_machines):
    """Create a model with given name. Skips slice creation if it already exists.
    NAME: name of model """
    env_conf = init_environment_config(name)
    try:
        with open(bundle, 'r') as bundle_file:
            bundledict = yaml.load(bundle_file)
    except yaml.YAMLError as yamlerror:
        raise click.ClickException(
            'Parsing bundle \033[91mfailed\033[0m: {}'.format(str(yamlerror)))
    downloadbigfiles(os.environ.get('JUJU_REPOSITORY', ''))
    if create_machines:
        provider_env = get_provider(env_conf).create_from_bundle(
            env_conf, bundledict)
    else:
        provider_env = get_provider(env_conf).get(env_conf)
    juju_env = JujuEnvironment.create(
        env_conf['env-name'],
        env_conf['juju-env-conf'],
        provider_env.machines,
        env_conf['init-bundle'],
    )
    juju_env.deploy_bundle(bundle)