]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Prevent exception with VIP deletion
authorGary Kotton <gkotton@redhat.com>
Sun, 3 Mar 2013 14:47:31 +0000 (14:47 +0000)
committerGary Kotton <gkotton@redhat.com>
Sun, 3 Mar 2013 16:08:50 +0000 (16:08 +0000)
Fixes bug 1137697

Change-Id: I6de55c674da1202eb9c1e2e11eda2e6de554750c

quantum/plugins/services/agent_loadbalancer/plugin.py

index 3b7b48ec774a6ce5f5166a2bf8fa366116044b03..0a09255dd6a6db63c740c63026322a0768301eff 100644 (file)
@@ -123,10 +123,15 @@ class LoadBalancerCallbacks(object):
         if not port_id:
             return
 
-        port = self.plugin._core_plugin.get_port(
-            context,
-            port_id
-        )
+        try:
+            port = self.plugin._core_plugin.get_port(
+                context,
+                port_id
+            )
+        except q_exc.PortNotFound:
+            msg = _('Unable to find port %s to plug.')
+            LOG.debug(msg, port_id)
+            return
 
         port['admin_state_up'] = True
         port['device_owner'] = 'quantum:' + constants.LOADBALANCER
@@ -142,10 +147,16 @@ class LoadBalancerCallbacks(object):
         if not port_id:
             return
 
-        port = self.plugin._core_plugin.get_port(
-            context,
-            port_id
-        )
+        try:
+            port = self.plugin._core_plugin.get_port(
+                context,
+                port_id
+            )
+        except q_exc.PortNotFound:
+            msg = _('Unable to find port %s to unplug.  This can occur when '
+                    'the Vip has been deleted first.')
+            LOG.debug(msg, port_id)
+            return
 
         port['admin_state_up'] = False
         port['device_owner'] = ''