Beispiel #1
0
def _show_profile(senlin_client, profile_id):
    try:
        data = senlin_client.get_profile(profile_id)
    except sdk_exc.ResourceNotFound:
        raise exc.CommandError('Profile not found: %s' % profile_id)
    else:
        formatters = {}
        formatters['metadata'] = senlin_utils.json_formatter
        formatters['spec'] = senlin_utils.nested_dict_formatter(
            ['type', 'version', 'properties'],
            ['property', 'value'])

        columns = [
            'created_at',
            'domain',
            'id',
            'metadata',
            'name',
            'project',
            'spec',
            'type',
            'updated_at',
            'user'
        ]
        return columns, utils.get_dict_properties(data.to_dict(), columns,
                                                  formatters=formatters)
Beispiel #2
0
def _show_profile(service, profile_id):
    try:
        profile = service.get_profile(profile_id)
    except sdk_exc.ResourceNotFound:
        raise exc.CommandError(_('Profile not found: %s') % profile_id)

    formatters = {
        'metadata': utils.json_formatter,
    }

    formatters['spec'] = utils.nested_dict_formatter(
        ['type', 'version', 'properties'],
        ['property', 'value'])

    utils.print_dict(profile.to_dict(), formatters=formatters)
Beispiel #3
0
def _show_profile(senlin_client, profile_id):
    try:
        data = senlin_client.get_profile(profile_id)
    except sdk_exc.ResourceNotFound:
        raise exc.CommandError('Profile not found: %s' % profile_id)
    else:
        formatters = {}
        formatters['metadata'] = senlin_utils.json_formatter
        formatters['spec'] = senlin_utils.nested_dict_formatter(
            ['type', 'version', 'properties'], ['property', 'value'])

        data = data.to_dict()
        columns = sorted(data.keys())
        return columns, utils.get_dict_properties(data,
                                                  columns,
                                                  formatters=formatters)
Beispiel #4
0
def _show_profile(senlin_client, profile_id):
    try:
        data = senlin_client.get_profile(profile_id)
    except sdk_exc.ResourceNotFound:
        raise exc.CommandError('Profile not found: %s' % profile_id)
    else:
        formatters = {}
        formatters['metadata'] = senlin_utils.json_formatter
        formatters['spec'] = senlin_utils.nested_dict_formatter(
            ['type', 'version', 'properties'], ['property', 'value'])

        columns = [
            'created_at', 'domain', 'id', 'metadata', 'name', 'project',
            'spec', 'type', 'updated_at', 'user'
        ]
        return columns, utils.get_dict_properties(data.to_dict(),
                                                  columns,
                                                  formatters=formatters)
Beispiel #5
0
def _show_node(service, node_id, show_details=False):
    """Show detailed info about the specified node."""

    args = {'show_details': True} if show_details else None
    try:
        node = service.get_node(node_id, args=args)
    except sdk_exc.ResourceNotFound:
        raise exc.CommandError(_('Node not found: %s') % node_id)

    formatters = {
        'metadata': utils.json_formatter,
        'data': utils.json_formatter,
    }
    data = node.to_dict()
    if show_details:
        formatters['details'] = utils.nested_dict_formatter(
            list(node['details'].keys()), ['property', 'value'])

    utils.print_dict(data, formatters=formatters)
Beispiel #6
0
def _show_node(senlin_client, node_id, show_details=False):
    """Show detailed info about the specified node."""

    args = {'show_details': True} if show_details else None
    try:
        node = senlin_client.get_node(node_id, args=args)
    except sdk_exc.ResourceNotFound:
        raise exc.CommandError(_('Node not found: %s') % node_id)

    formatters = {
        'metadata': senlin_utils.json_formatter,
        'data': senlin_utils.json_formatter,
    }
    if show_details and node:
        formatters['details'] = senlin_utils.nested_dict_formatter(
            list(node['details'].keys()), ['property', 'value'])

    columns = list(six.iterkeys(node))
    return columns, utils.get_dict_properties(node.to_dict(), columns,
                                              formatters=formatters)
