Skip to content

Commit 872b4b2

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Don't allow deletion of the router ports without IP addresses" into stable/zed
2 parents a655ccc + 1fe05c5 commit 872b4b2

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
@@ -1732,15 +1732,6 @@ def prevent_l3_port_deletion(self, context, port_id, port=None):
17321732
return
17331733
if port['device_owner'] not in self.router_device_owners:
17341734
return
1735-
# Raise port in use only if the port has IP addresses
1736-
# Otherwise it's a stale port that can be removed
1737-
fixed_ips = port['fixed_ips']
1738-
if not fixed_ips:
1739-
LOG.debug("Port %(port_id)s has owner %(port_owner)s, but "
1740-
"no IP address, so it can be deleted",
1741-
{'port_id': port['id'],
1742-
'port_owner': port['device_owner']})
1743-
return
17441735
# NOTE(kevinbenton): we also check to make sure that the
17451736
# router still exists. It's possible for HA router interfaces
17461737
# 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)