Merge "Switch to using plugins directory in lieu of neutron manager"
This commit is contained in:
commit
c5acb45ff6
|
@ -22,10 +22,10 @@ from neutron.callbacks import resources
|
|||
from neutron.common import ipv6_utils
|
||||
from neutron.db import api as db_api
|
||||
from neutron.db import common_db_mixin as base_db
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants
|
||||
from neutron_lib import constants as n_const
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_db import exception
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
|
@ -57,7 +57,7 @@ class LoadBalancerPluginDbv2(base_db.CommonDbMixin,
|
|||
|
||||
@property
|
||||
def _core_plugin(self):
|
||||
return manager.NeutronManager.get_plugin()
|
||||
return directory.get_plugin()
|
||||
|
||||
def _get_resource(self, context, model, id, for_update=False):
|
||||
resource = None
|
||||
|
@ -927,7 +927,6 @@ def _prevent_lbaasv2_port_delete_callback(resource, event, trigger, **kwargs):
|
|||
context = kwargs['context']
|
||||
port_id = kwargs['port_id']
|
||||
port_check = kwargs['port_check']
|
||||
lbaasv2plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
constants.LOADBALANCERV2)
|
||||
lbaasv2plugin = directory.get_plugin(constants.LOADBALANCERV2)
|
||||
if lbaasv2plugin and port_check:
|
||||
lbaasv2plugin.db.prevent_lbaasv2_port_deletion(context, port_id)
|
||||
|
|
|
@ -14,11 +14,12 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.api.v2 import base
|
||||
from neutron.api.v2 import resource_helper
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants
|
||||
from neutron_lib.api import converters
|
||||
from neutron_lib import constants as n_constants
|
||||
|
@ -204,8 +205,7 @@ class L7(extensions.ExtensionDescriptor):
|
|||
constants.LOADBALANCERV2,
|
||||
register_quota=True)
|
||||
|
||||
plugin = manager.NeutronManager.get_service_plugins()[
|
||||
constants.LOADBALANCERV2]
|
||||
plugin = directory.get_plugin(constants.LOADBALANCERV2)
|
||||
|
||||
for collection_name in SUB_RESOURCE_ATTRIBUTE_MAP:
|
||||
# Special handling needed for sub-resources with 'y' ending
|
||||
|
|
|
@ -15,11 +15,12 @@
|
|||
|
||||
import abc
|
||||
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
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.plugins.common import constants as plugin_const
|
||||
from neutron import policy
|
||||
from neutron import wsgi
|
||||
|
@ -36,8 +37,7 @@ LOADBALANCER_AGENT = 'loadbalancer-hosting-agent'
|
|||
|
||||
class LoadBalancerSchedulerController(wsgi.Controller):
|
||||
def index(self, request, **kwargs):
|
||||
lbaas_plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
plugin_const.LOADBALANCERV2)
|
||||
lbaas_plugin = directory.get_plugin(plugin_const.LOADBALANCERV2)
|
||||
if not lbaas_plugin:
|
||||
return {'load_balancers': []}
|
||||
|
||||
|
@ -52,8 +52,7 @@ class LoadBalancerSchedulerController(wsgi.Controller):
|
|||
|
||||
class LbaasAgentHostingLoadBalancerController(wsgi.Controller):
|
||||
def index(self, request, **kwargs):
|
||||
lbaas_plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
plugin_const.LOADBALANCERV2)
|
||||
lbaas_plugin = directory.get_plugin(plugin_const.LOADBALANCERV2)
|
||||
if not lbaas_plugin:
|
||||
return
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
import abc
|
||||
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
@ -24,7 +25,6 @@ from neutron.api import extensions
|
|||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.api.v2 import base
|
||||
from neutron.api.v2 import resource_helper
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants
|
||||
from neutron.services import service_base
|
||||
from neutron_lib.api import converters
|
||||
|
@ -458,8 +458,7 @@ class Loadbalancerv2(extensions.ExtensionDescriptor):
|
|||
constants.LOADBALANCERV2,
|
||||
action_map=action_map,
|
||||
register_quota=True)
|
||||
plugin = manager.NeutronManager.get_service_plugins()[
|
||||
constants.LOADBALANCERV2]
|
||||
plugin = directory.get_plugin(constants.LOADBALANCERV2)
|
||||
for collection_name in SUB_RESOURCE_ATTRIBUTE_MAP:
|
||||
# Special handling needed for sub-resources with 'y' ending
|
||||
# (e.g. proxies -> proxy)
|
||||
|
|
|
@ -16,12 +16,13 @@
|
|||
import copy
|
||||
import six
|
||||
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron.api.v2 import attributes as attrs
|
||||
from neutron.api.v2 import base as napi_base
|
||||
from neutron import context as ncontext
|
||||
from neutron.db import servicetype_db as st_db
|
||||
from neutron.extensions import flavors
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants
|
||||
from neutron.services.flavors import flavors_plugin
|
||||
from neutron.services import provider_configuration as pconf
|
||||
|
@ -212,8 +213,7 @@ class LoadBalancerPluginv2(loadbalancerv2.LoadBalancerPluginBaseV2):
|
|||
loadbalancer['provider'] != n_constants.ATTR_NOT_SPECIFIED):
|
||||
raise loadbalancerv2.ProviderFlavorConflict()
|
||||
|
||||
plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
constants.FLAVORS)
|
||||
plugin = directory.get_plugin(constants.FLAVORS)
|
||||
if not plugin:
|
||||
raise loadbalancerv2.FlavorsPluginNotLoaded()
|
||||
|
||||
|
|
|
@ -25,13 +25,13 @@ from neutron.plugins.common import constants
|
|||
from neutron.tests.unit.db import test_db_base_plugin_v2
|
||||
from neutron_lib import constants as n_constants
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
import testtools
|
||||
import webob.exc
|
||||
|
||||
from neutron import manager
|
||||
from neutron_lbaas._i18n import _
|
||||
from neutron_lbaas.common.cert_manager import cert_manager
|
||||
from neutron_lbaas.common import exceptions
|
||||
|
@ -1006,16 +1006,15 @@ class LbaasLoadBalancerTests(LbaasPluginDbTestCase):
|
|||
ctx = context.get_admin_context()
|
||||
port['device_owner'] = n_constants.DEVICE_OWNER_LOADBALANCERV2
|
||||
myloadbalancers = [{'name': 'lb1'}]
|
||||
with mock.patch.object(manager.NeutronManager, 'get_plugin') as gp:
|
||||
self.plugin.db.get_loadbalancers = mock.Mock(
|
||||
return_value=myloadbalancers)
|
||||
plugin = mock.Mock()
|
||||
gp.return_value = plugin
|
||||
plugin._get_port.return_value = port
|
||||
self.assertRaises(n_exc.ServicePortInUse,
|
||||
self.plugin.db.prevent_lbaasv2_port_deletion,
|
||||
ctx,
|
||||
port['id'])
|
||||
plugin = mock.Mock()
|
||||
directory.add_plugin(n_constants.CORE, plugin)
|
||||
self.plugin.db.get_loadbalancers = (
|
||||
mock.Mock(return_value=myloadbalancers))
|
||||
plugin._get_port.return_value = port
|
||||
self.assertRaises(n_exc.ServicePortInUse,
|
||||
self.plugin.db.prevent_lbaasv2_port_deletion,
|
||||
ctx,
|
||||
port['id'])
|
||||
|
||||
|
||||
class LoadBalancerDelegateVIPCreation(LbaasPluginDbTestCase):
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron import context
|
||||
from neutron.db import servicetype_db as st_db
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants
|
||||
|
||||
from neutron_lbaas.db.loadbalancer import models
|
||||
|
@ -45,9 +45,7 @@ class TestLoadBalancerPluginBase(test_db_loadbalancerv2.LbaasPluginDbTestCase):
|
|||
'AgentDriverBase:default'))
|
||||
|
||||
# we need access to loaded plugins to modify models
|
||||
loaded_plugins = manager.NeutronManager().get_service_plugins()
|
||||
|
||||
self.plugin_instance = loaded_plugins[constants.LOADBALANCERV2]
|
||||
self.plugin_instance = directory.get_plugin(constants.LOADBALANCERV2)
|
||||
|
||||
|
||||
class TestLoadBalancerAgentApi(base.BaseTestCase):
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
import contextlib
|
||||
import copy
|
||||
import mock
|
||||
from neutron_lib.plugins import directory
|
||||
import re
|
||||
|
||||
from neutron import context
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants
|
||||
from oslo_config import cfg
|
||||
from oslo_serialization import jsonutils
|
||||
|
@ -213,8 +213,7 @@ class TestLBaaSDriverBase(
|
|||
super(TestLBaaSDriverBase, self).setUp(
|
||||
lbaas_provider=RADWARE_PROVIDER)
|
||||
|
||||
loaded_plugins = manager.NeutronManager().get_service_plugins()
|
||||
self.plugin_instance = loaded_plugins[constants.LOADBALANCERV2]
|
||||
self.plugin_instance = directory.get_plugin(constants.LOADBALANCERV2)
|
||||
self.driver = self.plugin_instance.drivers['radwarev2']
|
||||
|
||||
|
||||
|
|
|
@ -18,12 +18,13 @@ import copy
|
|||
from datetime import datetime
|
||||
|
||||
import mock
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron import context
|
||||
from neutron.db import agents_db
|
||||
from neutron.extensions import agent
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants as plugin_const
|
||||
from neutron.tests.common import helpers
|
||||
from neutron.tests.unit.api import test_extensions
|
||||
|
@ -118,9 +119,8 @@ class LBaaSAgentSchedulerTestCase(test_agent.AgentDBTestMixIn,
|
|||
# the global attribute map
|
||||
attributes.RESOURCE_ATTRIBUTE_MAP.update(
|
||||
agent.RESOURCE_ATTRIBUTE_MAP)
|
||||
self.lbaas_plugin = manager.NeutronManager.get_service_plugins()[
|
||||
plugin_const.LOADBALANCERV2]
|
||||
self.core_plugin = manager.NeutronManager.get_plugin()
|
||||
self.lbaas_plugin = directory.get_plugin(plugin_const.LOADBALANCERV2)
|
||||
self.core_plugin = directory.get_plugin()
|
||||
self.addCleanup(self.restore_attribute_map)
|
||||
|
||||
def restore_attribute_map(self):
|
||||
|
|
Loading…
Reference in New Issue