Merge "Make prevent_l3_port_deletion handle missing port" into stable/juno

This commit is contained in:
Jenkins 2015-02-06 12:23:30 +00:00 committed by Gerrit Code Review
commit db0d47deca
3 changed files with 11 additions and 4 deletions

View File

@ -881,7 +881,11 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase):
to /ports, but rather via other API calls that perform the proper
deletion checks.
"""
port_db = self._core_plugin._get_port(context, port_id)
try:
port_db = self._core_plugin._get_port(context, port_id)
except n_exc.PortNotFound:
# non-existent ports don't need to be protected from deletion
return
if port_db['device_owner'] in self.router_device_owners:
# Raise port in use only if the port has IP addresses
# Otherwise it's a stale port that can be removed

View File

@ -985,8 +985,6 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
session.begin(subtransactions=True)):
port_db, binding = db.get_locked_port_and_binding(session, id)
if not port_db:
# the port existed when l3plugin.prevent_l3_port_deletion
# was called but now is already gone
LOG.debug(_("The port '%s' was deleted"), id)
return
port = self._make_port_dict(port_db)

View File

@ -2154,7 +2154,12 @@ class L3NatDBIntTestCase(L3BaseForIntTests, L3NatTestCaseBase):
class L3NatDBSepTestCase(L3BaseForSepTests, L3NatTestCaseBase):
"""Unit tests for a separate L3 routing service plugin."""
pass
def test_port_deletion_prevention_handles_missing_port(self):
pl = manager.NeutronManager.get_service_plugins().get(
service_constants.L3_ROUTER_NAT)
self.assertIsNone(
pl.prevent_l3_port_deletion(context.get_admin_context(), 'fakeid')
)
class L3NatDBIntTestCaseXML(L3NatDBIntTestCase):