summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-07 07:40:37 +0000
committerGerrit Code Review <review@openstack.org>2017-06-07 07:40:37 +0000
commit7d5539f28e95bb2264dbc8268614ea348fb293c3 (patch)
tree6e0f2e6abf5c7f87175770bf99e7e4bf7335298c
parent821e29f6d7b77ddc671f674cbca44f04d4c7d2c7 (diff)
parent2850d1714fbf5100a920d65b47bb748f8394af6d (diff)
Merge "Add the support for 'detail' flag"2.6.0
-rw-r--r--magnumclient/tests/v1/test_baymodels_shell.py10
-rw-r--r--magnumclient/tests/v1/test_clustertemplates_shell.py11
-rw-r--r--magnumclient/v1/basemodels.py5
-rw-r--r--magnumclient/v1/baymodels_shell.py13
-rw-r--r--magnumclient/v1/cluster_templates_shell.py13
5 files changed, 46 insertions, 6 deletions
diff --git a/magnumclient/tests/v1/test_baymodels_shell.py b/magnumclient/tests/v1/test_baymodels_shell.py
index 9eb3743..200cd5d 100644
--- a/magnumclient/tests/v1/test_baymodels_shell.py
+++ b/magnumclient/tests/v1/test_baymodels_shell.py
@@ -37,11 +37,12 @@ class FakeBayModel(BayModel):
37class ShellTest(shell_test_base.TestCommandLineArgument): 37class ShellTest(shell_test_base.TestCommandLineArgument):
38 38
39 def _get_expected_args_list(self, limit=None, sort_dir=None, 39 def _get_expected_args_list(self, limit=None, sort_dir=None,
40 sort_key=None): 40 sort_key=None, detail=False):
41 expected_args = {} 41 expected_args = {}
42 expected_args['limit'] = limit 42 expected_args['limit'] = limit
43 expected_args['sort_dir'] = sort_dir 43 expected_args['sort_dir'] = sort_dir
44 expected_args['sort_key'] = sort_key 44 expected_args['sort_key'] = sort_key
45 expected_args['detail'] = detail
45 46
46 return expected_args 47 return expected_args
47 48
@@ -550,6 +551,13 @@ class ShellTest(shell_test_base.TestCommandLineArgument):
550 mock_list.assert_called_once_with(**expected_args) 551 mock_list.assert_called_once_with(**expected_args)
551 552
552 @mock.patch('magnumclient.v1.baymodels.BayModelManager.list') 553 @mock.patch('magnumclient.v1.baymodels.BayModelManager.list')
554 def test_baymodel_list_success_detailed(self, mock_list):
555 self._test_arg_success('baymodel-list '
556 '--detail')
557 expected_args = self._get_expected_args_list(detail=True)
558 mock_list.assert_called_once_with(**expected_args)
559
560 @mock.patch('magnumclient.v1.baymodels.BayModelManager.list')
553 def test_baymodel_list_ignored_duplicated_field(self, mock_list): 561 def test_baymodel_list_ignored_duplicated_field(self, mock_list):
554 mock_list.return_value = [FakeBayModel()] 562 mock_list.return_value = [FakeBayModel()]
555 self._test_arg_success('baymodel-list --fields coe,coe,coe,name,name', 563 self._test_arg_success('baymodel-list --fields coe,coe,coe,name,name',
diff --git a/magnumclient/tests/v1/test_clustertemplates_shell.py b/magnumclient/tests/v1/test_clustertemplates_shell.py
index eaaba06..fcdbf2b 100644
--- a/magnumclient/tests/v1/test_clustertemplates_shell.py
+++ b/magnumclient/tests/v1/test_clustertemplates_shell.py
@@ -37,11 +37,12 @@ class FakeClusterTemplate(ClusterTemplate):
37class ShellTest(shell_test_base.TestCommandLineArgument): 37class ShellTest(shell_test_base.TestCommandLineArgument):
38 38
39 def _get_expected_args_list(self, limit=None, sort_dir=None, 39 def _get_expected_args_list(self, limit=None, sort_dir=None,
40 sort_key=None): 40 sort_key=None, detail=False):
41 expected_args = {} 41 expected_args = {}
42 expected_args['limit'] = limit 42 expected_args['limit'] = limit
43 expected_args['sort_dir'] = sort_dir 43 expected_args['sort_dir'] = sort_dir
44 expected_args['sort_key'] = sort_key 44 expected_args['sort_key'] = sort_key
45 expected_args['detail'] = detail
45 46
46 return expected_args 47 return expected_args
47 48
@@ -732,6 +733,14 @@ class ShellTest(shell_test_base.TestCommandLineArgument):
732 733
733 @mock.patch( 734 @mock.patch(
734 'magnumclient.v1.cluster_templates.ClusterTemplateManager.list') 735 'magnumclient.v1.cluster_templates.ClusterTemplateManager.list')
736 def test_cluster_template_list_success_detailed(self, mock_list):
737 self._test_arg_success('cluster-template-list '
738 '--detail')
739 expected_args = self._get_expected_args_list(detail=True)
740 mock_list.assert_called_once_with(**expected_args)
741
742 @mock.patch(
743 'magnumclient.v1.cluster_templates.ClusterTemplateManager.list')
735 def test_cluster_template_list_ignored_duplicated_field(self, mock_list): 744 def test_cluster_template_list_ignored_duplicated_field(self, mock_list):
736 mock_list.return_value = [FakeClusterTemplate()] 745 mock_list.return_value = [FakeClusterTemplate()]
737 self._test_arg_success( 746 self._test_arg_success(
diff --git a/magnumclient/v1/basemodels.py b/magnumclient/v1/basemodels.py
index d2715c2..0334b89 100644
--- a/magnumclient/v1/basemodels.py
+++ b/magnumclient/v1/basemodels.py
@@ -24,6 +24,11 @@ CREATION_ATTRIBUTES = ['name', 'image_id', 'flavor_id', 'master_flavor_id',
24 'docker_storage_driver', 'master_lb_enabled', 24 'docker_storage_driver', 'master_lb_enabled',
25 'floating_ip_enabled'] 25 'floating_ip_enabled']
26 26
27OUTPUT_ATTRIBUTES = CREATION_ATTRIBUTES + ['apiserver_port', 'created_at',
28 'insecure_registry', 'links',
29 'updated_at', 'cluster_distro',
30 'uuid']
31
27 32
28class BaseModel(base.Resource): 33class BaseModel(base.Resource):
29 # model_name needs to be overridden by any derived class. 34 # model_name needs to be overridden by any derived class.
diff --git a/magnumclient/v1/baymodels_shell.py b/magnumclient/v1/baymodels_shell.py
index dfd6fb0..53bf7c0 100644
--- a/magnumclient/v1/baymodels_shell.py
+++ b/magnumclient/v1/baymodels_shell.py
@@ -15,6 +15,7 @@
15from magnumclient.common import cliutils as utils 15from magnumclient.common import cliutils as utils
16from magnumclient.common import utils as magnum_utils 16from magnumclient.common import utils as magnum_utils
17from magnumclient.i18n import _ 17from magnumclient.i18n import _
18from magnumclient.v1 import basemodels
18 19
19 20
20DEPRECATION_MESSAGE = ( 21DEPRECATION_MESSAGE = (
@@ -211,6 +212,10 @@ def do_baymodel_show(cs, args):
211 'apiserver_port, server_type, tls_disabled, registry_enabled' 212 'apiserver_port, server_type, tls_disabled, registry_enabled'
212 ) 213 )
213 ) 214 )
215@utils.arg('--detail',
216 action='store_true', default=False,
217 help=_('Show detailed information about the baymodels.')
218 )
214@utils.deprecated(DEPRECATION_MESSAGE) 219@utils.deprecated(DEPRECATION_MESSAGE)
215def do_baymodel_list(cs, args): 220def do_baymodel_list(cs, args):
216 """Print a list of baymodels. 221 """Print a list of baymodels.
@@ -219,8 +224,12 @@ def do_baymodel_list(cs, args):
219 """ 224 """
220 nodes = cs.baymodels.list(limit=args.limit, 225 nodes = cs.baymodels.list(limit=args.limit,
221 sort_key=args.sort_key, 226 sort_key=args.sort_key,
222 sort_dir=args.sort_dir) 227 sort_dir=args.sort_dir,
223 columns = ['uuid', 'name'] 228 detail=args.detail)
229 if args.detail:
230 columns = basemodels.OUTPUT_ATTRIBUTES
231 else:
232 columns = ['uuid', 'name']
224 columns += utils._get_list_table_columns_and_formatters( 233 columns += utils._get_list_table_columns_and_formatters(
225 args.fields, nodes, 234 args.fields, nodes,
226 exclude_fields=(c.lower() for c in columns))[0] 235 exclude_fields=(c.lower() for c in columns))[0]
diff --git a/magnumclient/v1/cluster_templates_shell.py b/magnumclient/v1/cluster_templates_shell.py
index 7e602ef..0c9a3ac 100644
--- a/magnumclient/v1/cluster_templates_shell.py
+++ b/magnumclient/v1/cluster_templates_shell.py
@@ -15,6 +15,7 @@
15from magnumclient.common import cliutils as utils 15from magnumclient.common import cliutils as utils
16from magnumclient.common import utils as magnum_utils 16from magnumclient.common import utils as magnum_utils
17from magnumclient.i18n import _ 17from magnumclient.i18n import _
18from magnumclient.v1 import basemodels
18 19
19 20
20# Maps old parameter names to their new names and whether they are required 21# Maps old parameter names to their new names and whether they are required
@@ -259,12 +260,20 @@ def do_cluster_template_show(cs, args):
259 'apiserver_port, server_type, tls_disabled, registry_enabled' 260 'apiserver_port, server_type, tls_disabled, registry_enabled'
260 ) 261 )
261 ) 262 )
263@utils.arg('--detail',
264 action='store_true', default=False,
265 help=_('Show detailed information about the cluster templates.')
266 )
262def do_cluster_template_list(cs, args): 267def do_cluster_template_list(cs, args):
263 """Print a list of cluster templates.""" 268 """Print a list of cluster templates."""
264 nodes = cs.cluster_templates.list(limit=args.limit, 269 nodes = cs.cluster_templates.list(limit=args.limit,
265 sort_key=args.sort_key, 270 sort_key=args.sort_key,
266 sort_dir=args.sort_dir) 271 sort_dir=args.sort_dir,
267 columns = ['uuid', 'name'] 272 detail=args.detail)
273 if args.detail:
274 columns = basemodels.OUTPUT_ATTRIBUTES
275 else:
276 columns = ['uuid', 'name']
268 columns += utils._get_list_table_columns_and_formatters( 277 columns += utils._get_list_table_columns_and_formatters(
269 args.fields, nodes, 278 args.fields, nodes,
270 exclude_fields=(c.lower() for c in columns))[0] 279 exclude_fields=(c.lower() for c in columns))[0]