Merge "Remove the --long parameter when listing flavors"
This commit is contained in:
commit
a3a5a6383f
@ -128,43 +128,25 @@ 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
|
||||
|
||||
data = bc_client.flavor.list()
|
||||
|
||||
if parsed_args.long:
|
||||
# This is the easiest way to change column headers
|
||||
column_headers = (
|
||||
"UUID",
|
||||
"Name",
|
||||
"Is Public",
|
||||
"Description",
|
||||
"Properties",
|
||||
)
|
||||
columns = (
|
||||
"UUID",
|
||||
"Name",
|
||||
"Is Public",
|
||||
"Description",
|
||||
"Extra Specs",
|
||||
)
|
||||
else:
|
||||
column_headers = columns = (
|
||||
"UUID",
|
||||
"Name",
|
||||
"Is Public",
|
||||
)
|
||||
column_headers = (
|
||||
"UUID",
|
||||
"Name",
|
||||
"Is Public",
|
||||
"Description",
|
||||
"Properties",
|
||||
)
|
||||
columns = (
|
||||
"UUID",
|
||||
"Name",
|
||||
"Is Public",
|
||||
"Description",
|
||||
"Extra Specs",
|
||||
)
|
||||
|
||||
return (column_headers,
|
||||
(utils.get_item_properties(
|
||||
|
@ -219,23 +219,11 @@ class TestFlavorList(TestFlavor):
|
||||
"UUID",
|
||||
"Name",
|
||||
"Is Public",
|
||||
)
|
||||
|
||||
list_columns_long = (
|
||||
"UUID",
|
||||
"Name",
|
||||
"Is Public",
|
||||
"Description",
|
||||
"Properties",
|
||||
)
|
||||
|
||||
list_data = ((
|
||||
TestFlavor.fake_flavor.uuid,
|
||||
TestFlavor.fake_flavor.name,
|
||||
TestFlavor.fake_flavor.is_public,
|
||||
),)
|
||||
|
||||
list_data_long = ((
|
||||
TestFlavor.fake_flavor.uuid,
|
||||
TestFlavor.fake_flavor.name,
|
||||
TestFlavor.fake_flavor.is_public,
|
||||
@ -257,20 +245,6 @@ class TestFlavorList(TestFlavor):
|
||||
self.assertEqual(self.list_columns, columns)
|
||||
self.assertEqual(self.list_data, tuple(data))
|
||||
|
||||
def test_flavor_list_with_long(self, mock_list):
|
||||
arglist = [
|
||||
'--long',
|
||||
]
|
||||
verifylist = [
|
||||
('long', True),
|
||||
]
|
||||
mock_list.return_value = [self.fake_flavor]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
mock_list.assert_called_once_with('/types', response_key='types')
|
||||
self.assertEqual(self.list_columns_long, columns)
|
||||
self.assertEqual(self.list_data_long, tuple(data))
|
||||
|
||||
|
||||
@mock.patch.object(utils, 'find_resource')
|
||||
@mock.patch.object(flavor_mgr.FlavorManager, '_delete')
|
||||
|
Loading…
x
Reference in New Issue
Block a user