Exemple #1
0
def api_model_update(modelname):
    """ Deploys new bundle """
    bundle = request.data
    # Write bundle
    bundle_path = tempfile.mkdtemp() + '/bundle.yaml'
    with open(bundle_path, 'w+') as bundle_file:
        bundle_file.write(bundle)
    # Create environment from bundle if not exist, else deploy bundle
    if JujuEnvironment.env_exists(modelname):
        env = JujuEnvironment(modelname)
        output = env.deploy_bundle(bundle_path, '--skip-unit-wait')
    else:
        try:
            output = subprocess.check_output(
                ['tengu', 'create-model', '--bundle', bundle_path, modelname],
                stderr=subprocess.STDOUT)
        except CalledProcessError as process_error:
            return create_response(
                500, {
                    "msg":
                    "Failed to deploy bundle to environment {}. Output: {}".
                    format(modelname, process_error.output)
                })
    return create_response(
        200, {
            "msg":
            "Sucessfully deployed bundle to environment {}. Output: {}".format(
                modelname, output)
        })
Exemple #2
0
def api_model_update(modelname):
    """ Deploys new bundle """
    bundle = request.data
    # Write bundle
    bundle_path = tempfile.mkdtemp() + '/bundle.yaml'
    with open(bundle_path, 'w+') as bundle_file:
        bundle_file.write(bundle)
    # Create environment from bundle if not exist, else deploy bundle
    if JujuEnvironment.env_exists(modelname):
        env = JujuEnvironment(modelname)
        output = env.deploy_bundle(bundle_path, '--skip-unit-wait')
    else:
        try:
            output = subprocess.check_output(['/opt/tengu/scripts/tengu.py', 'create', '--bundle', bundle_path, modelname])
        except CalledProcessError as process_error:
            return create_response(500, {"msg": "Failed to deploy bundle to environment {}. Output: {}".format(modelname, process_error.output)})
    return create_response(200, {"msg": "Sucessfully deployed bundle to environment {}. Output: {}".format(modelname, output)})
Exemple #3
0
def c_deploy(bundle, name):
    """Create a Tengu with given name. Skips slice creation if it already exists.
    NAME: name of Tengu """
    downloadbigfiles(os.environ['JUJU_REPOSITORY'])
    juju_env = JujuEnvironment(name)
    juju_env.deploy_bundle(bundle)
Exemple #4
0
def c_deploy(bundle, name):
    """Create a Tengu with given name. Skips slice creation if it already exists.
    NAME: name of Tengu """
    downloadbigfiles(os.environ['JUJU_REPOSITORY'])
    juju_env = JujuEnvironment(name)
    juju_env.deploy_bundle(bundle)