summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
authorBharat Kunwar <bharat@stackhpc.com>2021-03-05 12:52:26 +0000
committerBharat Kunwar <bharat@stackhpc.com>2021-03-05 14:15:20 +0000
commited731d6cd9254eae047d14ccd55132229e13e7d1 (patch)
tree8fdc0f62f2486f08c636d09f5cb81aa6e737fd58 /openstackclient
parenta507fb50f8b98b026be88de41f1bac49bafe19bf (diff)
downloadpython-openstackclient-ed731d6cd9254eae047d14ccd55132229e13e7d1.tar.gz
network: Add missing subnet unset --gateway <subnet-id>
Story: 2008695 Task: 42003 Change-Id: I9486a09531b11f27a9ff0d68fd4ad8c68a65cccf
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/network/v2/subnet.py7
-rw-r--r--openstackclient/tests/unit/network/v2/test_subnet.py4
2 files changed, 11 insertions, 0 deletions
diff --git a/openstackclient/network/v2/subnet.py b/openstackclient/network/v2/subnet.py
index f87f7abe..b98f8641 100644
--- a/openstackclient/network/v2/subnet.py
+++ b/openstackclient/network/v2/subnet.py
@@ -673,6 +673,11 @@ class UnsetSubnet(command.Command):
'(repeat option to unset multiple allocation pools)')
)
parser.add_argument(
+ '--gateway',
+ action='store_true',
+ help=_("Remove gateway IP from this subnet")
+ )
+ parser.add_argument(
'--dns-nameserver',
metavar='<dns-nameserver>',
action='append',
@@ -715,6 +720,8 @@ class UnsetSubnet(command.Command):
obj = client.find_subnet(parsed_args.subnet, ignore_missing=False)
attrs = {}
+ if parsed_args.gateway:
+ attrs['gateway_ip'] = None
if parsed_args.dns_nameservers:
attrs['dns_nameservers'] = copy.deepcopy(obj.dns_nameservers)
_update_arguments(attrs['dns_nameservers'],
diff --git a/openstackclient/tests/unit/network/v2/test_subnet.py b/openstackclient/tests/unit/network/v2/test_subnet.py
index 1b4bfdad..6085cda8 100644
--- a/openstackclient/tests/unit/network/v2/test_subnet.py
+++ b/openstackclient/tests/unit/network/v2/test_subnet.py
@@ -1264,6 +1264,7 @@ class TestUnsetSubnet(TestSubnet):
'end': '8.8.8.170'}],
'service_types': ['network:router_gateway',
'network:floatingip_agent_gateway'],
+ 'gateway_ip': 'fe80::a00a:0:c0de:0:1',
'tags': ['green', 'red'], })
self.network.find_subnet = mock.Mock(return_value=self._testsubnet)
self.network.update_subnet = mock.Mock(return_value=None)
@@ -1277,6 +1278,7 @@ class TestUnsetSubnet(TestSubnet):
'--host-route', 'destination=10.30.30.30/24,gateway=10.30.30.1',
'--allocation-pool', 'start=8.8.8.100,end=8.8.8.150',
'--service-type', 'network:router_gateway',
+ '--gateway',
self._testsubnet.name,
]
verifylist = [
@@ -1286,6 +1288,7 @@ class TestUnsetSubnet(TestSubnet):
('allocation_pools', [{
'start': '8.8.8.100', 'end': '8.8.8.150'}]),
('service_types', ['network:router_gateway']),
+ ('gateway', True),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -1297,6 +1300,7 @@ class TestUnsetSubnet(TestSubnet):
"destination": "10.20.20.0/24", "nexthop": "10.20.20.1"}],
'allocation_pools': [{'start': '8.8.8.160', 'end': '8.8.8.170'}],
'service_types': ['network:floatingip_agent_gateway'],
+ 'gateway_ip': None,
}
self.network.update_subnet.assert_called_once_with(
self._testsubnet, **attrs)