diff options
author | Kaifeng Wang <kaifeng.w@gmail.com> | 2018-01-24 15:10:15 +0800 |
---|---|---|
committer | Kaifeng Wang <kaifeng.w@gmail.com> | 2018-01-24 15:10:15 +0800 |
commit | 677a4d82358ac453744716952f6227bd6534f352 (patch) | |
tree | 19447f40fda4f019c38db396d223f0ae8f58951f | |
parent | 26602ce40f64561d3bc7e6c5711d97e18e708c2b (diff) | |
download | python-ironicclient-677a4d82358ac453744716952f6227bd6534f352.tar.gz |
Can not set portgroup mode as a number
When creating portgroup, mode accepts a string or a number, e.g.:
active-backup or 1.
While setting new mode for an existing portgroup will raise an error, if
the mode is passed as a number:
# openstack --os-baremetal-api-version 1.26 baremetal port group \
set c42f9bf8-3b5d-4673-b6c1-832c10e4fecf --mode 1
Invalid input for field/attribute mode. Value: '1'. Wrong type. Expected
'<type 'unicode'>', got '<type 'int'>' (HTTP 400)
This patch add quotes to mode string to avoid unwanted conversion.
Change-Id: I1bfe6d203c5420f06c8d7ead487250da1847e103
Closes-Bug: #1745099
-rw-r--r-- | ironicclient/osc/v1/baremetal_portgroup.py | 2 | ||||
-rw-r--r-- | ironicclient/tests/unit/osc/v1/test_baremetal_portgroup.py | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/ironicclient/osc/v1/baremetal_portgroup.py b/ironicclient/osc/v1/baremetal_portgroup.py index 20c7625..bd7f1a2 100644 --- a/ironicclient/osc/v1/baremetal_portgroup.py +++ b/ironicclient/osc/v1/baremetal_portgroup.py @@ -379,7 +379,7 @@ class SetBaremetalPortGroup(command.Command): 'add', ["standalone_ports_supported=False"])) if parsed_args.mode: properties.extend(utils.args_array_to_patch( - 'add', ["mode=%s" % parsed_args.mode])) + 'add', ["mode=\"%s\"" % parsed_args.mode])) if parsed_args.extra: properties.extend(utils.args_array_to_patch( diff --git a/ironicclient/tests/unit/osc/v1/test_baremetal_portgroup.py b/ironicclient/tests/unit/osc/v1/test_baremetal_portgroup.py index a7b0d14..1b8dbda 100644 --- a/ironicclient/tests/unit/osc/v1/test_baremetal_portgroup.py +++ b/ironicclient/tests/unit/osc/v1/test_baremetal_portgroup.py @@ -546,6 +546,23 @@ class TestBaremetalPortGroupSet(TestBaremetalPortGroup): [{'path': '/mode', 'value': new_portgroup_mode, 'op': 'add'}]) + def test_baremetal_portgroup_set_mode_int(self): + new_portgroup_mode = '4' + arglist = [ + baremetal_fakes.baremetal_portgroup_uuid, + '--mode', new_portgroup_mode] + verifylist = [ + ('portgroup', baremetal_fakes.baremetal_portgroup_uuid), + ('mode', new_portgroup_mode)] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + self.baremetal_mock.portgroup.update.assert_called_once_with( + baremetal_fakes.baremetal_portgroup_uuid, + [{'path': '/mode', 'value': new_portgroup_mode, + 'op': 'add'}]) + def test_baremetal_portgroup_set_node_uuid(self): new_node_uuid = 'nnnnnn-uuuuuuuu' arglist = [ |