Esempio n. 1
0
def do_event_list(hc, args):
    '''List events for a stack.'''
    fields = {
        'stack_id': args.id,
        'resource_name': args.resource,
        'limit': args.limit,
        'marker': args.marker,
        'filters': utils.format_parameters(args.filters)
    }
    try:
        events = hc.events.list(**fields)
    except exc.HTTPNotFound as ex:
        # it could be the stack or resource that is not found
        # just use the message that the server sent us.
        raise exc.CommandError(str(ex))
    else:
        fields = [
            'id', 'resource_status_reason', 'resource_status', 'event_time'
        ]
        if len(events) >= 1:
            if hasattr(events[0], 'resource_name'):
                fields.insert(0, 'resource_name')
            else:
                fields.insert(0, 'logical_resource_id')
        utils.print_list(events, fields, sortby_index=None)
Esempio n. 2
0
def do_stack_list(hc, args={}):
    '''List the user's stacks'''
    kwargs = {}
    stacks = hc.stacks.list(**kwargs)
    field_labels = ['ID', 'Name', 'Status', 'Created']
    fields = ['id', 'stack_name', 'stack_status', 'creation_time']
    utils.print_list(stacks, fields, field_labels, sortby=3)
Esempio n. 3
0
 def list(self):
     """ list created stacks """
     fields = ['id', 'stack_name', 'stack_status', 'creation_time',
               'updated_time']
     uids = []
     stacks = self.client.stacks.list()
     utils.print_list(stacks, fields)
     return obj_gen_to_dict(stacks)
Esempio n. 4
0
 def list(self):
     """ list created stacks """
     fields = [
         'id', 'stack_name', 'stack_status', 'creation_time', 'updated_time'
     ]
     uids = []
     stacks = self.client.stacks.list()
     utils.print_list(stacks, fields)
     return obj_gen_to_dict(stacks)
Esempio n. 5
0
def do_resource_list(hc, args):
    '''Show list of resources belonging to a stack.'''
    fields = {'stack_id': args.id}
    try:
        resources = hc.resources.list(**fields)
    except exc.HTTPNotFound:
        raise exc.CommandError('Stack not found: %s' % args.id)
    else:
        fields = ['logical_resource_id', 'resource_type',
                  'resource_status', 'updated_time']
        utils.print_list(resources, fields, sortby=3)
Esempio n. 6
0
def do_list(hc, args={}):
    '''List the user's stacks'''
    kwargs = {}
    stacks = hc.stacks.list(**kwargs)
    field_labels = ['Name/ID', 'Status', 'Created']
    fields = ['id', 'stack_status', 'creation_time']
    formatters = {
        'id': lambda row: '%s/%s' % (row.stack_name, row.id)
    }
    utils.print_list(stacks, fields, field_labels,
        formatters=formatters, sortby=2)
Esempio n. 7
0
def do_stack_list(hc, args=None):
    '''List the user's stacks.'''
    kwargs = {}
    if args:
        kwargs = {'limit': args.limit,
                  'marker': args.marker,
                  'filters': utils.format_parameters(args.filters)}

    stacks = hc.stacks.list(**kwargs)
    fields = ['id', 'stack_name', 'stack_status', 'creation_time']
    utils.print_list(stacks, fields, sortby_index=3)
Esempio n. 8
0
def do_stack_list(hc, args=None):
    '''List the user's stacks.'''
    kwargs = {}
    if args:
        kwargs = {'limit': args.limit,
                  'marker': args.marker,
                  'filters': utils.format_parameters(args.filters),
                  'global_tenant': args.global_tenant}

    stacks = hc.stacks.list(**kwargs)
    fields = ['id', 'stack_name', 'stack_status', 'creation_time']
    utils.print_list(stacks, fields, sortby_index=3)
Esempio n. 9
0
def do_output_list(hc, args):
    """Show available outputs."""
    try:
        stack = hc.stacks.get(stack_id=args.id)
    except exc.HTTPNotFound:
        raise exc.CommandError("Stack not found: %s" % args.id)
    else:
        outputs = stack.to_dict()["outputs"]
        fields = ["output_key", "description"]
        formatters = {"output_key": lambda x: x["output_key"], "description": lambda x: x["description"]}

        utils.print_list(outputs, fields, formatters=formatters)
