Merge "Append existing information during subnet set"
This commit is contained in:
@@ -365,6 +365,12 @@ class SetSubnet(command.Command):
|
|||||||
if not attrs:
|
if not attrs:
|
||||||
msg = "Nothing specified to be set"
|
msg = "Nothing specified to be set"
|
||||||
raise exceptions.CommandError(msg)
|
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)
|
client.update_subnet(obj, **attrs)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@@ -536,6 +536,26 @@ class TestSetSubnet(TestSubnet):
|
|||||||
self.assertRaises(exceptions.CommandError, self.cmd.take_action,
|
self.assertRaises(exceptions.CommandError, self.cmd.take_action,
|
||||||
parsed_args)
|
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):
|
class TestShowSubnet(TestSubnet):
|
||||||
# The subnets to be shown
|
# The subnets to be shown
|
||||||
|
Reference in New Issue
Block a user