Merge "Add --long parameter to flavor list cmd"

This commit is contained in:
Jenkins 2017-09-14 08:16:34 +00:00 committed by Gerrit Code Review
commit a473f6a541
2 changed files with 50 additions and 19 deletions

View File

@ -129,30 +129,61 @@ class DeleteFlavor(command.Command):
class ListFlavor(command.Lister):
"""List all baremetal flavors"""
def get_parser(self, prog_name):
parser = super(ListFlavor, self).get_parser(prog_name)
parser.add_argument(
'--long',
action='store_true',
default=False,
help=_("List additional fields in output")
)
return parser
def take_action(self, parsed_args):
bc_client = self.app.client_manager.baremetal_compute
if parsed_args.long:
column_headers = (
"UUID",
"Name",
"Is Public",
"Description",
"Resources",
"Aggregates",
"Disabled",
)
columns = (
"uuid",
"name",
"is_public",
"description",
"resources",
"resource_aggregates",
"disabled",
)
else:
column_headers = (
"UUID",
"Name",
"Is Public",
"Description",
"Resources",
)
columns = (
"uuid",
"name",
"is_public",
"description",
"resources",
)
data = bc_client.flavor.list()
column_headers = (
"UUID",
"Name",
"Is Public",
"Description",
"Resources",
)
columns = (
"UUID",
"Name",
"Is Public",
"Description",
"Resources",
)
formatters = {'resources': utils.format_dict,
'resource_aggregates': utils.format_dict
}
return (column_headers,
(utils.get_item_properties(
s, columns,
) for s in data))
s, columns, formatters=formatters) for s in data))
class ShowFlavor(command.ShowOne):

View File

@ -231,7 +231,7 @@ class TestFlavorList(TestFlavor):
TestFlavor.fake_flavor.name,
TestFlavor.fake_flavor.is_public,
TestFlavor.fake_flavor.description,
TestFlavor.fake_flavor.resources,
"BAREMETAL_GOLD='1'",
),)
def setUp(self):