]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Extension moving tweaks, exceptions and extension path fix
authorDoug Wiegley <dougw@a10networks.com>
Mon, 2 Feb 2015 16:08:17 +0000 (10:08 -0600)
committerDoug Wiegley <dougw@a10networks.com>
Mon, 2 Feb 2015 16:29:35 +0000 (10:29 -0600)
- 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

neutron/api/extensions.py
neutron/common/exceptions.py
neutron/services/firewall/agents/l3reference/firewall_l3_agent.py
neutron/tests/unit/db/test_l3_dvr_db.py

index b1294e155ea201915e8027008370098e9617d528..b889c0a32311bb674dd719944fb3b312c1d97267 100644 (file)
@@ -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)
index 3aee9680cfb693b64542033eb4f988483f5d6b7a..310e67a344b5a5cac4e8e2f884db101dae9370e9 100644 (file)
@@ -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")
index 831fca6d31db34a10264f8337d586671dd9c591a..12248db667cce303acc701ecf37d582e248f10f0 100644 (file)
@@ -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']})
index b82923313c7f646cd064ba001120d6f1a43a58e8..7a6589c31aec8359bb27aa557b40c3a95e57de9b 100644 (file)
@@ -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')
                 ),