Skip to content

Commit 274d1ee

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "network: Add missing subnet unset --gateway <subnet-id>"
2 parents 9414435 + ed731d6 commit 274d1ee

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

openstackclient/network/v2/subnet.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,11 @@ def get_parser(self, prog_name):
672672
'subnet e.g.: start=192.168.199.2,end=192.168.199.254 '
673673
'(repeat option to unset multiple allocation pools)')
674674
)
675+
parser.add_argument(
676+
'--gateway',
677+
action='store_true',
678+
help=_("Remove gateway IP from this subnet")
679+
)
675680
parser.add_argument(
676681
'--dns-nameserver',
677682
metavar='<dns-nameserver>',
@@ -715,6 +720,8 @@ def take_action(self, parsed_args):
715720
obj = client.find_subnet(parsed_args.subnet, ignore_missing=False)
716721

717722
attrs = {}
723+
if parsed_args.gateway:
724+
attrs['gateway_ip'] = None
718725
if parsed_args.dns_nameservers:
719726
attrs['dns_nameservers'] = copy.deepcopy(obj.dns_nameservers)
720727
_update_arguments(attrs['dns_nameservers'],

openstackclient/tests/unit/network/v2/test_subnet.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,6 +1264,7 @@ def setUp(self):
12641264
'end': '8.8.8.170'}],
12651265
'service_types': ['network:router_gateway',
12661266
'network:floatingip_agent_gateway'],
1267+
'gateway_ip': 'fe80::a00a:0:c0de:0:1',
12671268
'tags': ['green', 'red'], })
12681269
self.network.find_subnet = mock.Mock(return_value=self._testsubnet)
12691270
self.network.update_subnet = mock.Mock(return_value=None)
@@ -1277,6 +1278,7 @@ def test_unset_subnet_params(self):
12771278
'--host-route', 'destination=10.30.30.30/24,gateway=10.30.30.1',
12781279
'--allocation-pool', 'start=8.8.8.100,end=8.8.8.150',
12791280
'--service-type', 'network:router_gateway',
1281+
'--gateway',
12801282
self._testsubnet.name,
12811283
]
12821284
verifylist = [
@@ -1286,6 +1288,7 @@ def test_unset_subnet_params(self):
12861288
('allocation_pools', [{
12871289
'start': '8.8.8.100', 'end': '8.8.8.150'}]),
12881290
('service_types', ['network:router_gateway']),
1291+
('gateway', True),
12891292
]
12901293

12911294
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -1297,6 +1300,7 @@ def test_unset_subnet_params(self):
12971300
"destination": "10.20.20.0/24", "nexthop": "10.20.20.1"}],
12981301
'allocation_pools': [{'start': '8.8.8.160', 'end': '8.8.8.170'}],
12991302
'service_types': ['network:floatingip_agent_gateway'],
1303+
'gateway_ip': None,
13001304
}
13011305
self.network.update_subnet.assert_called_once_with(
13021306
self._testsubnet, **attrs)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
fixes:
3+
- |
4+
Add missing ``openstack subnet unset --gateway <subnet-id>``.

0 commit comments

Comments
 (0)