Esempio n. 10
0
def do_event_list(hc, args):
    '''List events for a stack.'''
    fields = {'stack_id': args.id,
              'resource_name': args.resource}
    try:
        events = hc.events.list(**fields)
    except exc.HTTPNotFound:
        raise exc.CommandError('Stack not found: %s' % args.id)
    else:
        fields = ['logical_resource_id', 'id', 'resource_status_reason',
                  'resource_status', 'event_time']
        utils.print_list(events, fields, sortby=4)
Esempio n. 11
0
def do_stack_list(hc, args=None):
    """List the user's stacks."""
    kwargs = {}
    if args:
        kwargs = {
            "limit": args.limit,
            "marker": args.marker,
            "filters": utils.format_parameters(args.filters),
            "global_tenant": args.global_tenant,
        }

    stacks = hc.stacks.list(**kwargs)
    fields = ["id", "stack_name", "stack_status", "creation_time"]
    utils.print_list(stacks, fields, sortby_index=3)
Esempio n. 12
0
def do_output_list(hc, args):
    '''Show available outputs.'''
    try:
        stack = hc.stacks.get(stack_id=args.id)
    except exc.HTTPNotFound:
        raise exc.CommandError('Stack not found: %s' % args.id)
    else:
        outputs = stack.to_dict()['outputs']
        fields = ['output_key', 'description']
        formatters = {
            'output_key': lambda x: x['output_key'],
            'description': lambda x: x['description'],
        }

        utils.print_list(outputs, fields, formatters=formatters)
Esempio n. 13
0
def do_output_list(hc, args):
    '''Show available outputs.'''
    try:
        stack = hc.stacks.get(stack_id=args.id)
    except exc.HTTPNotFound:
        raise exc.CommandError('Stack not found: %s' % args.id)
    else:
        outputs = stack.to_dict()['outputs']
        fields = ['output_key', 'description']
        formatters = {
            'output_key': lambda x: x['output_key'],
            'description': lambda x: x['description'],
        }

        utils.print_list(outputs, fields, formatters=formatters)
Esempio n. 14
0
def do_resource_list(hc, args):
    """Show list of resources belonging to a stack."""
    fields = {"stack_id": args.id}
    try:
        resources = hc.resources.list(**fields)
    except exc.HTTPNotFound:
        raise exc.CommandError("Stack not found: %s" % args.id)
    else:
        fields = ["resource_type", "resource_status", "updated_time"]
        if len(resources) >= 1 and not hasattr(resources[0], "resource_name"):
            fields.insert(0, "logical_resource_id")
        else:
            fields.insert(0, "resource_name")

        utils.print_list(resources, fields, sortby_index=3)
Esempio n. 15
0
def do_resource_list(hc, args):
    '''Show list of resources belonging to a stack.'''
    fields = {'stack_id': args.id}
    try:
        resources = hc.resources.list(**fields)
    except exc.HTTPNotFound:
        raise exc.CommandError('Stack not found: %s' % args.id)
    else:
        fields = ['resource_type', 'resource_status', 'updated_time']
        if len(resources) >= 1 and not hasattr(resources[0], 'resource_name'):
            fields.insert(0, 'logical_resource_id')
        else:
            fields.insert(0, 'resource_name')

        utils.print_list(resources, fields, sortby_index=3)
Esempio n. 16
0
def do_resource_list(hc, args):
    '''Show list of resources belonging to a stack.'''
    fields = {'stack_id': args.id}
    try:
        resources = hc.resources.list(**fields)
    except exc.HTTPNotFound:
        raise exc.CommandError('Stack not found: %s' % args.id)
    else:
        fields = ['resource_type', 'resource_status', 'updated_time']
        if len(resources) >= 1 and not hasattr(resources[0], 'resource_name'):
            fields.insert(0, 'logical_resource_id')
        else:
            fields.insert(0, 'resource_name')

        utils.print_list(resources, fields, sortby_index=3)
