diff --git a/neutron/manager.py b/neutron/manager.py index b3829fa9c03..8cd25ad6af1 100644 --- a/neutron/manager.py +++ b/neutron/manager.py @@ -30,6 +30,8 @@ from stevedore import driver LOG = logging.getLogger(__name__) +CORE_PLUGINS_NAMESPACE = 'neutron.core_plugins' + class Manager(periodic_task.PeriodicTasks): @@ -111,7 +113,7 @@ class NeutronManager(object): # for performance metrics. plugin_provider = cfg.CONF.core_plugin LOG.info(_LI("Loading core plugin: %s"), plugin_provider) - self.plugin = self._get_plugin_instance('neutron.core_plugins', + self.plugin = self._get_plugin_instance(CORE_PLUGINS_NAMESPACE, plugin_provider) msg = validate_post_plugin_load() if msg: diff --git a/neutron/services/firewall/agents/l3reference/firewall_l3_agent.py b/neutron/services/firewall/agents/l3reference/firewall_l3_agent.py index b4b80c05e3a..831fca6d31d 100644 --- a/neutron/services/firewall/agents/l3reference/firewall_l3_agent.py +++ b/neutron/services/firewall/agents/l3reference/firewall_l3_agent.py @@ -25,6 +25,7 @@ from neutron.i18n import _LE from neutron.openstack.common import log as logging from neutron.plugins.common import constants from neutron.services.firewall.agents import firewall_agent_api as api +from neutron.services import provider_configuration as provconf LOG = logging.getLogger(__name__) @@ -55,7 +56,8 @@ class FWaaSL3AgentRpcCallback(api.FWaaSAgentRpcCallbackMixin): def __init__(self, conf): LOG.debug("Initializing firewall agent") self.conf = conf - fwaas_driver_class_path = cfg.CONF.fwaas.driver + fwaas_driver_class_path = provconf.get_provider_driver_class( + cfg.CONF.fwaas.driver) self.fwaas_enabled = cfg.CONF.fwaas.enabled # None means l3-agent has no information on the server diff --git a/neutron/services/firewall/fwaas_plugin.py b/neutron/services/firewall/fwaas_plugin.py deleted file mode 100644 index 31294586537..00000000000 --- a/neutron/services/firewall/fwaas_plugin.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2014 A10 Networks, Inc -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from neutron.i18n import _LE -from neutron.openstack.common import log as logging - -LOG = logging.getLogger(__name__) - -try: - from neutron_fwaas.services.firewall import fwaas_plugin -except Exception as e: - LOG.error(_LE("Firewall service plugin requires neutron-fwaas module")) - raise e - - -class FirewallPlugin(fwaas_plugin.FirewallPlugin): - pass diff --git a/neutron/services/loadbalancer/plugin.py b/neutron/services/loadbalancer/plugin.py deleted file mode 100644 index 831a6ffe3a8..00000000000 --- a/neutron/services/loadbalancer/plugin.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2014 A10 Networks, Inc -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from neutron.i18n import _LE -from neutron.openstack.common import log as logging - -LOG = logging.getLogger(__name__) - -try: - from neutron_lbaas.services.loadbalancer import plugin -except Exception as e: - LOG.error(_LE("Loadbalancer service plugin requires neutron-lbaas module")) - raise e - - -class LoadBalancerPlugin(plugin.LoadBalancerPlugin): - pass diff --git a/neutron/services/provider_configuration.py b/neutron/services/provider_configuration.py index b9dd8f626e2..841954b018e 100644 --- a/neutron/services/provider_configuration.py +++ b/neutron/services/provider_configuration.py @@ -14,13 +14,16 @@ # under the License. from oslo.config import cfg +import stevedore from neutron.common import exceptions as n_exc +from neutron.i18n import _LW from neutron.openstack.common import log as logging from neutron.plugins.common import constants LOG = logging.getLogger(__name__) +SERVICE_PROVIDERS = 'neutron.service_providers' serviceprovider_opts = [ cfg.MultiStrOpt('service_provider', default=[], @@ -37,6 +40,28 @@ def normalize_provider_name(name): return name.lower() +def get_provider_driver_class(driver, namespace=SERVICE_PROVIDERS): + """Return path to provider driver class + + In order to keep backward compatibility with configs < Kilo, we need to + translate driver class paths after advanced services split. This is done by + defining old class path as entry point in neutron package. + """ + try: + driver_manager = stevedore.driver.DriverManager( + namespace, driver).driver + except RuntimeError: + return driver + new_driver = "%s.%s" % (driver_manager.__module__, + driver_manager.__name__) + LOG.warning(_LW( + "The configured driver %(driver)s has been moved, automatically " + "using %(new_driver)s instead. Please update your config files, " + "as this automatic fixup will be removed in a future release."), + {'driver': driver, 'new_driver': new_driver}) + return new_driver + + def parse_service_provider_opt(): """Parse service definition opts and returns result.""" def validate_name(name): @@ -71,6 +96,7 @@ def parse_service_provider_opt(): 'allowed': constants.ALLOWED_SERVICES}) LOG.error(msg) raise n_exc.Invalid(msg) + driver = get_provider_driver_class(driver) res.append({'service_type': svc_type, 'name': name, 'driver': driver, diff --git a/neutron/services/vpn/plugin.py b/neutron/services/vpn/plugin.py deleted file mode 100644 index 17f34737b73..00000000000 --- a/neutron/services/vpn/plugin.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2014 A10 Networks, Inc -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from neutron.i18n import _LE -from neutron.openstack.common import log as logging - -LOG = logging.getLogger(__name__) - -try: - from neutron_vpnaas.services.vpn import plugin -except Exception as e: - LOG.error(_LE("VPN service plugin requires neutron-vpnaas module")) - raise e - - -class VPNDriverPlugin(plugin.VPNDriverPlugin): - pass diff --git a/neutron/tests/unit/services/firewall/test_plugin_shim.py b/neutron/tests/unit/services/firewall/test_plugin_shim.py deleted file mode 100644 index 8a1fa1ccdfb..00000000000 --- a/neutron/tests/unit/services/firewall/test_plugin_shim.py +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2012 OpenStack Foundation. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from neutron.tests import base - - -class TestPluginShim(base.BaseTestCase): - - def test_plugin_shim(self): - try: - from neutron.services.firewall import fwaas_plugin as plugin - plugin.FirewallPlugin() - except ImportError: - pass diff --git a/neutron/tests/unit/services/loadbalancer/__init__.py b/neutron/tests/unit/services/loadbalancer/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/neutron/tests/unit/services/loadbalancer/test_plugin_shim.py b/neutron/tests/unit/services/loadbalancer/test_plugin_shim.py deleted file mode 100644 index be3d405009c..00000000000 --- a/neutron/tests/unit/services/loadbalancer/test_plugin_shim.py +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2012 OpenStack Foundation. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from neutron.tests import base - - -class TestPluginShim(base.BaseTestCase): - - def test_plugin_shim(self): - try: - from neutron.services.loadbalancer import plugin - plugin.LoadBalancerPlugin() - except ImportError: - pass diff --git a/neutron/tests/unit/services/vpn/__init__.py b/neutron/tests/unit/services/vpn/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/neutron/tests/unit/services/vpn/test_plugin_shim.py b/neutron/tests/unit/services/vpn/test_plugin_shim.py deleted file mode 100644 index 4fe18be5bb7..00000000000 --- a/neutron/tests/unit/services/vpn/test_plugin_shim.py +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2012 OpenStack Foundation. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from neutron.tests import base - - -class TestPluginShim(base.BaseTestCase): - - def test_plugin_shim(self): - try: - from neutron.services.vpn import plugin - plugin.VPNDriverPlugin() - except ImportError: - pass diff --git a/neutron/tests/unit/test_provider_configuration.py b/neutron/tests/unit/test_provider_configuration.py index 60eeccca4f5..8a6378a06a3 100644 --- a/neutron/tests/unit/test_provider_configuration.py +++ b/neutron/tests/unit/test_provider_configuration.py @@ -15,7 +15,7 @@ from oslo.config import cfg from neutron.common import exceptions as n_exc - +from neutron import manager from neutron.plugins.common import constants from neutron.services import provider_configuration as provconf from neutron.tests import base @@ -197,3 +197,17 @@ class ProviderConfigurationTestCase(base.BaseTestCase): fields=['name'] ) self.assertEqual(p, [{'name': prov['name']}]) + + +class GetProviderDriverClassTestCase(base.BaseTestCase): + def test_get_provider_driver_class_hit(self): + driver = 'ml2' + expected = 'neutron.plugins.ml2.plugin.Ml2Plugin' + actual = provconf.get_provider_driver_class( + driver, + namespace=manager.CORE_PLUGINS_NAMESPACE) + self.assertEqual(expected, actual) + + def test_get_provider_driver_class_miss(self): + retval = provconf.get_provider_driver_class('foo') + self.assertEqual('foo', retval) diff --git a/setup.cfg b/setup.cfg index 2feb253afba..330a136881a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -144,10 +144,26 @@ neutron.service_plugins = dummy = neutron.tests.unit.dummy_plugin:DummyServicePlugin router = neutron.services.l3_router.l3_router_plugin:L3RouterPlugin bigswitch_l3 = neutron.plugins.bigswitch.l3_router_plugin:L3RestProxy - firewall = neutron.services.firewall.fwaas_plugin:FirewallPlugin - lbaas = neutron.services.loadbalancer.plugin:LoadBalancerPlugin - vpnaas = neutron.services.vpn.plugin:VPNDriverPlugin + firewall = neutron_fwaas.services.firewall.fwaas_plugin:FirewallPlugin + lbaas = neutron_lbaas.services.loadbalancer.plugin:LoadBalancerPlugin + vpnaas = neutron_vpnaas.services.vpn.plugin:VPNDriverPlugin metering = neutron.services.metering.metering_plugin:MeteringPlugin + neutron.services.firewall.fwaas_plugin.FirewallPlugin = neutron_fwaas.services.firewall.fwaas_plugin:FirewallPlugin + neutron.services.loadbalancer.plugin.LoadBalancerPlugin = neutron_lbaas.services.loadbalancer.plugin:LoadBalancerPlugin + neutron.services.vpn.plugin.VPNDriverPlugin = neutron_vpnaas.services.vpn.plugin:VPNDriverPlugin +neutron.service_providers = + # These are for backwards compat with Juno firewall service provider configuration values + neutron.services.firewall.drivers.linux.iptables_fwaas.IptablesFwaasDriver = neutron_fwaas.services.firewall.drivers.linux.iptables_fwaas:IptablesFwaasDriver + neutron.services.firewall.drivers.varmour.varmour_fwaas.vArmourFwaasDriver = neutron_fwaas.services.firewall.drivers.varmour.varmour_fwaas:vArmourFwaasDriver + # These are for backwards compat with Juno loadbalancer service provider configuration values + neutron.services.loadbalancer.drivers.a10networks.driver_v1.ThunderDriver = neutron_lbaas.services.loadbalancer.drivers.a10networks.driver_v1:ThunderDriver + neutron.services.loadbalancer.drivers.embrane.driver.EmbraneLbaas = neutron_lbaas.services.loadbalancer.drivers.embrane.driver:EmbraneLbaas + neutron.services.loadbalancer.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver = neutron_lbaas.services.loadbalancer.drivers.haproxy.plugin_driver:HaproxyOnHostPluginDriver + neutron.services.loadbalancer.drivers.netscaler.netscaler_driver.NetScalerPluginDriver = neutron_lbaas.services.loadbalancer.drivers.netscaler.netscaler_driver:NetScalerPluginDriver + neutron.services.loadbalancer.drivers.radware.driver.LoadBalancerDriver = neutron_lbaas.services.loadbalancer.drivers.radware.driver:LoadBalancerDriver + # These are for backwards compat with Juno vpnaas service provider configuration values + neutron.services.vpn.service_drivers.cisco_ipsec.CiscoCsrIPsecVPNDriver = neutron_vpnaas.services.vpn.service_drivers.cisco_ipsec:CiscoCsrIPsecVPNDriver + neutron.services.vpn.service_drivers.ipsec.IPsecVPNDriver = neutron_vpnaas.services.vpn.service_drivers.ipsec:IPsecVPNDriver neutron.ml2.type_drivers = flat = neutron.plugins.ml2.drivers.type_flat:FlatTypeDriver local = neutron.plugins.ml2.drivers.type_local:LocalTypeDriver