Пример #1
0
def get(execution_id):
    logger = get_logger()
    rest_host = utils.get_rest_host()
    client = utils.get_rest_client(rest_host)

    try:
        logger.info('Getting execution: '
                    '\'{0}\' [manager={1}]'
                    .format(execution_id, rest_host))
        execution = client.executions.get(execution_id)
    except exceptions.CloudifyClientError as e:
        if e.status_code != 404:
            raise
        raise CloudifyCliError('Execution {0} not found'.format(execution_id))

    pt = utils.table(['id', 'workflow_id', 'status', 'deployment_id',
                      'created_at', 'error'],
                     [execution])
    pt.max_width = 50
    utils.print_table('Executions:', pt)

    # print execution parameters
    logger.info('Execution Parameters:')
    for param_name, param_value in utils.decode_dict(
            execution.parameters).iteritems():
        logger.info('\t{0}: \t{1}'.format(param_name, param_value))
    if execution.status in (execution.CANCELLING, execution.FORCE_CANCELLING):
        logger.info(_STATUS_CANCELING_MESSAGE)
    logger.info('')
Пример #2
0
def get(node_instance_id):
    logger = get_logger()
    rest_host = utils.get_rest_host()
    client = utils.get_rest_client(rest_host)

    logger.info('Retrieving node instance with ID: \'{0}\' [manager={1}]'
                .format(node_instance_id, rest_host))
    try:
        node_instance = client.node_instances.get(node_instance_id)
    except CloudifyClientError as e:
        if e.status_code != 404:
            raise
        raise CloudifyCliError('Node instance {0} not found')

    columns = ['id', 'deployment_id', 'host_id', 'node_id', 'state']
    pt = utils.table(columns, [node_instance])
    pt.max_width = 50
    utils.print_table('Instance:', pt)

    # print node instance runtime properties
    logger.info('Instance runtime properties:')
    for prop_name, prop_value in utils.decode_dict(
            node_instance.runtime_properties).iteritems():
        logger.info('\t{0}: {1}'.format(prop_name, prop_value))
    logger.info('')
Пример #3
0
def get(deployment_id, workflow_id):
    logger = get_logger()
    rest_host = utils.get_rest_host()
    client = utils.get_rest_client(rest_host)
    try:
        logger.info('Retrieving workflow '
                    '\'{0}\' of deployment \'{1}\' [manager={2}]'
                    .format(workflow_id, deployment_id, rest_host))
        deployment = client.deployments.get(deployment_id)
        workflow = next((wf for wf in deployment.workflows if
                         wf.name == workflow_id), None)
        if not workflow:
            raise CloudifyCliError(
                'Workflow {0} not found'.format(workflow_id, deployment_id))
    except CloudifyClientError as e:
        if e.status_code != 404:
            raise
        raise CloudifyCliError('Deployment {0} not found'.format(
            deployment_id))

    pt = utils.table(['blueprint_id', 'deployment_id',
                      'name', 'created_at'],
                     data=[workflow],
                     defaults={'blueprint_id': deployment.blueprint_id,
                               'deployment_id': deployment.id})

    utils.print_table('Workflows:', pt)

    # print workflow parameters
    mandatory_params = dict()
    optional_params = dict()
    for param_name, param in utils.decode_dict(
            workflow.parameters).iteritems():
        params_group = optional_params if 'default' in param else \
            mandatory_params
        params_group[param_name] = param

    logger.info('Workflow Parameters:')
    logger.info('\tMandatory Parameters:')
    for param_name, param in mandatory_params.iteritems():
        if 'description' in param:
            logger.info('\t\t{0}\t({1})'.format(param_name,
                                                param['description']))
        else:
            logger.info('\t\t{0}'.format(param_name))

    logger.info('\tOptional Parameters:')
    for param_name, param in optional_params.iteritems():
        if 'description' in param:
            logger.info('\t\t{0}: \t{1}\t({2})'.format(
                param_name, param['default'], param['description']))
        else:
            logger.info('\t\t{0}: \t{1}'.format(param_name,
                                                param['default']))
    logger.info('')