Beispiel #7
0
def _show_node(senlin_client, node_id, show_details=False):
    """Show detailed info about the specified node."""

    try:
        node = senlin_client.get_node(node_id, details=show_details)
    except sdk_exc.ResourceNotFound:
        raise exc.CommandError(_('Node not found: %s') % node_id)

    formatters = {
        'metadata': senlin_utils.json_formatter,
        'data': senlin_utils.json_formatter,
        'dependents': senlin_utils.json_formatter,
    }
    data = node.to_dict()
    if show_details and data['details']:
        formatters['details'] = senlin_utils.nested_dict_formatter(
            list(data['details'].keys()), ['property', 'value'])
    columns = sorted(data.keys())
    return columns, utils.get_dict_properties(data, columns,
                                              formatters=formatters)
Beispiel #8
0
def _show_node(senlin_client, node_id, show_details=False):
    """Show detailed info about the specified node."""

    args = {'show_details': True} if show_details else None
    try:
        node = senlin_client.get_node(node_id, args=args)
    except sdk_exc.ResourceNotFound:
        raise exc.CommandError(_('Node not found: %s') % node_id)

    formatters = {
        'metadata': senlin_utils.json_formatter,
        'data': senlin_utils.json_formatter,
    }
    if show_details and node:
        formatters['details'] = senlin_utils.nested_dict_formatter(
            list(node['details'].keys()), ['property', 'value'])

    columns = list(six.iterkeys(node))
    return columns, utils.get_dict_properties(node.to_dict(),
                                              columns,
                                              formatters=formatters)
Beispiel #9
0
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)", parsed_args)

        senlin_client = self.app.client_manager.clustering

        preview = True if parsed_args.preview else False
        attrs = {
            'identity': parsed_args.identity,
            'overrides':
            senlin_utils.format_json_parameter(parsed_args.overrides),
            'snapshot': parsed_args.snapshot,
            'type': parsed_args.type
        }

        if not preview:
            attrs.update({
                'name':
                parsed_args.name,
                'role':
                parsed_args.role,
                'metadata':
                senlin_utils.format_parameters(parsed_args.metadata),
            })

        node = senlin_client.adopt_node(preview, **attrs)

        if not preview:
            return _show_node(senlin_client, node.id)
        else:
            formatters = {}
            formatters['node_preview'] = senlin_utils.nested_dict_formatter(
                ['type', 'version', 'properties'], ['property', 'value'])
            data = node['node_profile']
            columns = sorted(data.keys())
            return columns, utils.get_dict_properties(data,
                                                      columns,
                                                      formatters=formatters)
Beispiel #10
0
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)", parsed_args)
        senlin_client = self.app.client_manager.clustering

        spec = senlin_utils.get_spec_content(parsed_args.spec_file)
        type_name = spec.get('type', None)
        type_version = spec.get('version', None)
        properties = spec.get('properties', None)
        if type_name is None:
            raise exc.CommandError(_("Missing 'type' key in spec file."))
        if type_version is None:
            raise exc.CommandError(_("Missing 'version' key in spec file."))
        if properties is None:
            raise exc.CommandError(_("Missing 'properties' key in spec file."))

        if type_name == 'os.heat.stack':
            stack_properties = senlin_utils.process_stack_spec(properties)
            spec['properties'] = stack_properties

        params = {
            'spec': spec,
        }

        profile = senlin_client.validate_profile(**params)

        formatters = {}
        formatters['metadata'] = senlin_utils.json_formatter
        formatters['spec'] = senlin_utils.nested_dict_formatter(
            ['type', 'version', 'properties'], ['property', 'value'])

        columns = [
            'created_at', 'domain', 'id', 'metadata', 'name', 'project_id',
            'spec', 'type', 'updated_at', 'user_id'
        ]
        return columns, utils.get_dict_properties(profile.to_dict(),
                                                  columns,
                                                  formatters=formatters)