def delete_deployment(**kwargs):
    ctx.logger.info("Entering delete_deployment event.")

    if 'deployment_id' not in ctx.instance.runtime_properties:
        raise exceptions.NonRecoverableError(
            "Deployment ID as runtime property not specified.")

    client = manager.get_rest_client()
    deployment_id = ctx.instance.runtime_properties[
        'deployment_id']
    ignore = ctx.node.properties['ignore_live_nodes_on_delete']
    try:
        proxy_common.poll_until_with_timeout(
            proxy_common.check_if_deployment_is_ready(
                client, deployment_id),
            expected_result=True,
            timeout=900)
        client.deployments.delete(deployment_id,
                                  ignore_live_nodes=ignore)
    except Exception as ex:
        ctx.logger.error("Error during deployment deletion {0}. "
                         "Reason: {1}."
                         .format(deployment_id, str(ex)))
        raise exceptions.NonRecoverableError(
            "Error during deployment uninstall {0}. "
            "Reason: {1}.".format(deployment_id, str(ex)))
    ctx.logger.info("Exiting delete_deployment event.")
def create_deployment(deployment_inputs=None, **kwargs):
    ctx.logger.info("Entering create_deployment event.")
    client = manager.get_rest_client()
    blueprint_id = ctx.node.properties['blueprint_id']
    ctx.logger.info("Blueprint ID: %s" % blueprint_id)
    deployment_id = "{0}-{1}".format(blueprint_id,
                                     str(uuid.uuid4()))
    use_existing_deployment = ctx.node.properties['use_existing_deployment']
    existing_deployment_id = ctx.node.properties['existing_deployment_id']
    try:
        if not use_existing_deployment:
            ctx.logger.info("deployment ID to create: %s" % deployment_id)
            deployment = client.deployments.create(
                blueprint_id,
                deployment_id,
                inputs=deployment_inputs)
            ctx.logger.info("Deployment object {0}."
                            .format(str(deployment)))
        else:
            client.deployments.get(existing_deployment_id)
            deployment_id = existing_deployment_id
        ctx.logger.info("Instance runtime properties %s"
                        % str(ctx.instance.runtime_properties))
        proxy_common.poll_until_with_timeout(
            proxy_common.check_if_deployment_is_ready(
                client, deployment_id),
            expected_result=True,
            timeout=900)
        ctx.instance.runtime_properties.update(
            {'deployment_id': deployment_id})
    except Exception as ex:
        ctx.logger.error(str(ex))
        raise exceptions.NonRecoverableError(str(ex))

    ctx.logger.info("Exiting create_validation event.")
Beispiel #3
0
def create_deployment(deployment_inputs=None, **kwargs):
    ctx.logger.info("Entering create_deployment event.")
    client = manager.get_rest_client()
    blueprint_id = ctx.node.properties['blueprint_id']
    ctx.logger.info("Blueprint ID: %s" % blueprint_id)
    deployment_id = "{0}-{1}".format(blueprint_id, str(uuid.uuid4()))
    use_existing_deployment = ctx.node.properties['use_existing_deployment']
    existing_deployment_id = ctx.node.properties['existing_deployment_id']
    try:
        if not use_existing_deployment:
            ctx.logger.info("deployment ID to create: %s" % deployment_id)
            deployment = client.deployments.create(blueprint_id,
                                                   deployment_id,
                                                   inputs=deployment_inputs)
            ctx.logger.info("Deployment object {0}.".format(str(deployment)))
        else:
            client.deployments.get(existing_deployment_id)
            deployment_id = existing_deployment_id
        ctx.logger.info("Instance runtime properties %s" %
                        str(ctx.instance.runtime_properties))
        proxy_common.poll_until_with_timeout(
            proxy_common.check_if_deployment_is_ready(client, deployment_id),
            expected_result=True,
            timeout=900)
        ctx.instance.runtime_properties.update(
            {'deployment_id': deployment_id})
    except Exception as ex:
        ctx.logger.error(str(ex))
        raise exceptions.NonRecoverableError(str(ex))

    ctx.logger.info("Exiting create_validation event.")
