Merge "neutron-lib: use L3 constant"

This commit is contained in:
Jenkins 2017-01-13 04:54:04 +00:00 committed by Gerrit Code Review
commit b40ce0759f
10 changed files with 22 additions and 23 deletions

View File

@ -17,6 +17,7 @@ import abc
from neutron_lib.api import converters from neutron_lib.api import converters
from neutron_lib.api import extensions from neutron_lib.api import extensions
from neutron_lib import constants
from neutron_lib.db import constants as db_const from neutron_lib.db import constants as db_const
from neutron_lib import exceptions as nexception from neutron_lib import exceptions as nexception
import six import six
@ -24,7 +25,6 @@ import six
from neutron._i18n import _ from neutron._i18n import _
from neutron.api.v2 import resource_helper from neutron.api.v2 import resource_helper
from neutron.conf import quota from neutron.conf import quota
from neutron.plugins.common import constants
# L3 Exceptions # L3 Exceptions
@ -195,7 +195,7 @@ class L3(extensions.ExtensionDescriptor):
'remove_router_interface': 'PUT'}} 'remove_router_interface': 'PUT'}}
return resource_helper.build_resource_info(plural_mappings, return resource_helper.build_resource_info(plural_mappings,
RESOURCE_ATTRIBUTE_MAP, RESOURCE_ATTRIBUTE_MAP,
constants.L3_ROUTER_NAT, constants.L3,
action_map=action_map, action_map=action_map,
register_quota=True) register_quota=True)

View File

@ -13,6 +13,9 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from neutron_lib import constants
# Neutron well-known service type constants: # Neutron well-known service type constants:
DUMMY = "DUMMY" DUMMY = "DUMMY"
LOADBALANCER = "LOADBALANCER" LOADBALANCER = "LOADBALANCER"
@ -20,7 +23,6 @@ LOADBALANCERV2 = "LOADBALANCERV2"
FIREWALL = "FIREWALL" FIREWALL = "FIREWALL"
VPN = "VPN" VPN = "VPN"
METERING = "METERING" METERING = "METERING"
L3_ROUTER_NAT = "L3_ROUTER_NAT"
FLAVORS = "FLAVORS" FLAVORS = "FLAVORS"
QOS = "QOS" QOS = "QOS"
@ -33,7 +35,7 @@ EXT_TO_SERVICE_MAPPING = {
'fwaas': FIREWALL, 'fwaas': FIREWALL,
'vpnaas': VPN, 'vpnaas': VPN,
'metering': METERING, 'metering': METERING,
'router': L3_ROUTER_NAT, 'router': constants.L3,
'qos': QOS, 'qos': QOS,
} }

View File

