From: Doug Wiegley Date: Mon, 2 Feb 2015 16:08:17 +0000 (-0600) Subject: Extension moving tweaks, exceptions and extension path fix X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=c85c9e073b407f3fa9db48142718485adb382d1c;p=openstack-build%2Fneutron-build.git Extension moving tweaks, exceptions and extension path fix - Put a few shared *aas exceptions into neutron.common exceptions, pending them being unnecessary after L3 refactor. - Fix extension path creation, which dropped the extensions sub-module for service repos in one of the patch refactors. Change-Id: I2e9e27f72abf2e0ec359bce4a55f3698c0068159 Partially-Implements: blueprint services-split --- diff --git a/neutron/api/extensions.py b/neutron/api/extensions.py index b1294e155..b889c0a32 100644 --- a/neutron/api/extensions.py +++ b/neutron/api/extensions.py @@ -677,7 +677,11 @@ def get_extensions_path(): neutron_mods = repos.NeutronModules() for x in neutron_mods.installed_list(): - paths += neutron_mods.module(x).__path__ + try: + paths += neutron_mods.module(x).extensions.__path__ + except AttributeError: + # Occurs normally if module has no extensions sub-module + pass if cfg.CONF.api_extensions_path: paths.append(cfg.CONF.api_extensions_path) diff --git a/neutron/common/exceptions.py b/neutron/common/exceptions.py index 3aee9680c..310e67a34 100644 --- a/neutron/common/exceptions.py +++ b/neutron/common/exceptions.py @@ -360,3 +360,19 @@ class IpTablesApplyException(NeutronException): def __init__(self, message=None): self.message = message super(IpTablesApplyException, self).__init__() + + +# Shared *aas exceptions, pending them being refactored out of Neutron +# proper. + +class FirewallInternalDriverError(NeutronException): + """Fwaas exception for all driver errors. + + On any failure or exception in the driver, driver should log it and + raise this exception to the agent + """ + message = _("%(driver)s: Internal driver error.") + + +class RouterInUseByVPNService(InUse): + message = _("Router %(router_id)s is used by VPNService %(vpnservice_id)s") diff --git a/neutron/services/firewall/agents/l3reference/firewall_l3_agent.py b/neutron/services/firewall/agents/l3reference/firewall_l3_agent.py index 831fca6d3..12248db66 100644 --- a/neutron/services/firewall/agents/l3reference/firewall_l3_agent.py +++ b/neutron/services/firewall/agents/l3reference/firewall_l3_agent.py @@ -18,9 +18,9 @@ from oslo.utils import importutils from neutron.agent.common import config from neutron.agent.linux import ip_lib +from neutron.common import exceptions as nexception from neutron.common import topics from neutron import context -from neutron.extensions import firewall as fw_ext from neutron.i18n import _LE from neutron.openstack.common import log as logging from neutron.plugins.common import constants @@ -142,7 +142,7 @@ class FWaaSL3AgentRpcCallback(api.FWaaSAgentRpcCallbackMixin): status = constants.ACTIVE else: status = constants.DOWN - except fw_ext.FirewallInternalDriverError: + except nexception.FirewallInternalDriverError: LOG.error(_LE("Firewall Driver Error for %(func_name)s " "for fw: %(fwid)s"), {'func_name': func_name, 'fwid': fw['id']}) @@ -177,7 +177,7 @@ class FWaaSL3AgentRpcCallback(api.FWaaSAgentRpcCallbackMixin): self.fwplugin_rpc.firewall_deleted( ctx, fw['id']) - except fw_ext.FirewallInternalDriverError: + except nexception.FirewallInternalDriverError: LOG.error(_LE("Firewall Driver Error on fw state %(fwmsg)s " "for fw: %(fwid)s"), {'fwmsg': fw['status'], 'fwid': fw['id']}) @@ -196,7 +196,7 @@ class FWaaSL3AgentRpcCallback(api.FWaaSAgentRpcCallbackMixin): status = constants.ACTIVE else: status = constants.DOWN - except fw_ext.FirewallInternalDriverError: + except nexception.FirewallInternalDriverError: LOG.error(_LE("Firewall Driver Error on fw state %(fwmsg)s " "for fw: %(fwid)s"), {'fwmsg': fw['status'], 'fwid': fw['id']}) diff --git a/neutron/tests/unit/db/test_l3_dvr_db.py b/neutron/tests/unit/db/test_l3_dvr_db.py index b82923313..7a6589c31 100644 --- a/neutron/tests/unit/db/test_l3_dvr_db.py +++ b/neutron/tests/unit/db/test_l3_dvr_db.py @@ -17,10 +17,10 @@ import contextlib import mock from neutron.common import constants as l3_const +from neutron.common import exceptions as nexception from neutron import context from neutron.db import l3_dvr_db from neutron.extensions import l3 -from neutron.extensions import vpnaas from neutron import manager from neutron.openstack.common import uuidutils from neutron.tests.unit import testlib_api @@ -358,7 +358,7 @@ class L3DvrTestCase(testlib_api.SqlTestCase): return router_db, fw_mock, vpn_mock if not no_vpn and test_side_effect_vpn: self.assertRaises( - vpnaas.RouterInUseByVPNService, + nexception.RouterInUseByVPNService, self.mixin._validate_router_migration, self.ctx, router_db, @@ -378,7 +378,7 @@ class L3DvrTestCase(testlib_api.SqlTestCase): router_db, mock_firewall, mock_vpnaas = ( self._router_migration_with_services_setup( test_side_effect_vpn=( - vpnaas.RouterInUseByVPNService( + nexception.RouterInUseByVPNService( router_id='fake_id', vpnservice_id='fake_vpnaas_id') ),