Esempio n. 17
0
def _list_stack(module, heat):
    fields = [
        'id', 'stack_name', 'stack_status', 'creation_time', 'updated_time'
    ]
    uids = []
    stacks = heat.stacks.list()
    return utils.print_list(stacks, fields)
Esempio n. 18
0
def do_event_list(hc, args):
    '''List events for a stack.'''
    fields = {'stack_id': args.id,
              'resource_name': args.resource}
    try:
        events = hc.events.list(**fields)
    except exc.HTTPNotFound:
        raise exc.CommandError('Stack not found: %s' % args.id)
    else:
        fields = ['id', 'resource_status_reason',
                  'resource_status', 'event_time']
        if len(events) >= 1:
            if hasattr(events[0], 'resource_name'):
                fields.insert(0, 'resource_name')
            else:
                fields.insert(0, 'logical_resource_id')
        utils.print_list(events, fields)
Esempio n. 19
0
def do_event_list(hc, args):
    """List events for a stack."""
    fields = {"stack_id": args.id, "resource_name": args.resource}
    try:
        events = hc.events.list(**fields)
    except exc.HTTPNotFound as ex:
        # it could be the stack or resource that is not found
        # just use the message that the server sent us.
        raise exc.CommandError(str(ex))
    else:
        fields = ["id", "resource_status_reason", "resource_status", "event_time"]
        if len(events) >= 1:
            if hasattr(events[0], "resource_name"):
                fields.insert(0, "resource_name")
            else:
                fields.insert(0, "logical_resource_id")
        utils.print_list(events, fields)
Esempio n. 20
0
def do_event_list(hc, args):
    '''List events for a stack.'''
    fields = {'stack_id': args.id,
              'resource_name': args.resource}
    try:
        events = hc.events.list(**fields)
    except exc.HTTPNotFound as ex:
        # it could be the stack or resource that is not found
        # just use the message that the server sent us.
        raise exc.CommandError(str(ex))
    else:
        fields = ['id', 'resource_status_reason',
                  'resource_status', 'event_time']
        if len(events) >= 1:
            if hasattr(events[0], 'resource_name'):
                fields.insert(0, 'resource_name')
            else:
                fields.insert(0, 'logical_resource_id')
        utils.print_list(events, fields)
Esempio n. 21
0
def do_snapshot_list(hc, args):
    '''List the snapshots of a stack.'''
    fields = {'stack_id': args.id}
    try:
        snapshots = hc.stacks.snapshot_list(**fields)
    except exc.HTTPNotFound:
        raise exc.CommandError(_('Stack not found: %s') % args.id)
    else:
        fields = ['id', 'name', 'status', 'status_reason', 'data',
                  'creation_time']
        formatters = {
            'id': lambda x: x['id'],
            'name': lambda x: x['name'],
            'status': lambda x: x['status'],
            'status_reason': lambda x: x['status_reason'],
            'data': lambda x: jsonutils.dumps(x['data'], indent=2,
                                              ensure_ascii=False),
            'creation_time': lambda x: x['creation_time'],
        }
        utils.print_list(snapshots["snapshots"], fields, formatters=formatters)
Esempio n. 22
0
def do_stack_list(hc, args=None):
    '''List the user's stacks.'''
    kwargs = {}
    fields = ['id', 'stack_name', 'stack_status', 'creation_time']
    if args:
        kwargs = {'limit': args.limit,
                  'marker': args.marker,
                  'filters': utils.format_parameters(args.filters),
                  'global_tenant': args.global_tenant,
                  'show_deleted': args.show_deleted}
        if args.show_nested:
            fields.append('parent')
            kwargs['show_nested'] = True

        if args.global_tenant or args.show_owner:
            fields.insert(2, 'stack_owner')
        if args.global_tenant:
            fields.insert(2, 'project')

    stacks = hc.stacks.list(**kwargs)
    utils.print_list(stacks, fields, sortby_index=3)
