diff --git a/neutron/agent/dhcp_agent.py b/neutron/agent/dhcp_agent.py index 616a36383b..aa1c6fbf5e 100644 --- a/neutron/agent/dhcp_agent.py +++ b/neutron/agent/dhcp_agent.py @@ -22,6 +22,7 @@ eventlet.monkey_patch() import netaddr from oslo.config import cfg +from oslo import messaging from neutron.agent.common import config from neutron.agent.linux import dhcp @@ -138,7 +139,7 @@ class DhcpAgent(manager.Manager): % {'net_id': network.id, 'action': action}) except Exception as e: self.schedule_resync(e, network.id) - if (isinstance(e, n_rpc.RemoteError) + if (isinstance(e, messaging.RemoteError) and e.exc_type == 'NetworkNotFound' or isinstance(e, exceptions.NetworkNotFound)): LOG.warning(_("Network %s has been deleted."), network.id) diff --git a/neutron/agent/l3_agent.py b/neutron/agent/l3_agent.py index d0deb1fdc8..b166aa5b0c 100644 --- a/neutron/agent/l3_agent.py +++ b/neutron/agent/l3_agent.py @@ -108,9 +108,9 @@ class L3PluginApi(n_rpc.RpcProxy): def get_external_network_id(self, context): """Make a remote process call to retrieve the external network id. - @raise n_rpc.RemoteError: with TooManyExternalNetworks as - exc_type if there are more than one - external network + @raise messaging.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', @@ -534,7 +534,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, try: self.neutron_service_plugins = ( self.plugin_rpc.get_service_plugin_list(self.context)) - except n_rpc.RemoteError as e: + except messaging.RemoteError as e: with excutils.save_and_reraise_exception() as ctx: ctx.reraise = False LOG.warning(_LW('l3-agent cannot check service plugins ' @@ -750,7 +750,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, self.target_ex_net_id = self.plugin_rpc.get_external_network_id( self.context) return self.target_ex_net_id - except n_rpc.RemoteError as e: + except messaging.RemoteError as e: with excutils.save_and_reraise_exception() as ctx: if e.exc_type == 'TooManyExternalNetworks': ctx.reraise = False diff --git a/neutron/common/rpc.py b/neutron/common/rpc.py index eaa06f6957..9928aa28e7 100644 --- a/neutron/common/rpc.py +++ b/neutron/common/rpc.py @@ -275,5 +275,4 @@ def create_connection(new=True): # exceptions -RemoteError = messaging.RemoteError MessagingTimeout = messaging.MessagingTimeout diff --git a/neutron/db/l3_agentschedulers_db.py b/neutron/db/l3_agentschedulers_db.py index bef3119765..dd3d7ee8af 100644 --- a/neutron/db/l3_agentschedulers_db.py +++ b/neutron/db/l3_agentschedulers_db.py @@ -18,6 +18,7 @@ import time from oslo.config import cfg from oslo.db import exception as db_exc +from oslo import messaging import sqlalchemy as sa from sqlalchemy import func from sqlalchemy import orm @@ -26,7 +27,6 @@ from sqlalchemy.orm import joinedload from sqlalchemy import sql from neutron.common import constants -from neutron.common import rpc as n_rpc from neutron.common import utils as n_utils from neutron import context as n_ctx from neutron.db import agents_db @@ -135,7 +135,7 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase, try: self.reschedule_router(context, binding.router_id) except (l3agentscheduler.RouterReschedulingFailed, - n_rpc.RemoteError): + messaging.RemoteError): # Catch individual router rescheduling errors here # so one broken one doesn't stop the iteration. LOG.exception(_LE("Failed to reschedule router %s"), diff --git a/neutron/plugins/openvswitch/agent/ovs_dvr_neutron_agent.py b/neutron/plugins/openvswitch/agent/ovs_dvr_neutron_agent.py index 624ae2368c..90f5f64e4e 100644 --- a/neutron/plugins/openvswitch/agent/ovs_dvr_neutron_agent.py +++ b/neutron/plugins/openvswitch/agent/ovs_dvr_neutron_agent.py @@ -18,7 +18,6 @@ from oslo import messaging from neutron.api.rpc.handlers import dvr_rpc from neutron.common import constants as n_const -from neutron.common import rpc as n_rpc from neutron.common import utils as n_utils from neutron.openstack.common import excutils from neutron.openstack.common.gettextutils import _LE, _LW, _LI @@ -151,7 +150,7 @@ class OVSDVRNeutronAgent(dvr_rpc.DVRAgentRpcApiMixin): def get_dvr_mac_address(self): try: self.get_dvr_mac_address_with_retry() - except n_rpc.RemoteError as e: + except messaging.RemoteError as e: LOG.warning(_LW('L2 agent could not get DVR MAC address at ' 'startup due to RPC error. It happens when the ' 'server does not support this RPC API. Detailed ' diff --git a/neutron/tests/unit/openvswitch/test_agent_scheduler.py b/neutron/tests/unit/openvswitch/test_agent_scheduler.py index b492fa38ae..ccd046864f 100644 --- a/neutron/tests/unit/openvswitch/test_agent_scheduler.py +++ b/neutron/tests/unit/openvswitch/test_agent_scheduler.py @@ -20,6 +20,7 @@ import datetime import mock from oslo.config import cfg from oslo.db import exception as db_exc +from oslo import messaging from webob import exc from neutron.api import extensions @@ -28,7 +29,6 @@ from neutron.api.rpc.handlers import dhcp_rpc from neutron.api.rpc.handlers import l3_rpc from neutron.api.v2 import attributes from neutron.common import constants -from neutron.common import rpc as n_rpc from neutron import context from neutron.db import agents_db from neutron.db import l3_agentschedulers_db @@ -663,7 +663,7 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase): mock.patch.object( plugin, 'reschedule_router', side_effect=[ - db_exc.DBError(), n_rpc.RemoteError(), + db_exc.DBError(), messaging.RemoteError(), l3agentscheduler.RouterReschedulingFailed(router_id='f', agent_id='f'), ValueError('this raises') diff --git a/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py b/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py index c242c38eaa..0435b59f6a 100644 --- a/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py +++ b/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py @@ -26,7 +26,6 @@ from neutron.agent.linux import ip_lib from neutron.agent.linux import ovs_lib from neutron.agent.linux import utils from neutron.common import constants as n_const -from neutron.common import rpc as n_rpc from neutron.openstack.common import log from neutron.plugins.common import constants as p_const from neutron.plugins.openvswitch.agent import ovs_neutron_agent @@ -533,7 +532,7 @@ class TestOvsNeutronAgent(base.BaseTestCase): with contextlib.nested( mock.patch.object(self.agent.dvr_agent.plugin_rpc, 'get_dvr_mac_address_by_host', - side_effect=n_rpc.RemoteError), + side_effect=messaging.RemoteError), mock.patch.object(self.agent.dvr_agent.int_br, 'add_flow')) as (gd_mac, add_int_flow_fn): diff --git a/neutron/tests/unit/test_dhcp_agent.py b/neutron/tests/unit/test_dhcp_agent.py index 00b9208adf..45c606cfb5 100644 --- a/neutron/tests/unit/test_dhcp_agent.py +++ b/neutron/tests/unit/test_dhcp_agent.py @@ -20,6 +20,7 @@ import uuid import eventlet import mock from oslo.config import cfg +from oslo import messaging import testtools from neutron.agent.common import config @@ -29,7 +30,6 @@ from neutron.agent.linux import interface from neutron.common import config as common_config from neutron.common import constants as const from neutron.common import exceptions -from neutron.common import rpc as n_rpc from neutron.tests import base @@ -280,7 +280,7 @@ class TestDhcpAgent(base.BaseTestCase): def test_call_driver_remote_error_net_not_found(self): self._test_call_driver_failure( - exc=n_rpc.RemoteError(exc_type='NetworkNotFound'), + exc=messaging.RemoteError(exc_type='NetworkNotFound'), trace_level='warning') def test_call_driver_network_not_found(self): diff --git a/neutron/tests/unit/test_l3_agent.py b/neutron/tests/unit/test_l3_agent.py index fb717c216a..8bf861e3ec 100644 --- a/neutron/tests/unit/test_l3_agent.py +++ b/neutron/tests/unit/test_l3_agent.py @@ -30,7 +30,6 @@ from neutron.agent.linux import interface from neutron.common import config as base_config from neutron.common import constants as l3_constants from neutron.common import exceptions as n_exc -from neutron.common import rpc as n_rpc from neutron.openstack.common import processutils from neutron.openstack.common import uuidutils from neutron.plugins.common import constants as p_const @@ -2221,7 +2220,7 @@ vrrp_instance VR_1 { self.assertTrue(self.plugin_api.get_service_plugin_list.called) def test_get_service_plugin_list_failed(self): - raise_rpc = n_rpc.RemoteError() + raise_rpc = messaging.RemoteError() self.plugin_api.get_service_plugin_list.side_effect = raise_rpc agent = l3_agent.L3NATAgent(HOSTNAME, self.conf) self.assertIsNone(agent.neutron_service_plugins)