Merge "Remove neutron.common.rpc.RemoteError"

This commit is contained in:
Jenkins 2014-11-14 15:07:14 +00:00 committed by Gerrit Code Review
commit af203be75f
9 changed files with 16 additions and 19 deletions

View File

@ -22,6 +22,7 @@ eventlet.monkey_patch()
import netaddr import netaddr
from oslo.config import cfg from oslo.config import cfg
from oslo import messaging
from neutron.agent.common import config from neutron.agent.common import config
from neutron.agent.linux import dhcp from neutron.agent.linux import dhcp
@ -138,7 +139,7 @@ class DhcpAgent(manager.Manager):
% {'net_id': network.id, 'action': action}) % {'net_id': network.id, 'action': action})
except Exception as e: except Exception as e:
self.schedule_resync(e, network.id) self.schedule_resync(e, network.id)
if (isinstance(e, n_rpc.RemoteError) if (isinstance(e, messaging.RemoteError)
and e.exc_type == 'NetworkNotFound' and e.exc_type == 'NetworkNotFound'
or isinstance(e, exceptions.NetworkNotFound)): or isinstance(e, exceptions.NetworkNotFound)):
LOG.warning(_("Network %s has been deleted."), network.id) LOG.warning(_("Network %s has been deleted."), network.id)

View File

