]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Introduced transition RPC exception types
authorIhar Hrachyshka <ihrachys@redhat.com>
Fri, 30 May 2014 13:26:45 +0000 (15:26 +0200)
committerIhar Hrachyshka <ihrachys@redhat.com>
Mon, 9 Jun 2014 14:42:47 +0000 (16:42 +0200)
These exception types will ease transition from oslo-rpc to
oslo.messaging.

blueprint oslo-messaging

Change-Id: I48d214d676e863d7a60d78c49d2fa917d47c07d9

neutron/agent/dhcp_agent.py
neutron/agent/l3_agent.py
neutron/common/rpc_compat.py
neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py
neutron/plugins/mlnx/agent/eswitch_neutron_agent.py
neutron/tests/unit/linuxbridge/test_lb_neutron_agent.py
neutron/tests/unit/test_dhcp_agent.py

index eeb55fda8cc46f94524eb6eeb9dbf09abdf27f49..bfdbca371b10c9ce0bbe6cb3a58d560f0a3e89be 100644 (file)
@@ -37,7 +37,6 @@ from neutron import manager
 from neutron.openstack.common import importutils
 from neutron.openstack.common import log as logging
 from neutron.openstack.common import loopingcall
-from neutron.openstack.common.rpc import common
 from neutron.openstack.common import service
 from neutron import service as neutron_service
 
@@ -136,7 +135,7 @@ class DhcpAgent(manager.Manager):
                         % {'net_id': network.id, 'action': action})
         except Exception as e:
             self.schedule_resync(e)
