Bugfix: Use fields option for cluster template list

`openstack cluster template list` accepts a `fields` option, but this
was not used. Fixed it to have some behaviour as legacy magnum client.

Also fixed tests.

Change-Id: I0d75f4b597a46b652c082ead3db5e3ad0b56b479
This commit is contained in:
Jake Yip 2020-01-14 12:35:02 +11:00
parent c0d3683608
commit 5b7a671319
2 changed files with 7 additions and 3 deletions

View File

@ -354,6 +354,8 @@ class ListTemplateCluster(command.Lister):
mag_client = self.app.client_manager.container_infra
columns = ['uuid', 'name']
if parsed_args.fields:
columns += parsed_args.fields.split(',')
cts = mag_client.cluster_templates.list(limit=parsed_args.limit,
sort_key=parsed_args.sort_key,
sort_dir=parsed_args.sort_dir)

View File

@ -271,22 +271,24 @@ class TestClusterTemplateList(TestClusterTemplate):
'--limit', '1',
'--sort-key', 'key',
'--sort-dir', 'asc',
'--fields', 'fields'
'--fields', 'field1,field2'
]
verifylist = [
('limit', 1),
('sort_key', 'key'),
('sort_dir', 'asc'),
('fields', 'fields'),
('fields', 'field1,field2'),
]
verifycolumns = self.columns + ['field1', 'field2']
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
columns, data = self.cmd.take_action(parsed_args)
self.cluster_templates_mock.list.assert_called_with(
limit=1,
sort_dir='asc',
sort_key='key',
)
self.assertEqual(verifycolumns, columns)
def test_cluster_template_list_bad_sort_dir_fail(self):
arglist = [