Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)