Merge "Add a 'metadata' column to show resource optional properties"
This commit is contained in:
@@ -34,6 +34,11 @@ class ResourceShow(show.ShowOne):
|
|||||||
class ResourceList(lister.Lister):
|
class ResourceList(lister.Lister):
|
||||||
"""List resources"""
|
"""List resources"""
|
||||||
|
|
||||||
|
RESOURCE_PROPERTIES = \
|
||||||
|
('vitrage_id', 'type', 'id', 'state',
|
||||||
|
'aggregated_state', 'metadata')
|
||||||
|
METADATA = ('name', 'project_id', 'update_timestamp')
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
parser = super(ResourceList, self).get_parser(prog_name)
|
parser = super(ResourceList, self).get_parser(prog_name)
|
||||||
parser.add_argument('--type',
|
parser.add_argument('--type',
|
||||||
@@ -54,9 +59,12 @@ class ResourceList(lister.Lister):
|
|||||||
resources = utils.get_client(self).resource.list(
|
resources = utils.get_client(self).resource.list(
|
||||||
resource_type=resource_type,
|
resource_type=resource_type,
|
||||||
all_tenants=all_tenants)
|
all_tenants=all_tenants)
|
||||||
return utils.list2cols(('vitrage_id',
|
# cluster, zone and host don't have "project_id" property
|
||||||
'type',
|
# neutron.port don't have "name" property
|
||||||
'name',
|
# cluster don't have "update_timestamp"
|
||||||
'id',
|
for resource in resources:
|
||||||
'state',
|
resource['metadata'] = \
|
||||||
'project_id'), resources)
|
{item: resource[item] for item in self.METADATA
|
||||||
|
if item in resource}
|
||||||
|
|
||||||
|
return utils.list2cols(self.RESOURCE_PROPERTIES, resources)
|
||||||
|
Reference in New Issue
Block a user