From 5b7a67131920f42b2add9ad0d063e5d9ff01b611 Mon Sep 17 00:00:00 2001 From: Jake Yip Date: Tue, 14 Jan 2020 12:35:02 +1100 Subject: [PATCH] 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 --- magnumclient/osc/v1/cluster_templates.py | 2 ++ magnumclient/tests/osc/unit/v1/test_cluster_templates.py | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/magnumclient/osc/v1/cluster_templates.py b/magnumclient/osc/v1/cluster_templates.py index 54bd7816..852ee333 100644 --- a/magnumclient/osc/v1/cluster_templates.py +++ b/magnumclient/osc/v1/cluster_templates.py @@ -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) diff --git a/magnumclient/tests/osc/unit/v1/test_cluster_templates.py b/magnumclient/tests/osc/unit/v1/test_cluster_templates.py index 85c4ef4c..b5c1c352 100644 --- a/magnumclient/tests/osc/unit/v1/test_cluster_templates.py +++ b/magnumclient/tests/osc/unit/v1/test_cluster_templates.py @@ -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 = [