Пример #1
0
def cancelByExecutionId(execution_id, force, wait, timeout=900):
    logger = get_logger()
    management_ip = utils.get_management_server_ip()
    client = utils.get_rest_client(management_ip)
    logger.info('{0}Cancelling execution {1} on management server {2}'.format(
        'Force-' if force else '', execution_id, management_ip))
    execution = client.executions.cancel(execution_id, force)
    logger.info(
        'A cancel request for execution {0} has been sent to management '
        "server {1}. To track the execution's status, use:\n"
        "cfy executions get -e {0}".format(execution_id, management_ip))

    if wait:
        try:
            logger.info(
                'Waiting for execution {0} to finish being cancelled'.format(
                    execution_id))
            execution = wait_for_cancel(client, execution, timeout=timeout)

            if execution.error:
                logger.info("Cancellation of execution '{0}' "
                            "failed. [error={2}]".format(
                                execution_id, execution.error))
                raise SuppressedCloudifyCliError()
            else:
                logger.info(
                    "Finished cancelling execution '{0}'".format(execution_id))
        except ExecutionTimeoutError, e:
            logger.info("Cancellation of execution '{0}' timed out. ".format(
                e.execution_id))
            raise SuppressedCloudifyCliError()
Пример #2
0
def cancelByExecutionId(execution_id, force, wait, timeout=900):
    logger = get_logger()
    management_ip = utils.get_management_server_ip()
    client = utils.get_rest_client(management_ip)
    logger.info(
        '{0}Cancelling execution {1} on management server {2}'
        .format('Force-' if force else '', execution_id, management_ip))
    execution = client.executions.cancel(execution_id, force)
    logger.info(
        'A cancel request for execution {0} has been sent to management '
        "server {1}. To track the execution's status, use:\n"
        "cfy executions get -e {0}"
        .format(execution_id, management_ip))

    if wait:
        try:
            logger.info('Waiting for execution {0} to finish being cancelled'
                        .format(execution_id))
            execution = wait_for_cancel(client,
                                        execution,
                                        timeout=timeout)

            if execution.error:
                logger.info("Cancellation of execution '{0}' "
                            "failed. [error={2}]"
                            .format(execution_id,
                                    execution.error))
                raise SuppressedCloudifyCliError()
            else:
                logger.info("Finished cancelling execution '{0}'"
                            .format(execution_id))
        except ExecutionTimeoutError, e:
            logger.info("Cancellation of execution '{0}' timed out. "
                        .format(e.execution_id))
            raise SuppressedCloudifyCliError()
Пример #3
0
def cancelByDeploymentId(deployment_id, force, wait, timeout=900):
    executions = []

    logger = get_logger()
    management_ip = utils.get_management_server_ip()
    client = utils.get_rest_client(management_ip)

    # Retrieve all executions for the provided deployment
    executionsRaw = client.executions.list(
        deployment_id=deployment_id, _include=['id', 'status', 'created_at'])

    # Find only executions that aren't complete
    for execution in executionsRaw:
        logger.info('{0} is {1}'.format(execution['id'], execution['status']))
        if execution['status'] == 'started':
            executions.append(execution)

    if len(executions) > 0:
        logger.info('{0}Cancelling {1} execution(s) '
                    'on management server {2}'.format(
                        'Force-' if force else '', len(executions),
                        management_ip))
    else:
        logger.info('There are no active executions '
                    'for the specified deployment ID')
        return


# Cancel each non-terminated execution one-by-one
    for execution in executions:
        logger.info('{0}Cancelling execution {1} on '
                    'management server {2}'.format('Force-' if force else '',
                                                   execution['id'],
                                                   management_ip))

        client.executions.cancel(execution['id'], force)

        logger.info('A cancel request for execution {0} has been '
                    'sent to the management server {1}'.format(
                        execution['id'], management_ip))

        logger.info('To track the execution\'s status, '
                    'use:\n  cfy executions get -e {0}'.format(
                        execution['id']))

        if wait:
            try:
                logger.info('Waiting for execution {0} to '
                            'finish being cancelled'.format(execution['id']))
                execution = wait_for_cancel(client, execution, timeout=timeout)

                if execution.error:
                    logger.info("Cancellation of execution '{0}' "
                                "failed. [error={2}]".format(
                                    execution['id'], execution['error']))
                    raise SuppressedCloudifyCliError()
                else:
                    logger.info("Finished cancelling execution '{0}'".format(
                        execution['id']))
            except ExecutionTimeoutError, e:
                logger.info(
                    "Cancellation of execution '{0}' timed out. ".format(
                        e.execution_id))
                raise SuppressedCloudifyCliError()
Пример #4
0
def cancelByDeploymentId(deployment_id, force, wait, timeout=900):
    executions = []

    logger = get_logger()
    management_ip = utils.get_management_server_ip()
    client = utils.get_rest_client(management_ip)

# Retrieve all executions for the provided deployment
    executionsRaw = client.executions.list(
        deployment_id=deployment_id,
        _include=[
            'id',
            'status',
            'created_at'
        ]
    )

# Find only executions that aren't complete
    for execution in executionsRaw:
        logger.info('{0} is {1}' . format(
            execution['id'],
            execution['status']
        ))
        if execution['status'] == 'started':
            executions.append(execution)

    if len(executions) > 0:
        logger.info(
            '{0}Cancelling {1} execution(s) '
            'on management server {2}'
            . format(
                'Force-' if force else '',
                len(executions),
                management_ip))
    else:
        logger.info(
            'There are no active executions '
            'for the specified deployment ID')
        return

# Cancel each non-terminated execution one-by-one
    for execution in executions:
        logger.info(
            '{0}Cancelling execution {1} on '
            'management server {2}'
            . format(
                'Force-' if force else '',
                execution['id'],
                management_ip))

        client.executions.cancel(execution['id'], force)

        logger.info(
            'A cancel request for execution {0} has been '
            'sent to the management server {1}'
            . format(
                execution['id'],
                management_ip))

        logger.info(
            'To track the execution\'s status, '
            'use:\n  cfy executions get -e {0}'
            . format(
                execution['id']))

        if wait:
            try:
                logger.info('Waiting for execution {0} to '
                            'finish being cancelled'
                            .format(execution['id']))
                execution = wait_for_cancel(client,
                                            execution,
                                            timeout=timeout)

                if execution.error:
                    logger.info("Cancellation of execution '{0}' "
                                "failed. [error={2}]"
                                .format(execution['id'],
                                        execution['error']))
                    raise SuppressedCloudifyCliError()
                else:
                    logger.info("Finished cancelling execution '{0}'"
                                .format(execution['id']))
            except ExecutionTimeoutError, e:
                logger.info("Cancellation of execution '{0}' timed out. "
                            .format(e.execution_id))
                raise SuppressedCloudifyCliError()