Skip to content

Commit 3bf5e62

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Don't allow deletion of the router ports without IP addresses" into stable/yoga
2 parents 47d98c6 + 4f043fb commit 3bf5e62

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

neutron/db/l3_db.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,15 +1730,6 @@ def prevent_l3_port_deletion(self, context, port_id, port=None):
17301730
return
17311731
if port['device_owner'] not in self.router_device_owners:
17321732
return
1733-
# Raise port in use only if the port has IP addresses
1734-
# Otherwise it's a stale port that can be removed
1735-
fixed_ips = port['fixed_ips']
1736-
if not fixed_ips:
1737-
LOG.debug("Port %(port_id)s has owner %(port_owner)s, but "
1738-
"no IP address, so it can be deleted",
1739-
{'port_id': port['id'],
1740-
'port_owner': port['device_owner']})
1741-
return
17421733
# NOTE(kevinbenton): we also check to make sure that the
17431734
# router still exists. It's possible for HA router interfaces
17441735
# to remain after the router is deleted if they encounter an

neutron/tests/unit/db/test_l3_db.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,10 @@ def test_prevent_l3_port_no_fixed_ips(self, gp):
290290
# without fixed IPs is allowed
291291
gp.return_value.get_port.return_value = {
292292
'device_owner': n_const.DEVICE_OWNER_ROUTER_INTF, 'fixed_ips': [],
293-
'id': 'f'
293+
'device_id': '44', 'id': 'f',
294294
}
295-
self.db.prevent_l3_port_deletion(None, None)
295+
with testtools.ExpectedException(n_exc.ServicePortInUse):
296+
self.db.prevent_l3_port_deletion(mock.Mock(), None)
296297

297298
@mock.patch.object(directory, 'get_plugin')
298299
def test_prevent_l3_port_no_router(self, gp):

0 commit comments

Comments
 (0)