From 4e934ada6bb38de8512143807bcfc29362204b82 Mon Sep 17 00:00:00 2001 From: armando-migliaccio Date: Mon, 27 Jul 2015 13:57:09 -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 Related-bug: #1473110 Change-Id: I7f3f084acfae67eaf82a959178565a05149254f4 --- neutron_lbaas/services/loadbalancer/plugin.py | 11 +++-------- neutron_lbaas/tests/base.py | 19 ++++++------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/neutron_lbaas/services/loadbalancer/plugin.py b/neutron_lbaas/services/loadbalancer/plugin.py index 3391be7a9..c4086faba 100644 --- a/neutron_lbaas/services/loadbalancer/plugin.py +++ b/neutron_lbaas/services/loadbalancer/plugin.py @@ -57,14 +57,9 @@ def verify_lbaas_mutual_exclusion(): def add_provider_configuration(type_manager, service_type): - try: - type_manager.add_provider_configuration( - service_type, - pconf.ProviderConfiguration('neutron_lbaas')) - 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_lbaas')) class LoadBalancerPlugin(ldb.LoadBalancerPluginDb, diff --git a/neutron_lbaas/tests/base.py b/neutron_lbaas/tests/base.py index a347ca0a3..2f24dd68c 100644 --- a/neutron_lbaas/tests/base.py +++ b/neutron_lbaas/tests/base.py @@ -22,7 +22,6 @@ from neutron.tests.unit.db import test_db_base_plugin_v2 from neutron.tests.unit.extensions import base as ext_base from neutron.tests.unit.extensions import test_quotasv2 from neutron.tests.unit import testlib_api -from oslo_config import cfg from testtools import matchers @@ -34,18 +33,12 @@ class NeutronDbPluginV2TestCase( test_db_base_plugin_v2.NeutronDbPluginV2TestCase): def set_override(self, lbaas_provider): - # TODO(armax): remove this if branch as soon as the ServiceTypeManager - # API for adding provider configurations becomes available - if not hasattr(st_db.ServiceTypeManager, 'add_provider_configuration'): - cfg.CONF.set_override( - 'service_provider', lbaas_provider, 'service_providers') - else: - # override the default service provider - self.service_providers = ( - mock.patch.object(st_db.ServiceTypeManager, - 'get_service_providers').start()) - self.service_providers.return_value = ( - self._to_provider_dicts(lbaas_provider)) + # override the default service provider + self.service_providers = ( + mock.patch.object(st_db.ServiceTypeManager, + 'get_service_providers').start()) + self.service_providers.return_value = ( + self._to_provider_dicts(lbaas_provider)) # need to reload provider configuration st_db.ServiceTypeManager._instance = None