-            if (isinstance(e, common.RemoteError)
+            if (isinstance(e, rpc_compat.RemoteError)
                 and e.exc_type == 'NetworkNotFound'
                 or isinstance(e, exceptions.NetworkNotFound)):
                 LOG.warning(_("Network %s has been deleted."), network.id)
index 0f2ae2bcea2423e2375558b12620aab9ff61a940..778b947cce9fc8bfc99f373c9a89600e4e7ba2e5 100644 (file)
@@ -37,7 +37,6 @@ from neutron.openstack.common import log as logging
 from neutron.openstack.common import loopingcall
 from neutron.openstack.common import periodic_task
 from neutron.openstack.common import processutils
-from neutron.openstack.common.rpc import common as rpc_common
 from neutron.openstack.common import service
 from neutron import service as neutron_service
 from neutron.services.firewall.agents.l3reference import firewall_l3_agent
@@ -76,9 +75,9 @@ class L3PluginApi(rpc_compat.RpcProxy):
     def get_external_network_id(self, context):
         """Make a remote process call to retrieve the external network id.
 
-        @raise common.RemoteError: with TooManyExternalNetworks
-                                   as exc_type if there are
-                                   more than one external network
+        @raise rpc_compat.RemoteError: with TooManyExternalNetworks
+                                       as exc_type if there are
+                                       more than one external network
         """
         return self.call(context,
                          self.make_msg('get_external_network_id',
@@ -324,7 +323,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
             self.target_ex_net_id = self.plugin_rpc.get_external_network_id(
                 self.context)
             return self.target_ex_net_id
-        except rpc_common.RemoteError as e:
+        except rpc_compat.RemoteError as e:
             with excutils.save_and_reraise_exception() as ctx:
                 if e.exc_type == 'TooManyExternalNetworks':
                     ctx.reraise = False
@@ -857,7 +856,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
             self._process_routers(routers, all_routers=True)
             self.fullsync = False
             LOG.debug(_("_sync_routers_task successfully completed"))
-        except rpc_common.RPCException:
+        except rpc_compat.RPCException:
             LOG.exception(_("Failed synchronizing routers due to RPC error"))
             self.fullsync = True
             return
index 0e0eb11705f2ab1e9e4edec56426c02c17b4732f..6854f572841cce361777540e960ae6e94f131978 100644 (file)
@@ -13,6 +13,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+from neutron.openstack.common.rpc import common as rpc_common
 from neutron.openstack.common.rpc import proxy
 
 
@@ -23,3 +24,9 @@ class RpcProxy(proxy.RpcProxy):
     emulate RpcProxy class behaviour using oslo.messaging API once the
     migration is applied.
     '''
+
+
+# exceptions
+RPCException = rpc_common.RPCException
+RemoteError = rpc_common.RemoteError
+MessagingTimeout = rpc_common.Timeout
index 30008822aca8b64470d95f96a35a28522c986259..5e5c1524362c61168368745d26552985d3b461be 100755 (executable)
@@ -37,12 +37,12 @@ from neutron.agent import securitygroups_rpc as sg_rpc
 from neutron.common import config as logging_config
 from neutron.common import constants
 from neutron.common import exceptions
+from neutron.common import rpc_compat
 from neutron.common import topics
 from neutron.common import utils as q_utils
 from neutron import context
 from neutron.openstack.common import log as logging
 from neutron.openstack.common import loopingcall
-from neutron.openstack.common.rpc import common as rpc_common
 from neutron.openstack.common.rpc import dispatcher
 from neutron.plugins.common import constants as p_const
 from neutron.plugins.linuxbridge.common import config  # noqa
@@ -725,7 +725,7 @@ class LinuxBridgeRpcCallbacks(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
                                                          tap_device_name,
                                                          self.agent.agent_id,
                                                          cfg.CONF.host)
-        except rpc_common.Timeout:
+        except rpc_compat.MessagingTimeout:
             LOG.error(_("RPC timeout while updating port %s"), port['id'])
 
     def fdb_add(self, context, fdb_entries):
index 12915331eda6050160183a874bb9f02a5c10e54c..35bc015f07eda3270ea7989d9a5cc840ece024a7 100644 (file)
@@ -27,12 +27,12 @@ from neutron.agent import rpc as agent_rpc
 from neutron.agent import securitygroups_rpc as sg_rpc
 from neutron.common import config as logging_config
 from neutron.common import constants as q_constants
+from neutron.common import rpc_compat
 from neutron.common import topics
 from neutron.common import utils as q_utils
 from neutron import context
 from neutron.openstack.common import log as logging
 from neutron.openstack.common import loopingcall
-from neutron.openstack.common.rpc import common as rpc_common
 from neutron.openstack.common.rpc import dispatcher
 from neutron.plugins.common import constants as p_const
 from neutron.plugins.mlnx.agent import utils
@@ -202,7 +202,7 @@ class MlnxEswitchRpcCallbacks(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
                         port['mac_address'],
                         self.agent.agent_id,
                         cfg.CONF.host)
-            except rpc_common.Timeout:
+            except rpc_compat.MessagingTimeout:
                 LOG.error(_("RPC timeout while updating port %s"), port['id'])
         else:
             LOG.debug(_("No port %s defined on agent."), port['id'])
index c367710f8247f21f585268d9a1c349961422fa28..34671424ad0cd96f7ef35a9fab5fc66702fa4baf 100644 (file)
@@ -25,7 +25,7 @@ from neutron.agent.linux import ip_lib
 from neutron.agent.linux import utils
 from neutron.common import constants
 from neutron.common import exceptions
-from neutron.openstack.common.rpc import common as rpc_common
+from neutron.common import rpc_compat
 from neutron.plugins.common import constants as p_const
 from neutron.plugins.linuxbridge.agent import linuxbridge_neutron_agent
 from neutron.plugins.linuxbridge.common import constants as lconst
@@ -983,14 +983,15 @@ class TestLinuxBridgeRpcCallbacks(base.BaseTestCase):
             port = {"admin_state_up": True,
                     "id": "1234-5678",
                     "network_id": "123-123"}
-            plugin_rpc.update_device_up.side_effect = rpc_common.Timeout
+            timeout_class = rpc_compat.MessagingTimeout
+            plugin_rpc.update_device_up.side_effect = timeout_class
             self.lb_rpc.port_update(mock.Mock(), port=port)
             self.assertTrue(plugin_rpc.update_device_up.called)
             self.assertEqual(log.call_count, 1)
 
             log.reset_mock()
             port["admin_state_up"] = False
-            plugin_rpc.update_device_down.side_effect = rpc_common.Timeout
+            plugin_rpc.update_device_down.side_effect = timeout_class
             self.lb_rpc.port_update(mock.Mock(), port=port)
             self.assertTrue(plugin_rpc.update_device_down.called)
             self.assertEqual(log.call_count, 1)
index 1401fd853d9099df83f54fa34a43deff6c2765e6..ae99dac6cbb6c258c960eb6385fd0d1b6e907f6b 100644 (file)
@@ -30,7 +30,7 @@ from neutron.agent.linux import dhcp
 from neutron.agent.linux import interface
 from neutron.common import constants as const
 from neutron.common import exceptions
-from neutron.openstack.common.rpc import common
+from neutron.common import rpc_compat
 from neutron.tests import base
 
 
@@ -227,7 +227,7 @@ class TestDhcpAgent(base.BaseTestCase):
 
     def test_call_driver_remote_error_net_not_found(self):
         self._test_call_driver_failure(
-            exc=common.RemoteError(exc_type='NetworkNotFound'),
+            exc=rpc_compat.RemoteError(exc_type='NetworkNotFound'),
             trace_level='warning')
 
     def test_call_driver_network_not_found(self):