summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
authorreedip <reedip.banerjee@nectechnologies.in>2016-04-08 11:41:33 +0900
committerReedip <reedip.banerjee@nectechnologies.in>2016-04-08 06:19:09 +0000
commit03d932ea0b3074187bfcdd9c0422a968f5f56c59 (patch)
tree619b04639468ecf22761e7e2ff2dec26cf60946e /openstackclient
parent7ad529ec244e8b5ba13542eeb03d78acbdb7163e (diff)
downloadpython-openstackclient-03d932ea0b3074187bfcdd9c0422a968f5f56c59.tar.gz
Append existing information during subnet set
Existing values of --dns-nameserver, --allocation-pool and --houst-routes is currently overwritten when a user executes 'port set', but actually that data should be appended. This patch fixes the issue. Closes-Bug: #1564447 Change-Id: I3dba9afa68d869abb3960b55a6880401a10eebf7
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/network/v2/subnet.py6
-rw-r--r--openstackclient/tests/network/v2/test_subnet.py20
2 files changed, 26 insertions, 0 deletions
diff --git a/openstackclient/network/v2/subnet.py b/openstackclient/network/v2/subnet.py
index 10e5859a..45e68235 100644
--- a/openstackclient/network/v2/subnet.py
+++ b/openstackclient/network/v2/subnet.py
@@ -366,6 +366,12 @@ class SetSubnet(command.Command):
if not attrs:
msg = "Nothing specified to be set"
raise exceptions.CommandError(msg)
+ if 'dns_nameservers' in attrs:
+ attrs['dns_nameservers'] += obj.dns_nameservers
+ if 'host_routes' in attrs:
+ attrs['host_routes'] += obj.host_routes
+ if 'allocation_pools' in attrs:
+ attrs['allocation_pools'] += obj.allocation_pools
client.update_subnet(obj, **attrs)
return
diff --git a/openstackclient/tests/network/v2/test_subnet.py b/openstackclient/tests/network/v2/test_subnet.py
index 2535bbe6..ede37416 100644
--- a/openstackclient/tests/network/v2/test_subnet.py
+++ b/openstackclient/tests/network/v2/test_subnet.py
@@ -536,6 +536,26 @@ class TestSetSubnet(TestSubnet):
self.assertRaises(exceptions.CommandError, self.cmd.take_action,
parsed_args)
+ def test_append_options(self):
+ _testsubnet = network_fakes.FakeSubnet.create_one_subnet(
+ {'dns_nameservers': ["10.0.0.1"]})
+ self.network.find_subnet = mock.Mock(return_value=_testsubnet)
+ arglist = [
+ '--dns-nameserver', '10.0.0.2',
+ _testsubnet.name,
+ ]
+ verifylist = [
+ ('dns_nameservers', ['10.0.0.2']),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+ result = self.cmd.take_action(parsed_args)
+ attrs = {
+ 'dns_nameservers': ['10.0.0.2', '10.0.0.1'],
+ }
+ self.network.update_subnet.assert_called_once_with(
+ _testsubnet, **attrs)
+ self.assertIsNone(result)
+
class TestShowSubnet(TestSubnet):
# The subnets to be shown