summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Rocha <rocha.porto@gmail.com>2017-10-09 11:54:17 +0000
committerRicardo Rocha <rocha.porto@gmail.com>2017-12-18 14:15:03 +0000
commit5e9f07b77c4c43de72b6297dd7393d11fa623a57 (patch)
tree13119e30742a8fbd8f88595e8255b7c565faac65
parent58ae37ea03fc81762540640dcc88bad9741ea83d (diff)
Set --labels default to None on cluster create
Set the default value for --labels to None, so the cluster template value is used when no explicit labels argument is given on cluster create. Closes-Bug: #1697651 Change-Id: I284db3f32cd5c8b6541d60c2a86d7d693ffbedea
Notes
Notes (review): Code-Review+2: Spyros Trigazis (strigazi) <strigazi@gmail.com> Code-Review+2: yatin <ykarel@redhat.com> Workflow+1: yatin <ykarel@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Wed, 27 Dec 2017 13:33:31 +0000 Reviewed-on: https://review.openstack.org/510546 Project: openstack/python-magnumclient Branch: refs/heads/master
-rw-r--r--magnumclient/osc/v1/clusters.py1
-rw-r--r--magnumclient/tests/osc/unit/v1/fakes.py2
-rw-r--r--magnumclient/tests/osc/unit/v1/test_clusters.py24
-rw-r--r--magnumclient/tests/v1/test_clusters_shell.py2
-rw-r--r--magnumclient/v1/clusters_shell.py2
5 files changed, 26 insertions, 5 deletions
diff --git a/magnumclient/osc/v1/clusters.py b/magnumclient/osc/v1/clusters.py
index 3a92acd..c6857b7 100644
--- a/magnumclient/osc/v1/clusters.py
+++ b/magnumclient/osc/v1/clusters.py
@@ -74,7 +74,6 @@ class CreateCluster(command.Command):
74 parser.add_argument('--labels', 74 parser.add_argument('--labels',
75 metavar='<KEY1=VALUE1,KEY2=VALUE2;KEY3=VALUE3...>', 75 metavar='<KEY1=VALUE1,KEY2=VALUE2;KEY3=VALUE3...>',
76 action='append', 76 action='append',
77 default=[],
78 help=_('Arbitrary labels in the form of key=value' 77 help=_('Arbitrary labels in the form of key=value'
79 'pairs to associate with a cluster ' 78 'pairs to associate with a cluster '
80 'template. May be used multiple times.')) 79 'template. May be used multiple times.'))
diff --git a/magnumclient/tests/osc/unit/v1/fakes.py b/magnumclient/tests/osc/unit/v1/fakes.py
index 703e3c4..81ccb34 100644
--- a/magnumclient/tests/osc/unit/v1/fakes.py
+++ b/magnumclient/tests/osc/unit/v1/fakes.py
@@ -110,7 +110,7 @@ class FakeClusterTemplate(object):
110 ct_info = { 110 ct_info = {
111 'links': [], 111 'links': [],
112 'insecure_registry': None, 112 'insecure_registry': None,
113 'labels': {}, 113 'labels': None,
114 'updated_at': None, 114 'updated_at': None,
115 'floating_ip_enabled': True, 115 'floating_ip_enabled': True,
116 'fixed_subnet': None, 116 'fixed_subnet': None,
diff --git a/magnumclient/tests/osc/unit/v1/test_clusters.py b/magnumclient/tests/osc/unit/v1/test_clusters.py
index 62f7671..a0bbe62 100644
--- a/magnumclient/tests/osc/unit/v1/test_clusters.py
+++ b/magnumclient/tests/osc/unit/v1/test_clusters.py
@@ -43,7 +43,6 @@ class TestClusterCreate(TestCluster):
43 'create_timeout': 60, 43 'create_timeout': 60,
44 'discovery_url': None, 44 'discovery_url': None,
45 'docker_volume_size': None, 45 'docker_volume_size': None,
46 'labels': {},
47 'flavor_id': None, 46 'flavor_id': None,
48 'keypair': None, 47 'keypair': None,
49 'master_count': 1, 48 'master_count': 1,
@@ -94,6 +93,29 @@ class TestClusterCreate(TestCluster):
94 self.assertRaises(magnum_fakes.MagnumParseException, 93 self.assertRaises(magnum_fakes.MagnumParseException,
95 self.check_parser, self.cmd, arglist, verifylist) 94 self.check_parser, self.cmd, arglist, verifylist)
96 95
96 def test_cluster_create_with_labels(self):
97 """Verifies labels are properly parsed when given as argument."""
98
99 expected_args = self._default_args
100 expected_args['labels'] = {
101 'arg1': 'value1', 'arg2': 'value2'
102 }
103
104 arglist = [
105 '--cluster-template', self._cluster.cluster_template_id,
106 '--labels', 'arg1=value1',
107 '--labels', 'arg2=value2',
108 self._cluster.name
109 ]
110 verifylist = [
111 ('cluster_template', self._cluster.cluster_template_id),
112 ('labels', ['arg1=value1', 'arg2=value2']),
113 ('name', self._cluster.name)
114 ]
115 parsed_args = self.check_parser(self.cmd, arglist, verifylist)
116 self.cmd.take_action(parsed_args)
117 self.clusters_mock.create.assert_called_with(**expected_args)
118
97 119
98class TestClusterDelete(TestCluster): 120class TestClusterDelete(TestCluster):
99 121
diff --git a/magnumclient/tests/v1/test_clusters_shell.py b/magnumclient/tests/v1/test_clusters_shell.py
index 866e514..244132c 100644
--- a/magnumclient/tests/v1/test_clusters_shell.py
+++ b/magnumclient/tests/v1/test_clusters_shell.py
@@ -59,7 +59,7 @@ class ShellTest(shell_test_base.TestCommandLineArgument):
59 master_count=1, node_count=1, 59 master_count=1, node_count=1,
60 create_timeout=60, keypair=None, 60 create_timeout=60, keypair=None,
61 docker_volume_size=None, 61 docker_volume_size=None,
62 labels={}, 62 labels=None,
63 discovery_url=None): 63 discovery_url=None):
64 expected_args = {} 64 expected_args = {}
65 expected_args['name'] = name 65 expected_args['name'] = name
diff --git a/magnumclient/v1/clusters_shell.py b/magnumclient/v1/clusters_shell.py
index 0480214..bbdb31b 100644
--- a/magnumclient/v1/clusters_shell.py
+++ b/magnumclient/v1/clusters_shell.py
@@ -106,7 +106,7 @@ def do_cluster_list(cs, args):
106 type=int, 106 type=int,
107 help=_('The size in GB for the docker volume to use')) 107 help=_('The size in GB for the docker volume to use'))
108@utils.arg('--labels', metavar='<KEY1=VALUE1,KEY2=VALUE2;KEY3=VALUE3...>', 108@utils.arg('--labels', metavar='<KEY1=VALUE1,KEY2=VALUE2;KEY3=VALUE3...>',
109 action='append', default=[], 109 action='append',
110 help=_('Arbitrary labels in the form of key=value pairs ' 110 help=_('Arbitrary labels in the form of key=value pairs '
111 'to associate with a cluster. ' 111 'to associate with a cluster. '
112 'May be used multiple times.')) 112 'May be used multiple times.'))