Skip to content

Commit 883f820

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Append existing information during subnet set"
2 parents 379fd72 + 03d932e commit 883f820

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

openstackclient/network/v2/subnet.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,12 @@ def take_action(self, parsed_args):
365365
if not attrs:
366366
msg = "Nothing specified to be set"
367367
raise exceptions.CommandError(msg)
368+
if 'dns_nameservers' in attrs:
369+
attrs['dns_nameservers'] += obj.dns_nameservers
370+
if 'host_routes' in attrs:
371+
attrs['host_routes'] += obj.host_routes
372+
if 'allocation_pools' in attrs:
373+
attrs['allocation_pools'] += obj.allocation_pools
368374
client.update_subnet(obj, **attrs)
369375
return
370376

openstackclient/tests/network/v2/test_subnet.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,26 @@ def test_set_nothing(self):
536536
self.assertRaises(exceptions.CommandError, self.cmd.take_action,
537537
parsed_args)
538538

539+
def test_append_options(self):
540+
_testsubnet = network_fakes.FakeSubnet.create_one_subnet(
541+
{'dns_nameservers': ["10.0.0.1"]})
542+
self.network.find_subnet = mock.Mock(return_value=_testsubnet)
543+
arglist = [
544+
'--dns-nameserver', '10.0.0.2',
545+
_testsubnet.name,
546+
]
547+
verifylist = [
548+
('dns_nameservers', ['10.0.0.2']),
549+
]
550+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
551+
result = self.cmd.take_action(parsed_args)
552+
attrs = {
553+
'dns_nameservers': ['10.0.0.2', '10.0.0.1'],
554+
}
555+
self.network.update_subnet.assert_called_once_with(
556+
_testsubnet, **attrs)
557+
self.assertIsNone(result)
558+
539559

540560
class TestShowSubnet(TestSubnet):
541561
# The subnets to be shown

0 commit comments

Comments
 (0)