From 8037e8b4c6c153fb104498827424f3bd687d8c8b Mon Sep 17 00:00:00 2001 From: armando-migliaccio Date: Mon, 27 Jul 2015 14:08:57 -0700 Subject: [PATCH] Remove fall-back logic to service provider registration Once [1] merges, we no longer need to catch the AttributeError exception, so clean this up. [1] https://review.openstack.org/#/c/202207 Change-Id: I59eaf1dfd67751fdb4026407ea29e9f39fcbc2f9 Related-bug: #1473110 --- neutron_vpnaas/services/vpn/plugin.py | 11 ++----- .../tests/unit/db/vpn/test_vpn_db.py | 33 ++++++++----------- 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/neutron_vpnaas/services/vpn/plugin.py b/neutron_vpnaas/services/vpn/plugin.py index b2d54fe54..215d018be 100644 --- a/neutron_vpnaas/services/vpn/plugin.py +++ b/neutron_vpnaas/services/vpn/plugin.py @@ -27,14 +27,9 @@ LOG = logging.getLogger(__name__) def add_provider_configuration(type_manager, service_type): - try: - type_manager.add_provider_configuration( - service_type, - pconf.ProviderConfiguration('neutron_vpnaas')) - except AttributeError: - # TODO(armax): remove this try catch once the API - # add_provider_configuration becomes available - LOG.debug('add_provider_configuration API is not available') + type_manager.add_provider_configuration( + service_type, + pconf.ProviderConfiguration('neutron_vpnaas')) class VPNPlugin(vpn_db.VPNPluginDb): diff --git a/neutron_vpnaas/tests/unit/db/vpn/test_vpn_db.py b/neutron_vpnaas/tests/unit/db/vpn/test_vpn_db.py index dadf4dc51..b40d98f0c 100644 --- a/neutron_vpnaas/tests/unit/db/vpn/test_vpn_db.py +++ b/neutron_vpnaas/tests/unit/db/vpn/test_vpn_db.py @@ -32,7 +32,6 @@ from neutron.plugins.common import constants from neutron.scheduler import l3_agent_scheduler from neutron.tests.unit.db import test_db_base_plugin_v2 as test_db_plugin from neutron.tests.unit.extensions import test_l3 as test_l3_plugin -from oslo_config import cfg from oslo_utils import uuidutils import six import webob.exc @@ -423,25 +422,19 @@ class VPNPluginDbTestCase(VPNTestMixin, constants.VPN + ':vpnaas:neutron_vpnaas.services.vpn.' 'service_drivers.ipsec.IPsecVPNDriver:default') - # TODO(armax): remove this if branch as soon as the ServiceTypeManager - # API for adding provider configurations becomes available - if not hasattr(sdb.ServiceTypeManager, 'add_provider_configuration'): - cfg.CONF.set_override( - 'service_provider', [vpnaas_provider], 'service_providers') - else: - bits = vpnaas_provider.split(':') - vpnaas_provider = { - 'service_type': bits[0], - 'name': bits[1], - 'driver': bits[2] - } - if len(bits) == 4: - vpnaas_provider['default'] = True - # override the default service provider - self.service_providers = ( - mock.patch.object(sdb.ServiceTypeManager, - 'get_service_providers').start()) - self.service_providers.return_value = [vpnaas_provider] + bits = vpnaas_provider.split(':') + vpnaas_provider = { + 'service_type': bits[0], + 'name': bits[1], + 'driver': bits[2] + } + if len(bits) == 4: + vpnaas_provider['default'] = True + # override the default service provider + self.service_providers = ( + mock.patch.object(sdb.ServiceTypeManager, + 'get_service_providers').start()) + self.service_providers.return_value = [vpnaas_provider] # force service type manager to reload configuration: sdb.ServiceTypeManager._instance = None service_plugins = {'vpnaas_plugin': vpnaas_plugin}