Esempio n. 23
0
def do_stack_list(hc, args=None):
    '''List the user's stacks.'''
    kwargs = {}
    fields = ['id', 'stack_name', 'stack_status', 'creation_time']
    if args:
        kwargs = {
            'limit': args.limit,
            'marker': args.marker,
            'filters': utils.format_parameters(args.filters),
            'global_tenant': args.global_tenant,
            'show_deleted': args.show_deleted
        }
        if args.show_nested:
            fields.append('parent')
            kwargs['show_nested'] = True

        if args.global_tenant or args.show_owner:
            fields.insert(2, 'stack_owner')
        if args.global_tenant:
            fields.insert(2, 'project')

    stacks = hc.stacks.list(**kwargs)
    utils.print_list(stacks, fields, sortby_index=3)
Esempio n. 24
0
def do_event_list(hc, args):
    '''List events for a stack.'''
    fields = {'stack_id': args.id,
              'resource_name': args.resource,
              'limit': args.limit,
              'marker': args.marker,
              'filters': utils.format_parameters(args.filters),
              'sort_dir': 'asc'}
    try:
        events = hc.events.list(**fields)
    except exc.HTTPNotFound as ex:
        # it could be the stack or resource that is not found
        # just use the message that the server sent us.
        raise exc.CommandError(str(ex))
    else:
        fields = ['id', 'resource_status_reason',
                  'resource_status', 'event_time']
        if len(events) >= 1:
            if hasattr(events[0], 'resource_name'):
                fields.insert(0, 'resource_name')
            else:
                fields.insert(0, 'logical_resource_id')
        utils.print_list(events, fields, sortby_index=None)
Esempio n. 25
0
def do_stack_list(hc, args=None):
    """List the user's stacks."""
    kwargs = {}
    fields = ["id", "stack_name", "stack_status", "creation_time"]
    if args:
        kwargs = {
            "limit": args.limit,
            "marker": args.marker,
            "filters": utils.format_parameters(args.filters),
            "global_tenant": args.global_tenant,
            "show_deleted": args.show_deleted,
        }
        if args.show_nested:
            fields.append("parent")
            kwargs["show_nested"] = True

        if args.global_tenant or args.show_owner:
            fields.insert(2, "stack_owner")
        if args.global_tenant:
            fields.insert(2, "project")

    stacks = hc.stacks.list(**kwargs)
    utils.print_list(stacks, fields, sortby_index=3)
Esempio n. 26
0
def do_resource_type_list(hc, args={}):
    '''List the available resource types.'''
    kwargs = {}
    types = hc.resource_types.list(**kwargs)
    utils.print_list(types, ['resource_type'], sortby=0)
Esempio n. 27
0
def do_resource_type_list(hc, args):
    '''List the available resource types.'''
    types = hc.resource_types.list()
    utils.print_list(types, ['resource_type'], sortby_index=0)
Esempio n. 28
0
def _list_stack(module, heat):
    fields = ['id', 'stack_name', 'stack_status', 'creation_time',
              'updated_time']
    uids = []
    stacks = heat.stacks.list()
    return utils.print_list(stacks, fields)
Esempio n. 29
0
def do_service_list(hc, args=None):
    '''List the Heat engines.'''
    fields = ['hostname', 'binary', 'engine_id', 'host',
              'topic', 'updated_at', 'status']
    services = hc.services.list()
    utils.print_list(services, fields, sortby_index=1)
Esempio n. 30
0
def _list_stack(module, heat):
    fields = ["id", "stack_name", "stack_status", "creation_time", "updated_time"]
    uids = []
    stacks = heat.stacks.list()
    return utils.print_list(stacks, fields)
Esempio n. 31
0
def do_resource_type_list(hc, args):
    """List the available resource types."""
    types = hc.resource_types.list()
    utils.print_list(types, ["resource_type"], sortby_index=0)
Esempio n. 32
0
def do_resource_type_list(hc, args):
    '''List the available resource types.'''
    types = hc.resource_types.list()
    utils.print_list(types, ['resource_type'], sortby_index=0)