@ -32,7 +32,6 @@ from neutron.db import l3_hamode_db
from neutron.db import l3_hascheduler_db from neutron.db import l3_hascheduler_db
from neutron.db.models import l3 as l3_models from neutron.db.models import l3 as l3_models
from neutron.extensions import l3 from neutron.extensions import l3
from neutron.plugins.common import constants
from neutron.quota import resource_registry from neutron.quota import resource_registry
from neutron import service from neutron import service
from neutron.services.l3_router.service_providers import driver_controller from neutron.services.l3_router.service_providers import driver_controller
@ -95,7 +94,7 @@ class L3RouterPlugin(service_base.ServicePluginBase,
@classmethod @classmethod
def get_plugin_type(cls): def get_plugin_type(cls):
return constants.L3_ROUTER_NAT return n_const.L3
def get_plugin_description(self): def get_plugin_description(self):
"""returns string description of the plugin.""" """returns string description of the plugin."""

View File

@ -45,7 +45,7 @@ class DriverController(object):
self.l3_plugin = l3_plugin self.l3_plugin = l3_plugin
self._stm = st_db.ServiceTypeManager.get_instance() self._stm = st_db.ServiceTypeManager.get_instance()
self._stm.add_provider_configuration( self._stm.add_provider_configuration(
constants.L3_ROUTER_NAT, _LegacyPlusProviderConfiguration()) lib_const.L3, _LegacyPlusProviderConfiguration())
self._load_drivers() self._load_drivers()
registry.subscribe(self._check_router_request, registry.subscribe(self._check_router_request,
resources.ROUTER, events.BEFORE_CREATE) resources.ROUTER, events.BEFORE_CREATE)
@ -58,7 +58,7 @@ class DriverController(object):
def _load_drivers(self): def _load_drivers(self):
self.drivers, self.default_provider = ( 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 # store the provider name on each driver to make finding inverse easy
for provider_name, driver in self.drivers.items(): for provider_name, driver in self.drivers.items():
setattr(driver, 'name', provider_name) setattr(driver, 'name', provider_name)
@ -86,7 +86,7 @@ class DriverController(object):
if _flavor_specified(router): if _flavor_specified(router):
router_db.flavor_id = router['flavor_id'] router_db.flavor_id = router['flavor_id']
drv = self._get_provider_for_create(context, router) 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']) drv.name, router['id'])
def _clear_router_provider(self, resource, event, trigger, context, def _clear_router_provider(self, resource, event, trigger, context,
@ -143,7 +143,7 @@ class DriverController(object):
with context.session.begin(subtransactions=True): with context.session.begin(subtransactions=True):
self._stm.del_resource_associations(context, [router_id]) self._stm.del_resource_associations(context, [router_id])
self._stm.add_resource_association( 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): def _get_provider_for_router(self, context, router_id):
"""Return the provider driver handle for a 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) router = self.l3_plugin.get_router(context, router_id)
driver = self._attrs_to_driver(router) driver = self._attrs_to_driver(router)
driver_name = driver.name 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) driver_name, router_id)
return self.drivers[driver_name] return self.drivers[driver_name]
@ -211,7 +211,7 @@ class _LegacyPlusProviderConfiguration(
('single_node', 'single_node.SingleNodeDriver')): ('single_node', 'single_node.SingleNodeDriver')):
path = 'neutron.services.l3_router.service_providers.%s' % driver path = 'neutron.services.l3_router.service_providers.%s' % driver
try: try:
self.add_provider({'service_type': constants.L3_ROUTER_NAT, self.add_provider({'service_type': lib_const.L3,
'name': name, 'driver': path, 'name': name, 'driver': path,
'default': False}) 'default': False})
except lib_exc.Invalid: except lib_exc.Invalid:

View File

@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from neutron_lib import constants
from tempest.lib import exceptions as lib_exc from tempest.lib import exceptions as lib_exc
from tempest import test from tempest import test
import testtools import testtools
@ -45,7 +46,7 @@ class RoutersFlavorTestCase(base.BaseRouterTest):
cls.flavor = cls.create_flavor( cls.flavor = cls.create_flavor(
name='special_flavor', name='special_flavor',
description='econonomy class', description='econonomy class',
service_type='L3_ROUTER_NAT') service_type=constants.L3)
cls.admin_client.create_flavor_service_profile( cls.admin_client.create_flavor_service_profile(
cls.flavor['id'], sp['service_profile']['id']) cls.flavor['id'], sp['service_profile']['id'])
cls.flavor_service_profiles.append((cls.flavor['id'], cls.flavor_service_profiles.append((cls.flavor['id'],
@ -63,7 +64,7 @@ class RoutersFlavorTestCase(base.BaseRouterTest):
cls.prem_flavor = cls.create_flavor( cls.prem_flavor = cls.create_flavor(
name='better_special_flavor', name='better_special_flavor',
description='econonomy comfort', description='econonomy comfort',
service_type='L3_ROUTER_NAT') service_type=constants.L3)
cls.admin_client.create_flavor_service_profile( cls.admin_client.create_flavor_service_profile(
cls.prem_flavor['id'], sp['service_profile']['id']) cls.prem_flavor['id'], sp['service_profile']['id'])
cls.flavor_service_profiles.append((cls.prem_flavor['id'], cls.flavor_service_profiles.append((cls.prem_flavor['id'],

View File

@ -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.agent.l3 import ha as ha_conf
from neutron.conf import common as base_config from neutron.conf import common as base_config
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron.plugins.common import constants as p_const
from neutron.tests import base from neutron.tests import base
from neutron.tests.common import l3_test_common from neutron.tests.common import l3_test_common
@ -2281,7 +2280,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
self.assertEqual(2, mocked_func.call_count) self.assertEqual(2, mocked_func.call_count)
def test_get_service_plugin_list(self): 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 self.plugin_api.get_service_plugin_list.return_value = service_plugins
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf) agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
self.assertEqual(service_plugins, agent.neutron_service_plugins) self.assertEqual(service_plugins, agent.neutron_service_plugins)

View File

@ -185,7 +185,7 @@ class ExtNetDBTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
def test_delete_network_check_disassociated_floatingips(self): def test_delete_network_check_disassociated_floatingips(self):
l3_mock = mock.Mock() l3_mock = mock.Mock()
directory.add_plugin('L3_ROUTER_NAT', l3_mock) directory.add_plugin(constants.L3, l3_mock)
with self.network() as net: with self.network() as net:
req = self.new_delete_request('networks', net['network']['id']) req = self.new_delete_request('networks', net['network']['id'])
res = req.get_response(self.api) res = req.get_response(self.api)

View File

@ -52,7 +52,6 @@ from neutron.extensions import dns
from neutron.extensions import external_net from neutron.extensions import external_net
from neutron.extensions import l3 from neutron.extensions import l3
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron.plugins.common import constants as service_constants
from neutron.plugins.ml2 import config from neutron.plugins.ml2 import config
from neutron.tests import base from neutron.tests import base
from neutron.tests.common import helpers from neutron.tests.common import helpers
@ -307,7 +306,7 @@ class TestL3NatServicePlugin(common_db_mixin.CommonDbMixin,
@classmethod @classmethod
def get_plugin_type(cls): def get_plugin_type(cls):
return service_constants.L3_ROUTER_NAT return lib_constants.L3
def get_plugin_description(self): def get_plugin_description(self):
return "L3 Routing Service Plugin for testing" return "L3 Routing Service Plugin for testing"

View File

@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from neutron_lib import constants
import six import six
from neutron.db.availability_zone import router as router_az_db 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.db import l3_db
from neutron.extensions import l3 from neutron.extensions import l3
from neutron.extensions import router_availability_zone as router_az 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_availability_zone as test_az
from neutron.tests.unit.extensions import test_l3 from neutron.tests.unit.extensions import test_l3
@ -40,7 +40,7 @@ class AZRouterTestPlugin(common_db_mixin.CommonDbMixin,
@classmethod @classmethod
def get_plugin_type(cls): def get_plugin_type(cls):
return service_constants.L3_ROUTER_NAT return constants.L3
def get_plugin_description(self): def get_plugin_description(self):
return "L3 Routing Service Plugin for testing" return "L3 Routing Service Plugin for testing"

View File

@ -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 l3agentscheduler as l3agent
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron import manager from neutron import manager
from neutron.plugins.common import constants as service_constants
from neutron.scheduler import l3_agent_scheduler from neutron.scheduler import l3_agent_scheduler
from neutron.tests import base from neutron.tests import base
from neutron.tests.common import helpers from neutron.tests.common import helpers
@ -1415,7 +1414,7 @@ class L3HAPlugin(db_v2.NeutronDbPluginV2,
@classmethod @classmethod
def get_plugin_type(cls): def get_plugin_type(cls):
return service_constants.L3_ROUTER_NAT return constants.L3
def get_plugin_description(self): def get_plugin_description(self):
return "L3 Routing Service Plugin for testing" return "L3 Routing Service Plugin for testing"