Switch to using plugins directory in lieu of neutron manager

Partially-implements: blueprint neutron-lib

Depends-on: I7331e914234c5f0b7abe836604fdd7e4067551cf
Change-Id: Id8d55cce14489fa06ec6542ebefb317623ea5d2d
This commit is contained in:
Armando Migliaccio 2016-11-10 10:09:38 -08:00
parent 635a4df588
commit 04538fc4c9
5 changed files with 16 additions and 23 deletions

View File

@ -13,10 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from neutron_lib.plugins import directory
import oslo_messaging
from neutron import manager
from neutron_dynamic_routing.extensions import bgp as bgp_ext
@ -37,8 +36,7 @@ class BgpSpeakerRpcCallback(object):
@property
def plugin(self):
if not hasattr(self, '_plugin'):
self._plugin = manager.NeutronManager.get_service_plugins().get(
bgp_ext.BGP_EXT_ALIAS)
self._plugin = directory.get_plugin(bgp_ext.BGP_EXT_ALIAS)
return self._plugin
def get_bgp_speaker_info(self, context, bgp_speaker_id):

View File

@ -18,13 +18,13 @@ import six
import webob
from neutron_lib import exceptions as n_exc
from neutron_lib.plugins import directory
from oslo_log import log as logging
from neutron.api import extensions
from neutron.api.v2 import base
from neutron.api.v2 import resource
from neutron.extensions import agent
from neutron import manager
from neutron import wsgi
from neutron_dynamic_routing._i18n import _, _LE
@ -57,8 +57,7 @@ class DrAgentAssociationError(n_exc.Conflict):
class BgpDrSchedulerController(wsgi.Controller):
"""Schedule BgpSpeaker for a BgpDrAgent"""
def get_plugin(self):
plugin = manager.NeutronManager.get_service_plugins().get(
bgp_ext.BGP_EXT_ALIAS)
plugin = directory.get_plugin(bgp_ext.BGP_EXT_ALIAS)
if not plugin:
LOG.error(_LE('No plugin for BGP routing registered'))
msg = _('The resource could not be found.')
@ -85,8 +84,7 @@ class BgpDrSchedulerController(wsgi.Controller):
class BgpDrAgentController(wsgi.Controller):
def get_plugin(self):
plugin = manager.NeutronManager.get_service_plugins().get(
bgp_ext.BGP_EXT_ALIAS)
plugin = directory.get_plugin(bgp_ext.BGP_EXT_ALIAS)
if not plugin:
LOG.error(_LE('No plugin for BGP routing registered'))
msg = _('The resource could not be found.')
@ -94,8 +92,7 @@ class BgpDrAgentController(wsgi.Controller):
return plugin
def index(self, request, **kwargs):
plugin = manager.NeutronManager.get_service_plugins().get(
bgp_ext.BGP_EXT_ALIAS)
plugin = directory.get_plugin(bgp_ext.BGP_EXT_ALIAS)
return plugin.list_dragent_hosting_bgp_speaker(
request.context, kwargs['bgp_speaker_id'])

View File

@ -14,20 +14,21 @@
# limitations under the License.
import mock
from neutron_lib.plugins import directory
from neutron.tests import base
from neutron_dynamic_routing.api.rpc.handlers import bgp_speaker_rpc
from neutron_dynamic_routing.extensions import bgp as bgp_ext
class TestBgpSpeakerRpcCallback(base.BaseTestCase):
def setUp(self):
self.plugin_p = mock.patch('neutron.manager.NeutronManager.'
'get_service_plugins')
self.plugin = self.plugin_p.start()
self.callback = bgp_speaker_rpc.BgpSpeakerRpcCallback()
super(TestBgpSpeakerRpcCallback, self).setUp()
self.plugin = mock.Mock()
directory.add_plugin(bgp_ext.BGP_EXT_ALIAS, self.plugin)
self.callback = bgp_speaker_rpc.BgpSpeakerRpcCallback()
def test_get_bgp_speaker_info(self):
self.callback.get_bgp_speaker_info(mock.Mock(),

View File

@ -18,14 +18,13 @@ from oslo_config import cfg
from neutron_lib import constants as n_const
from neutron_lib import exceptions as n_exc
from neutron_lib.plugins import directory
from oslo_utils import uuidutils
from neutron.db import l3_dvr_ha_scheduler_db
from neutron.db import l3_hamode_db
from neutron.extensions import external_net
from neutron.extensions import portbindings
from neutron import manager
from neutron.plugins.common import constants as p_const
from neutron.tests.unit.extensions import test_l3
from neutron.tests.unit.plugins.ml2 import test_plugin
@ -168,10 +167,9 @@ class BgpTests(test_plugin.Ml2PluginV2TestCase,
def setUp(self):
super(BgpTests, self).setUp()
self.l3plugin = manager.NeutronManager.get_service_plugins().get(
p_const.L3_ROUTER_NAT)
self.l3plugin = directory.get_plugin(n_const.L3)
self.bgp_plugin = bgp_plugin.BgpPlugin()
self.plugin = manager.NeutronManager.get_plugin()
self.plugin = directory.get_plugin()
@contextlib.contextmanager
def subnetpool_with_address_scope(self, ip_version, prefixes=None,

View File

@ -12,13 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib.plugins import directory
from oslo_config import cfg
from oslo_utils import importutils
from neutron.api.v2 import attributes
from neutron import context
from neutron.extensions import agent
from neutron import manager
from neutron.tests.unit.db import test_db_base_plugin_v2 as test_db_base_plugin
from neutron.tests.unit.extensions import test_agent
@ -201,6 +201,5 @@ class BgpDrPluginSchedulerTests(test_db_base_plugin.NeutronDbPluginV2TestCase,
ext_mgr = ext_mgr or BgpDrSchedulerTestExtensionManager()
super(BgpDrPluginSchedulerTests, self).setUp(
plugin=plugin, ext_mgr=ext_mgr, service_plugins=service_plugins)
self.bgp_plugin = manager.NeutronManager.get_service_plugins().get(
bgp.BGP_EXT_ALIAS)
self.bgp_plugin = directory.get_plugin(bgp.BGP_EXT_ALIAS)
self.context = context.get_admin_context()