diff --git a/vitrageclient/v1/cli/resource.py b/vitrageclient/v1/cli/resource.py index 2a3b0a8..20969fa 100644 --- a/vitrageclient/v1/cli/resource.py +++ b/vitrageclient/v1/cli/resource.py @@ -36,14 +36,27 @@ class ResourceList(lister.Lister): def get_parser(self, prog_name): parser = super(ResourceList, self).get_parser(prog_name) - parser.add_argument('--type', dest='resource_type', + parser.add_argument('--type', + dest='resource_type', metavar='', help='Type of resource') + parser.add_argument('--all-tenants', + default=False, + dest='all_tenants', + action='store_true', + help='Shows resources of all the tenants') return parser def take_action(self, parsed_args): resource_type = parsed_args.resource_type + all_tenants = parsed_args.all_tenants resources = utils.get_client(self).resource.list( - resource_type=resource_type) - return [], resources + resource_type=resource_type, + all_tenants=all_tenants) + return utils.list2cols(('vitrage_id', + 'type', + 'name', + 'id', + 'state', + 'project_id'), resources) diff --git a/vitrageclient/v1/resource.py b/vitrageclient/v1/resource.py index 90f728f..20a7d06 100644 --- a/vitrageclient/v1/resource.py +++ b/vitrageclient/v1/resource.py @@ -17,12 +17,13 @@ class Resource(object): def __init__(self, api): self.api = api - def list(self, resource_type=None): + def list(self, resource_type=None, all_tenants=False): """Get a all resources :param resource_type: the type for the resources """ - params = dict(resource_type=resource_type) + params = dict(resource_type=resource_type, + all_tenants=all_tenants) return self.api.get(self.url, params=params).json() def get(self, resource_id):