@ -108,7 +108,7 @@ class L3PluginApi(n_rpc.RpcProxy):
def get_external_network_id(self, context): def get_external_network_id(self, context):
"""Make a remote process call to retrieve the external network id. """Make a remote process call to retrieve the external network id.
@raise n_rpc.RemoteError: with TooManyExternalNetworks as @raise messaging.RemoteError: with TooManyExternalNetworks as
exc_type if there are more than one exc_type if there are more than one
external network external network
""" """
@ -534,7 +534,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback,
try: try:
self.neutron_service_plugins = ( self.neutron_service_plugins = (
self.plugin_rpc.get_service_plugin_list(self.context)) 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: with excutils.save_and_reraise_exception() as ctx:
ctx.reraise = False ctx.reraise = False
LOG.warning(_LW('l3-agent cannot check service plugins ' 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.target_ex_net_id = self.plugin_rpc.get_external_network_id(
self.context) self.context)
return self.target_ex_net_id 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: with excutils.save_and_reraise_exception() as ctx:
if e.exc_type == 'TooManyExternalNetworks': if e.exc_type == 'TooManyExternalNetworks':
ctx.reraise = False ctx.reraise = False

View File

@ -275,5 +275,4 @@ def create_connection(new=True):
# exceptions # exceptions
RemoteError = messaging.RemoteError
MessagingTimeout = messaging.MessagingTimeout MessagingTimeout = messaging.MessagingTimeout

View File

@ -18,6 +18,7 @@ import time
from oslo.config import cfg from oslo.config import cfg
from oslo.db import exception as db_exc from oslo.db import exception as db_exc
from oslo import messaging
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy import func from sqlalchemy import func
from sqlalchemy import orm from sqlalchemy import orm
@ -26,7 +27,6 @@ from sqlalchemy.orm import joinedload
from sqlalchemy import sql from sqlalchemy import sql
from neutron.common import constants from neutron.common import constants
from neutron.common import rpc as n_rpc
from neutron.common import utils as n_utils from neutron.common import utils as n_utils
from neutron import context as n_ctx from neutron import context as n_ctx
from neutron.db import agents_db from neutron.db import agents_db
@ -135,7 +135,7 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
try: try:
self.reschedule_router(context, binding.router_id) self.reschedule_router(context, binding.router_id)
except (l3agentscheduler.RouterReschedulingFailed, except (l3agentscheduler.RouterReschedulingFailed,
n_rpc.RemoteError): messaging.RemoteError):
# Catch individual router rescheduling errors here # Catch individual router rescheduling errors here
# so one broken one doesn't stop the iteration. # so one broken one doesn't stop the iteration.
LOG.exception(_LE("Failed to reschedule router %s"), LOG.exception(_LE("Failed to reschedule router %s"),

View File

@ -18,7 +18,6 @@ from oslo import messaging
from neutron.api.rpc.handlers import dvr_rpc from neutron.api.rpc.handlers import dvr_rpc
from neutron.common import constants as n_const 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.common import utils as n_utils
from neutron.openstack.common import excutils from neutron.openstack.common import excutils
from neutron.openstack.common.gettextutils import _LE, _LW, _LI from neutron.openstack.common.gettextutils import _LE, _LW, _LI
@ -151,7 +150,7 @@ class OVSDVRNeutronAgent(dvr_rpc.DVRAgentRpcApiMixin):
def get_dvr_mac_address(self): def get_dvr_mac_address(self):
try: try:
self.get_dvr_mac_address_with_retry() 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 ' LOG.warning(_LW('L2 agent could not get DVR MAC address at '
'startup due to RPC error. It happens when the ' 'startup due to RPC error. It happens when the '
'server does not support this RPC API. Detailed ' 'server does not support this RPC API. Detailed '

View File

@ -20,6 +20,7 @@ import datetime
import mock import mock
from oslo.config import cfg from oslo.config import cfg
from oslo.db import exception as db_exc from oslo.db import exception as db_exc
from oslo import messaging
from webob import exc from webob import exc
from neutron.api import extensions 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.rpc.handlers import l3_rpc
from neutron.api.v2 import attributes from neutron.api.v2 import attributes
from neutron.common import constants from neutron.common import constants
from neutron.common import rpc as n_rpc
from neutron import context from neutron import context
from neutron.db import agents_db from neutron.db import agents_db
from neutron.db import l3_agentschedulers_db from neutron.db import l3_agentschedulers_db
@ -663,7 +663,7 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
mock.patch.object( mock.patch.object(
plugin, 'reschedule_router', plugin, 'reschedule_router',
side_effect=[ side_effect=[
db_exc.DBError(), n_rpc.RemoteError(), db_exc.DBError(), messaging.RemoteError(),
l3agentscheduler.RouterReschedulingFailed(router_id='f', l3agentscheduler.RouterReschedulingFailed(router_id='f',
agent_id='f'), agent_id='f'),
ValueError('this raises') ValueError('this raises')

View File

@ -26,7 +26,6 @@ from neutron.agent.linux import ip_lib
from neutron.agent.linux import ovs_lib from neutron.agent.linux import ovs_lib
from neutron.agent.linux import utils from neutron.agent.linux import utils
from neutron.common import constants as n_const from neutron.common import constants as n_const
from neutron.common import rpc as n_rpc
from neutron.openstack.common import log from neutron.openstack.common import log
from neutron.plugins.common import constants as p_const from neutron.plugins.common import constants as p_const
from neutron.plugins.openvswitch.agent import ovs_neutron_agent from neutron.plugins.openvswitch.agent import ovs_neutron_agent
@ -533,7 +532,7 @@ class TestOvsNeutronAgent(base.BaseTestCase):
with contextlib.nested( with contextlib.nested(
mock.patch.object(self.agent.dvr_agent.plugin_rpc, mock.patch.object(self.agent.dvr_agent.plugin_rpc,
'get_dvr_mac_address_by_host', 'get_dvr_mac_address_by_host',
side_effect=n_rpc.RemoteError), side_effect=messaging.RemoteError),
mock.patch.object(self.agent.dvr_agent.int_br, mock.patch.object(self.agent.dvr_agent.int_br,
'add_flow')) as (gd_mac, add_int_flow_fn): 'add_flow')) as (gd_mac, add_int_flow_fn):

View File

@ -20,6 +20,7 @@ import uuid
import eventlet import eventlet
import mock import mock
from oslo.config import cfg from oslo.config import cfg
from oslo import messaging
import testtools import testtools
from neutron.agent.common import config 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 config as common_config
from neutron.common import constants as const from neutron.common import constants as const
from neutron.common import exceptions from neutron.common import exceptions
from neutron.common import rpc as n_rpc
from neutron.tests import base from neutron.tests import base
@ -280,7 +280,7 @@ class TestDhcpAgent(base.BaseTestCase):
def test_call_driver_remote_error_net_not_found(self): def test_call_driver_remote_error_net_not_found(self):
self._test_call_driver_failure( self._test_call_driver_failure(
exc=n_rpc.RemoteError(exc_type='NetworkNotFound'), exc=messaging.RemoteError(exc_type='NetworkNotFound'),
trace_level='warning') trace_level='warning')
def test_call_driver_network_not_found(self): def test_call_driver_network_not_found(self):

View File

@ -30,7 +30,6 @@ from neutron.agent.linux import interface
from neutron.common import config as base_config from neutron.common import config as base_config
from neutron.common import constants as l3_constants from neutron.common import constants as l3_constants
from neutron.common import exceptions as n_exc 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 processutils
from neutron.openstack.common import uuidutils from neutron.openstack.common import uuidutils
from neutron.plugins.common import constants as p_const 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) self.assertTrue(self.plugin_api.get_service_plugin_list.called)
def test_get_service_plugin_list_failed(self): 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 self.plugin_api.get_service_plugin_list.side_effect = raise_rpc
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf) agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
self.assertIsNone(agent.neutron_service_plugins) self.assertIsNone(agent.neutron_service_plugins)