Пример #4
0
def get(deployment_id, node_id):
    logger = get_logger()
    rest_host = utils.get_rest_host()
    client = utils.get_rest_client(rest_host)

    logger.info('Retrieving node: \'{0}\' for deployment with ID \'{1}\' '
                '[manager={2}]'.format(node_id, deployment_id, rest_host))
    try:
        node = client.nodes.get(deployment_id, node_id)
    except CloudifyClientError as e:
        if e.status_code != 404:
            raise
        raise CloudifyCliError('Node {0} was not found'.format(node_id))

    logger.debug('Getting node instances for node with ID \'{0}\''
                 .format(node_id))
    try:
        instances = client.node_instances.list(deployment_id, node_id)
    except CloudifyClientError as e:
        if e.status_code != 404:
            raise

    # print node parameters
    columns = ['id', 'deployment_id', 'blueprint_id', 'host_id', 'type',
               'number_of_instances', 'planned_number_of_instances']
    pt = utils.table(columns, [node])
    pt.max_width = 50
    utils.print_table('Node:', pt)

    # print node properties
    logger.info('Node properties:')
    for property_name, property_value in utils.decode_dict(
            node.properties).iteritems():
        logger.info('\t{0}: {1}'.format(property_name, property_value))
    logger.info('')

    # print node instances IDs
    logger.info('Node instance IDs:')
    if instances:
        for instance in instances:
            logger.info('\t{0}'.format(instance['id']))
    else:
        logger.info('\tNo node instances')
Пример #5
0
def _print_maintenance_mode_status(client):
    logger = get_logger()

    status_response = client.maintenance_mode.status()

    logger.info('\nMaintenance Mode Status:')
    for param_name, param_value in utils.decode_dict(
            status_response).iteritems():
        if param_value and param_name != 'remaining_executions':
            logger.info('\t{0}:\t{1}'.format(
                    param_name.title().replace("_", " "),
                    param_value))
    logger.info('')

    remaining_executions = status_response.remaining_executions
    if remaining_executions:
        if len(remaining_executions) == 1:
            logger.info(
                    'Cloudify Manager currently has one '
                    'running or pending execution. Waiting for it'
                    ' to finish before activating.')
        else:
            logger.info(
                    'Cloudify Manager currently has {0} '
                    'running or pending executions. Waiting for all '
                    'executions to finish before activating.'.format(
                            len(remaining_executions)))

        if get_global_verbosity() != NO_VERBOSE:
            pt = utils.table(['id', 'deployment_id', 'workflow_id', 'status'],
                             remaining_executions)
            pt.max_width = 50
            utils.print_table('Remaining executions:', pt)

    if status_response.status == MAINTENANCE_MODE_ACTIVE:
        logger.info('INFO - Cloudify Manager is currently under maintenance. '
                    'Most requests will be blocked '
                    'until maintenance mode is deactivated.\n')
Пример #6
0
    except exceptions.CloudifyClientError, e:
        if e.status_code != 404:
            raise
        msg = ("Execution '{0}' not found on management server".format(
            execution_id))
        raise CloudifyCliError(msg)

    pt = utils.table([
        'id', 'workflow_id', 'status', 'deployment_id', 'created_at', 'error'
    ], [execution])
    pt.max_width = 50
    utils.print_table('Executions:', pt)

    # print execution parameters
    logger.info('Execution Parameters:')
    for param_name, param_value in utils.decode_dict(
            execution.parameters).iteritems():
        logger.info('\t{0}: \t{1}'.format(param_name, param_value))
    logger.info('')


