diff --git a/neutron/extensions/l3.py b/neutron/extensions/l3.py index 78eeade0747..a0795a393d9 100644 --- a/neutron/extensions/l3.py +++ b/neutron/extensions/l3.py @@ -17,6 +17,7 @@ import abc from neutron_lib.api import converters from neutron_lib.api import extensions +from neutron_lib import constants from neutron_lib.db import constants as db_const from neutron_lib import exceptions as nexception import six @@ -24,7 +25,6 @@ import six from neutron._i18n import _ from neutron.api.v2 import resource_helper from neutron.conf import quota -from neutron.plugins.common import constants # L3 Exceptions @@ -195,7 +195,7 @@ class L3(extensions.ExtensionDescriptor): 'remove_router_interface': 'PUT'}} return resource_helper.build_resource_info(plural_mappings, RESOURCE_ATTRIBUTE_MAP, - constants.L3_ROUTER_NAT, + constants.L3, action_map=action_map, register_quota=True) diff --git a/neutron/plugins/common/constants.py b/neutron/plugins/common/constants.py index 23f8dc5c86c..a8524bd7bdd 100644 --- a/neutron/plugins/common/constants.py +++ b/neutron/plugins/common/constants.py @@ -13,6 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import constants + + # Neutron well-known service type constants: DUMMY = "DUMMY" LOADBALANCER = "LOADBALANCER" @@ -20,7 +23,6 @@ LOADBALANCERV2 = "LOADBALANCERV2" FIREWALL = "FIREWALL" VPN = "VPN" METERING = "METERING" -L3_ROUTER_NAT = "L3_ROUTER_NAT" FLAVORS = "FLAVORS" QOS = "QOS" @@ -33,7 +35,7 @@ EXT_TO_SERVICE_MAPPING = { 'fwaas': FIREWALL, 'vpnaas': VPN, 'metering': METERING, - 'router': L3_ROUTER_NAT, + 'router': constants.L3, 'qos': QOS, } diff --git a/neutron/services/l3_router/l3_router_plugin.py b/neutron/services/l3_router/l3_router_plugin.py index 2a3c585734c..9ed3ee9ec81 100644 --- a/neutron/services/l3_router/l3_router_plugin.py +++ b/neutron/services/l3_router/l3_router_plugin.py @@ -32,7 +32,6 @@ from neutron.db import l3_hamode_db from neutron.db import l3_hascheduler_db from neutron.db.models import l3 as l3_models from neutron.extensions import l3 -from neutron.plugins.common import constants from neutron.quota import resource_registry from neutron import service from neutron.services.l3_router.service_providers import driver_controller @@ -95,7 +94,7 @@ class L3RouterPlugin(service_base.ServicePluginBase, @classmethod def get_plugin_type(cls): - return constants.L3_ROUTER_NAT + return n_const.L3 def get_plugin_description(self): """returns string description of the plugin.""" diff --git a/neutron/services/l3_router/service_providers/driver_controller.py b/neutron/services/l3_router/service_providers/driver_controller.py index 9dcb14d9c73..df35231d4b7 100644 --- a/neutron/services/l3_router/service_providers/driver_controller.py +++ b/neutron/services/l3_router/service_providers/driver_controller.py @@ -45,7 +45,7 @@ class DriverController(object): self.l3_plugin = l3_plugin self._stm = st_db.ServiceTypeManager.get_instance() self._stm.add_provider_configuration( - constants.L3_ROUTER_NAT, _LegacyPlusProviderConfiguration()) + lib_const.L3, _LegacyPlusProviderConfiguration()) self._load_drivers() registry.subscribe(self._check_router_request, resources.ROUTER, events.BEFORE_CREATE) @@ -58,7 +58,7 @@ class DriverController(object): def _load_drivers(self): self.drivers, self.default_provider = ( - service_base.load_drivers(constants.L3_ROUTER_NAT, self.l3_plugin)) + service_base.load_drivers(lib_const.L3, self.l3_plugin)) # store the provider name on each driver to make finding inverse easy for provider_name, driver in self.drivers.items(): setattr(driver, 'name', provider_name) @@ -86,7 +86,7 @@ class DriverController(object): if _flavor_specified(router): router_db.flavor_id = router['flavor_id'] drv = self._get_provider_for_create(context, router) - self._stm.add_resource_association(context, 'L3_ROUTER_NAT', + self._stm.add_resource_association(context, lib_const.L3, drv.name, router['id']) def _clear_router_provider(self, resource, event, trigger, context, @@ -143,7 +143,7 @@ class DriverController(object): with context.session.begin(subtransactions=True): self._stm.del_resource_associations(context, [router_id]) self._stm.add_resource_association( - context, 'L3_ROUTER_NAT', new_drv.name, router_id) + context, lib_const.L3, new_drv.name, router_id) def _get_provider_for_router(self, context, router_id): """Return the provider driver handle for a router id.""" @@ -155,7 +155,7 @@ class DriverController(object): router = self.l3_plugin.get_router(context, router_id) driver = self._attrs_to_driver(router) driver_name = driver.name - self._stm.add_resource_association(context, 'L3_ROUTER_NAT', + self._stm.add_resource_association(context, lib_const.L3, driver_name, router_id) return self.drivers[driver_name] @@ -211,7 +211,7 @@ class _LegacyPlusProviderConfiguration( ('single_node', 'single_node.SingleNodeDriver')): path = 'neutron.services.l3_router.service_providers.%s' % driver try: - self.add_provider({'service_type': constants.L3_ROUTER_NAT, + self.add_provider({'service_type': lib_const.L3, 'name': name, 'driver': path, 'default': False}) except lib_exc.Invalid: diff --git a/neutron/tests/tempest/api/admin/test_routers_flavors.py b/neutron/tests/tempest/api/admin/test_routers_flavors.py index 4988ba80b5e..7323427cb7d 100644 --- a/neutron/tests/tempest/api/admin/test_routers_flavors.py +++ b/neutron/tests/tempest/api/admin/test_routers_flavors.py @@ -11,6 +11,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import constants from tempest.lib import exceptions as lib_exc from tempest import test import testtools @@ -45,7 +46,7 @@ class RoutersFlavorTestCase(base.BaseRouterTest): cls.flavor = cls.create_flavor( name='special_flavor', description='econonomy class', - service_type='L3_ROUTER_NAT') + service_type=constants.L3) cls.admin_client.create_flavor_service_profile( cls.flavor['id'], sp['service_profile']['id']) cls.flavor_service_profiles.append((cls.flavor['id'], @@ -63,7 +64,7 @@ class RoutersFlavorTestCase(base.BaseRouterTest): cls.prem_flavor = cls.create_flavor( name='better_special_flavor', description='econonomy comfort', - service_type='L3_ROUTER_NAT') + service_type=constants.L3) cls.admin_client.create_flavor_service_profile( cls.prem_flavor['id'], sp['service_profile']['id']) cls.flavor_service_profiles.append((cls.prem_flavor['id'], diff --git a/neutron/tests/unit/agent/l3/test_agent.py b/neutron/tests/unit/agent/l3/test_agent.py index 402150fba69..131b7d88d71 100644 --- a/neutron/tests/unit/agent/l3/test_agent.py +++ b/neutron/tests/unit/agent/l3/test_agent.py @@ -53,7 +53,6 @@ from neutron.conf.agent.l3 import config as l3_config from neutron.conf.agent.l3 import ha as ha_conf from neutron.conf import common as base_config from neutron.extensions import portbindings -from neutron.plugins.common import constants as p_const from neutron.tests import base from neutron.tests.common import l3_test_common @@ -2281,7 +2280,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework): self.assertEqual(2, mocked_func.call_count) def test_get_service_plugin_list(self): - service_plugins = [p_const.L3_ROUTER_NAT] + service_plugins = [lib_constants.L3] self.plugin_api.get_service_plugin_list.return_value = service_plugins agent = l3_agent.L3NATAgent(HOSTNAME, self.conf) self.assertEqual(service_plugins, agent.neutron_service_plugins) diff --git a/neutron/tests/unit/extensions/test_external_net.py b/neutron/tests/unit/extensions/test_external_net.py index aa8a49e9c90..43c80553326 100644 --- a/neutron/tests/unit/extensions/test_external_net.py +++ b/neutron/tests/unit/extensions/test_external_net.py @@ -185,7 +185,7 @@ class ExtNetDBTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase): def test_delete_network_check_disassociated_floatingips(self): l3_mock = mock.Mock() - directory.add_plugin('L3_ROUTER_NAT', l3_mock) + directory.add_plugin(constants.L3, l3_mock) with self.network() as net: req = self.new_delete_request('networks', net['network']['id']) res = req.get_response(self.api) diff --git a/neutron/tests/unit/extensions/test_l3.py b/neutron/tests/unit/extensions/test_l3.py index 8560ffeb223..9034dc641aa 100644 --- a/neutron/tests/unit/extensions/test_l3.py +++ b/neutron/tests/unit/extensions/test_l3.py @@ -52,7 +52,6 @@ from neutron.extensions import dns from neutron.extensions import external_net from neutron.extensions import l3 from neutron.extensions import portbindings -from neutron.plugins.common import constants as service_constants from neutron.plugins.ml2 import config from neutron.tests import base from neutron.tests.common import helpers @@ -307,7 +306,7 @@ class TestL3NatServicePlugin(common_db_mixin.CommonDbMixin, @classmethod def get_plugin_type(cls): - return service_constants.L3_ROUTER_NAT + return lib_constants.L3 def get_plugin_description(self): return "L3 Routing Service Plugin for testing" diff --git a/neutron/tests/unit/extensions/test_router_availability_zone.py b/neutron/tests/unit/extensions/test_router_availability_zone.py index 30e6e8b9d04..9319309151b 100644 --- a/neutron/tests/unit/extensions/test_router_availability_zone.py +++ b/neutron/tests/unit/extensions/test_router_availability_zone.py @@ -11,6 +11,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import constants import six from neutron.db.availability_zone import router as router_az_db @@ -19,7 +20,6 @@ from neutron.db import l3_agentschedulers_db from neutron.db import l3_db from neutron.extensions import l3 from neutron.extensions import router_availability_zone as router_az -from neutron.plugins.common import constants as service_constants from neutron.tests.unit.extensions import test_availability_zone as test_az from neutron.tests.unit.extensions import test_l3 @@ -40,7 +40,7 @@ class AZRouterTestPlugin(common_db_mixin.CommonDbMixin, @classmethod def get_plugin_type(cls): - return service_constants.L3_ROUTER_NAT + return constants.L3 def get_plugin_description(self): return "L3 Routing Service Plugin for testing" diff --git a/neutron/tests/unit/scheduler/test_l3_agent_scheduler.py b/neutron/tests/unit/scheduler/test_l3_agent_scheduler.py index 56b89133de7..8cce97b2cfa 100644 --- a/neutron/tests/unit/scheduler/test_l3_agent_scheduler.py +++ b/neutron/tests/unit/scheduler/test_l3_agent_scheduler.py @@ -43,7 +43,6 @@ from neutron.extensions import l3_ext_ha_mode as l3_ha from neutron.extensions import l3agentscheduler as l3agent from neutron.extensions import portbindings from neutron import manager -from neutron.plugins.common import constants as service_constants from neutron.scheduler import l3_agent_scheduler from neutron.tests import base from neutron.tests.common import helpers @@ -1415,7 +1414,7 @@ class L3HAPlugin(db_v2.NeutronDbPluginV2, @classmethod def get_plugin_type(cls): - return service_constants.L3_ROUTER_NAT + return constants.L3 def get_plugin_description(self): return "L3 Routing Service Plugin for testing"