summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorM V P Nitesh <m.nitesh@nectechnologies.in>2017-08-22 13:00:57 +0530
committerSpyros Trigazis (strigazi) <strigazi@gmail.com>2018-02-20 14:12:53 +0000
commitc165071ff8fee67adbc6bf9acee0368cdebf5503 (patch)
treec425878bdbbcf635dbaec9b715051b277dab74f2
parent2d5efb2e4da8bfae03a9e550dfa325115cc4cd3b (diff)
Now cluster-template-update works for "labels"
Now we are handling the label values converting them as a dictionary. But as magnum-api only accepts the input as string. We are converting the dictionary into string and passing to magnum-api. It is parsing the string to dictionary and storing the label value a dictionary. Change-Id: I2cec19e24c6dd32e209ca65a26a2f1999d8289e0 Depends-on: I4d64da78dc4ed4d5599533b54861b65bce609c28 Closes-Bug: #1659189
Notes
Notes (review): Code-Review+2: Spyros Trigazis (strigazi) <strigazi@gmail.com> Code-Review+1: Van Hung Pham <hungpv@vn.fujitsu.com> Code-Review+2: Madhuri Kumari <madhuri.kumari@intel.com> Workflow+1: Spyros Trigazis (strigazi) <strigazi@gmail.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 20 Feb 2018 14:29:14 +0000 Reviewed-on: https://review.openstack.org/496136 Project: openstack/python-magnumclient Branch: refs/heads/master
-rw-r--r--magnumclient/common/utils.py8
-rw-r--r--magnumclient/tests/v1/test_clustertemplates_shell.py9
2 files changed, 16 insertions, 1 deletions
diff --git a/magnumclient/common/utils.py b/magnumclient/common/utils.py
index 57ce02e..af5642f 100644
--- a/magnumclient/common/utils.py
+++ b/magnumclient/common/utils.py
@@ -78,7 +78,13 @@ def args_array_to_patch(op, attributes):
78 attr = '/' + attr 78 attr = '/' + attr
79 if op in ['add', 'replace']: 79 if op in ['add', 'replace']:
80 path, value = split_and_deserialize(attr) 80 path, value = split_and_deserialize(attr)
81 patch.append({'op': op, 'path': path, 'value': value}) 81 if path == "/labels":
82 a = []
83 a.append(value)
84 value = str(handle_labels(a))
85 patch.append({'op': op, 'path': path, 'value': value})
86 else:
87 patch.append({'op': op, 'path': path, 'value': value})
82 88
83 elif op == "remove": 89 elif op == "remove":
84 # For remove only the key is needed 90 # For remove only the key is needed
diff --git a/magnumclient/tests/v1/test_clustertemplates_shell.py b/magnumclient/tests/v1/test_clustertemplates_shell.py
index bb53ff6..67bce87 100644
--- a/magnumclient/tests/v1/test_clustertemplates_shell.py
+++ b/magnumclient/tests/v1/test_clustertemplates_shell.py
@@ -681,6 +681,15 @@ class ShellTest(shell_test_base.TestCommandLineArgument):
681 681
682 @mock.patch( 682 @mock.patch(
683 'magnumclient.v1.cluster_templates.ClusterTemplateManager.update') 683 'magnumclient.v1.cluster_templates.ClusterTemplateManager.update')
684 def test_cluster_template_update_label(self, mock_update):
685 self._test_arg_success('cluster-template-update test '
686 'replace labels=key1=val1')
687 patch = [{'op': 'replace', 'path': '/labels',
688 'value': "{'key1': 'val1'}"}]
689 mock_update.assert_called_once_with('test', patch)
690
691 @mock.patch(
692 'magnumclient.v1.cluster_templates.ClusterTemplateManager.update')
684 def test_cluster_template_update_failure_wrong_op(self, mock_update): 693 def test_cluster_template_update_failure_wrong_op(self, mock_update):
685 _error_msg = [ 694 _error_msg = [
686 '.*?^usage: magnum cluster-template-update ', 695 '.*?^usage: magnum cluster-template-update ',