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
This commit is contained in:
parent
2d5efb2e4d
commit
c165071ff8
|
@ -78,7 +78,13 @@ def args_array_to_patch(op, attributes):
|
|||
attr = '/' + attr
|
||||
if op in ['add', 'replace']:
|
||||
path, value = split_and_deserialize(attr)
|
||||
patch.append({'op': op, 'path': path, 'value': value})
|
||||
if path == "/labels":
|
||||
a = []
|
||||
a.append(value)
|
||||
value = str(handle_labels(a))
|
||||
patch.append({'op': op, 'path': path, 'value': value})
|
||||
else:
|
||||
patch.append({'op': op, 'path': path, 'value': value})
|
||||
|
||||
elif op == "remove":
|
||||
# For remove only the key is needed
|
||||
|
|
|
@ -679,6 +679,15 @@ class ShellTest(shell_test_base.TestCommandLineArgument):
|
|||
{'op': 'add', 'path': '/test1', 'value': 'test1'}]
|
||||
mock_update.assert_called_once_with('test', patch)
|
||||
|
||||
@mock.patch(
|
||||
'magnumclient.v1.cluster_templates.ClusterTemplateManager.update')
|
||||
def test_cluster_template_update_label(self, mock_update):
|
||||
self._test_arg_success('cluster-template-update test '
|
||||
'replace labels=key1=val1')
|
||||
patch = [{'op': 'replace', 'path': '/labels',
|
||||
'value': "{'key1': 'val1'}"}]
|
||||
mock_update.assert_called_once_with('test', patch)
|
||||
|
||||
@mock.patch(
|
||||
'magnumclient.v1.cluster_templates.ClusterTemplateManager.update')
|
||||
def test_cluster_template_update_failure_wrong_op(self, mock_update):
|
||||
|
|
Loading…
Reference in New Issue