def wait_for_deployment(deployment_id, **kwargs):
    ctx.logger.info("Entering wait_for_deployment event.")
    ctx.logger.info("Using deployment %s" % deployment_id)
    if not deployment_id:
        raise exceptions.NonRecoverableError("Deployment ID not specified.")

    client = manager.get_rest_client()
    timeout = ctx.node.properties["timeout"]
    proxy_common.poll_until_with_timeout(
        proxy_common.check_if_deployment_is_ready(client, deployment_id), expected_result=True, timeout=timeout
    )

    ctx.logger.info("Exiting wait_for_deployment event.")
def wait_for_deployment(deployment_id, **kwargs):
    ctx.logger.info("Entering wait_for_deployment event.")
    ctx.logger.info("Using deployment %s" % deployment_id)
    if not deployment_id:
        raise exceptions.NonRecoverableError("Deployment ID not specified.")

    client = manager.get_rest_client()
    timeout = ctx.node.properties['timeout']
    proxy_common.poll_until_with_timeout(
        proxy_common.check_if_deployment_is_ready(client, deployment_id),
        expected_result=True,
        timeout=timeout)

    ctx.logger.info("Exiting wait_for_deployment event.")
def install_deployment(**kwargs):
    ctx.logger.info("Entering install_deployment event.")
    if "deployment_id" not in ctx.instance.runtime_properties:
        raise exceptions.NonRecoverableError("Deployment ID as runtime property not specified.")

    client = manager.get_rest_client()
    deployment_id = ctx.instance.runtime_properties["deployment_id"]
    proxy_common.poll_until_with_timeout(
        proxy_common.check_if_deployment_is_ready(client, deployment_id), expected_result=True, timeout=900
    )

    if not ctx.node.properties["use_existing_deployment"]:
        proxy_common.execute_workflow(deployment_id, "install")

    ctx.instance.runtime_properties["outputs"] = client.deployments.get(deployment_id).outputs
    ctx.logger.info("Exiting install_deployment event.")
def install_deployment(**kwargs):
    ctx.logger.info("Entering install_deployment event.")
    if 'deployment_id' not in ctx.instance.runtime_properties:
        raise exceptions.NonRecoverableError(
            "Deployment ID as runtime property not specified.")

    client = manager.get_rest_client()
    deployment_id = ctx.instance.runtime_properties['deployment_id']
    proxy_common.poll_until_with_timeout(
        proxy_common.check_if_deployment_is_ready(client, deployment_id),
        expected_result=True,
        timeout=900)

    if not ctx.node.properties['use_existing_deployment']:
        proxy_common.execute_workflow(deployment_id, 'install')

    ctx.instance.runtime_properties['outputs'] = (
        client.deployments.get(deployment_id).outputs)
    ctx.logger.info("Exiting install_deployment event.")
Beispiel #8
0
def delete_deployment(**kwargs):
    ctx.logger.info("Entering delete_deployment event.")

    if 'deployment_id' not in ctx.instance.runtime_properties:
        raise exceptions.NonRecoverableError(
            "Deployment ID as runtime property not specified.")

    client = manager.get_rest_client()
    deployment_id = ctx.instance.runtime_properties['deployment_id']
    ignore = ctx.node.properties['ignore_live_nodes_on_delete']
    try:
        proxy_common.poll_until_with_timeout(
            proxy_common.check_if_deployment_is_ready(client, deployment_id),
            expected_result=True,
            timeout=900)
        client.deployments.delete(deployment_id, ignore_live_nodes=ignore)
    except Exception as ex:
        ctx.logger.error("Error during deployment deletion {0}. "
                         "Reason: {1}.".format(deployment_id, str(ex)))
        raise exceptions.NonRecoverableError(
            "Error during deployment uninstall {0}. "
            "Reason: {1}.".format(deployment_id, str(ex)))
    ctx.logger.info("Exiting delete_deployment event.")