Checkpoint list: show only plan name and id

No need to list the entire plan for each checkpoint in the checkpoint
list commands. Show only the name and id.

Change-Id: I50a7e65e8fe810e43e762a4355c7976c9c4eca96
This commit is contained in:
Yuval Brik
2017-08-14 11:09:30 +03:00
parent aa5d56495f
commit 9b77c76ed0
3 changed files with 11 additions and 9 deletions

View File

@@ -99,9 +99,13 @@ class ListCheckpoints(command.Lister):
column_headers = ['Id', 'Project id', 'Status', 'Protection plan',
'Metadata', 'Created at']
def plan_formatter(plan):
return "Name: %s\nId: %s" % (plan['name'],
plan['id'])
formatters = {"Protection plan": plan_formatter}
return (column_headers,
(osc_utils.get_item_properties(
s, column_headers
s, column_headers, formatters=formatters
) for s in data))

View File

@@ -71,14 +71,9 @@ class TestListCheckpoints(TestCheckpoints):
"dcb20606-ad71-40a3-80e4-ef0fafdad0c3",
"e486a2f49695423ca9c47e589b948108",
"available",
{
"Name: %(name)s\nId: %(id)s" % {
"id": "3523a271-68aa-42f5-b9ba-56e5200a2ebb",
"name": "My application",
"provider_id": "cf56bd3e-97a7-4078-b6d5-f36246333fd9",
"resources": [{
"id": "99777fdd-8a5b-45ab-ba2c-52420008103f",
"type": "OS::Glance::Image",
"name": "cirros-0.3.4-x86_64-uec"}]
},
'',
'')]

View File

@@ -670,8 +670,11 @@ def do_checkpoint_list(cs, args):
sortby_index = None
else:
sortby_index = 0
formatters = {"Protection plan": lambda obj: json.dumps(
obj.protection_plan, indent=2, sort_keys=True)}
def plan_formatter(obj):
return "Name: %s\nId: %s" % (obj.protection_plan['name'],
obj.protection_plan['id'])
formatters = {"Protection plan": plan_formatter}
utils.print_list(checkpoints, key_list, exclude_unavailable=True,
sortby_index=sortby_index, formatters=formatters)