Ejemplo n.º 1
0
def install_binary(ctx, **_):
    executable_path = ctx.node.properties.get(HELM_CONFIG,
                                              {}).get(EXECUTABLE_PATH, "")
    if executable_path:
        ctx.logger.warning('You are requesting to write a new file to {loc}. '
                           'If you do not have sufficient permissions, that '
                           'installation will fail.Please talk your system '
                           'administrator if using executable_path '
                           'property.'.format(loc=executable_path))
    else:
        executable_path = os.path.join(get_deployment_dir(ctx.deployment.id),
                                       'helm')

    if is_using_existing(ctx):
        if not os.path.isfile(executable_path):
            raise NonRecoverableError(
                "Helm executable not found at {0}, cant use existing "
                "binary!".format(executable_path))
    else:
        if os.path.isfile(executable_path):
            ctx.logger.info(
                "Helm executable already found at {path};skipping "
                "installation of executable".format(path=executable_path))
        else:
            with get_binary(ctx) as binary:
                copy_binary(binary, executable_path)
    create_temporary_env_of_helm(ctx)
    ctx.instance.runtime_properties[EXECUTABLE_PATH] = executable_path
Ejemplo n.º 2
0
def get_node_instance_dir(target=False, source=False, source_path=None):
    """This is the place where the magic happens.
    We put all our binaries, templates, or symlinks to those files here,
    and then we also run all executions from here.
    """
    instance = get_instance(target=target, source=source)
    folder = os.path.join(get_deployment_dir(ctx.deployment.id), instance.id)
    if source_path:
        folder = os.path.join(folder, source_path)
    if not os.path.exists(folder):
        mkdir_p(folder)
    ctx.logger.debug('Value deployment_dir is {loc}.'.format(loc=folder))
    return folder
Ejemplo n.º 3
0
def create_venv():
    """
        Handle creation of virtual environment.
        Create the virtual environment in deployment directory.
        Save the path of the virtual environment in runtime properties.
       :param packages_to_install: list of python packages to install
        inside venv.
    """
    if not ctx.instance.runtime_properties.get(AWS_CLI_VENV):
        deployment_dir = get_deployment_dir(ctx.deployment.id)
        venv_path = tempfile.mkdtemp(dir=deployment_dir)
        make_virtualenv(path=venv_path)
        install_packages_to_venv(venv_path, [AWS_CLI_TO_INSTALL])
        ctx.instance.runtime_properties[AWS_CLI_VENV] = venv_path
Ejemplo n.º 4
0
def create_temporary_env_of_helm(ctx):
    """
    Create temporary directories for helm cache,data and configuration files
    and inject their paths to runtime properties.
    :param ctx: cloudify context.

    """
    deployment_dir = get_deployment_dir(ctx.deployment.id)
    ctx.instance.runtime_properties[CACHE_DIR_ENV_VAR] = tempfile.mkdtemp(
        dir=deployment_dir)
    ctx.instance.runtime_properties[CONFIG_DIR_ENV_VAR] = tempfile.mkdtemp(
        dir=deployment_dir)
    ctx.instance.runtime_properties[DATA_DIR_ENV_VAR] = tempfile.mkdtemp(
        dir=deployment_dir)