def ls(deployment_id):
    logger = get_logger()
    management_ip = utils.get_management_server_ip()
    client = utils.get_rest_client(management_ip)
    try:
        if deployment_id:
            logger.info('Getting executions list for deployment: \'{0}\' '
                        '[manager={1}]'.format(deployment_id, management_ip))
        else:
            logger.info(
                'Getting a list of all executions: [manager={0}]'.format(
Пример #7
0
    try:
        instances = client.node_instances.list(deployment_id, node_id)
    except CloudifyClientError, e:
        if e.status_code != 404:
            raise

    # print node parameters
    columns = ['id', 'deployment_id', 'blueprint_id', 'host_id', 'type',
               'number_of_instances', 'planned_number_of_instances']
    pt = utils.table(columns, [node])
    pt.max_width = 50
    utils.print_table('Node:', pt)

    # print node properties
    logger.info('Node properties:')
    for property_name, property_value in utils.decode_dict(
            node.properties).iteritems():
        logger.info('\t{0}: {1}'.format(property_name, property_value))
    logger.info('')

    # print node instances IDs
    logger.info('Node instance IDs:')
    if instances:
        for instance in instances:
            logger.info('\t{0}'.format(instance['id']))
    else:
        logger.info('\tNo node instances')


def ls(deployment_id):
    logger = get_logger()
    management_ip = utils.get_management_server_ip()
Пример #8
0
        node_instance = client.node_instances.get(node_instance_id)
    except CloudifyClientError, e:
        if e.status_code != 404:
            raise
        msg = ("Node instance with ID '{0}' was not found on the management "
               "server".format(node_instance_id))
        raise CloudifyCliError(msg)

    columns = ['id', 'deployment_id', 'host_id', 'node_id', 'state']
    pt = utils.table(columns, [node_instance])
    pt.max_width = 50
    utils.print_table('Instance:', pt)

    # print node instance runtime properties
    logger.info('Instance runtime properties:')
    for prop_name, prop_value in utils.decode_dict(
            node_instance.runtime_properties).iteritems():
        logger.info('\t{0}: {1}'.format(prop_name, prop_value))
    logger.info('')


def ls(deployment_id, node_name=None):
    logger = get_logger()
    management_ip = utils.get_management_server_ip()
    client = utils.get_rest_client(management_ip)
    try:
        if deployment_id:
            logger.info('Getting instances list for deployment: \'{0}\' '
                        '[manager={1}]'.format(deployment_id, management_ip))
        else:
            logger.info(
                'Getting a list of all instances: [manager={0}]'.format(
Пример #9
0
            deployment_id))
        raise CloudifyCliError(msg)

    pt = utils.table(['blueprint_id', 'deployment_id', 'name', 'created_at'],
                     data=[workflow],
                     defaults={
                         'blueprint_id': deployment.blueprint_id,
                         'deployment_id': deployment.id
                     })

    utils.print_table('Workflows:', pt)

    # print workflow parameters
    mandatory_params = dict()
    optional_params = dict()
    for param_name, param in utils.decode_dict(
            workflow.parameters).iteritems():
        params_group = optional_params if 'default' in param else \
            mandatory_params
        params_group[param_name] = param

    logger.info('Workflow Parameters:')
    logger.info('\tMandatory Parameters:')
    for param_name, param in mandatory_params.iteritems():
        if 'description' in param:
            logger.info('\t\t{0}\t({1})'.format(param_name,
                                                param['description']))
        else:
            logger.info('\t\t{0}'.format(param_name))

    logger.info('\tOptional Parameters:')
    for param_name, param in optional_params.iteritems():
Пример #10
0
        execution = client.executions.get(execution_id)
    except exceptions.CloudifyClientError, e:
        if e.status_code != 404:
            raise
        msg = ("Execution '{0}' not found on management server"
               .format(execution_id))
        raise CloudifyCliError(msg)

    pt = utils.table(['id', 'workflow_id', 'status',
                      'created_at', 'error'],
                     [execution])
    utils.print_table('Executions:', pt)

    # print execution parameters
    logger.info('Execution Parameters:')
    for param_name, param_value in utils.decode_dict(
            execution.parameters).iteritems():
        logger.info('\t{0}: \t{1}'.format(param_name, param_value))
    logger.info('')


def ls(deployment_id):
    logger = get_logger()
    management_ip = utils.get_management_server_ip()
    client = utils.get_rest_client(management_ip)
    try:
        if deployment_id:
            logger.info('Getting executions list for deployment: \'{0}\' '
                        '[manager={1}]'.format(deployment_id, management_ip))
        else:
            logger.info(
                'Getting a list of all executions: [manager={0}]'.format(
Пример #11
0
        node_instance = client.node_instances.get(node_instance_id)
    except CloudifyClientError, e:
        if e.status_code != 404:
            raise
        msg = ("Node instance with ID '{0}' was not found on the management "
               "server".format(node_instance_id))
        raise CloudifyCliError(msg)

    columns = ['id', 'deployment_id', 'host_id', 'node_id', 'state']
    pt = utils.table(columns, [node_instance])
    pt.max_width = 50
    utils.print_table('Instance:', pt)

    # print node instance runtime properties
    logger.info('Instance runtime properties:')
    for prop_name, prop_value in utils.decode_dict(
            node_instance.runtime_properties).iteritems():
        logger.info('\t{0}: {1}'.format(prop_name, prop_value))
    logger.info('')


def ls(deployment_id, node_name=None):
    logger = get_logger()
    management_ip = utils.get_management_server_ip()
    client = utils.get_rest_client(management_ip)
    try:
        if deployment_id:
            logger.info('Getting instances list for deployment: \'{0}\' '
                        '[manager={1}]'.format(deployment_id, management_ip))
        else:
            logger.info(
                'Getting a list of all instances: [manager={0}]'.format(
Пример #12
0
        msg = ("Deployment '{0}' not found on management server"
               .format(deployment_id))
        raise CloudifyCliError(msg)

    pt = utils.table(['blueprint_id', 'deployment_id',
                      'name', 'created_at'],
                     data=[workflow],
                     defaults={'blueprint_id': deployment.blueprint_id,
                               'deployment_id': deployment.id})

    utils.print_table('Workflows:', pt)

    # print workflow parameters
    mandatory_params = dict()
    optional_params = dict()
    for param_name, param in utils.decode_dict(
            workflow.parameters).iteritems():
        params_group = optional_params if 'default' in param else \
            mandatory_params
        params_group[param_name] = param

    logger.info('Workflow Parameters:')
    logger.info('\tMandatory Parameters:')
    for param_name, param in mandatory_params.iteritems():
        if 'description' in param:
            logger.info('\t\t{0}\t({1})'.format(param_name,
                                                param['description']))
        else:
            logger.info('\t\t{0}'.format(param_name))

    logger.info('\tOptional Parameters:')
    for param_name, param in optional_params.iteritems():
Пример #13
0
    except CloudifyClientError, e:
        if e.status_code != 404:
            raise

    # print node parameters
    columns = [
        'id', 'deployment_id', 'blueprint_id', 'host_id', 'type',
        'number_of_instances', 'planned_number_of_instances'
    ]
    pt = utils.table(columns, [node])
    pt.max_width = 50
    utils.print_table('Node:', pt)

    # print node properties
    logger.info('Node properties:')
    for property_name, property_value in utils.decode_dict(
            node.properties).iteritems():
        logger.info('\t{0}: {1}'.format(property_name, property_value))
    logger.info('')

    # print node instances IDs
    logger.info('Node instance IDs:')
    if instances:
        for instance in instances:
            logger.info('\t{0}'.format(instance['id']))
    else:
        logger.info('\tNo node instances')


def ls(deployment_id):
    logger = get_logger()
    management_ip = utils.get_management_server_ip()