Merge "Adopt neutron-lib plugin directory"
This commit is contained in:
commit
b9d0a5b885
|
@ -55,14 +55,14 @@ Calling the Core Plugin from Services
|
|||
|
||||
There are many cases where a service may want to create a resource
|
||||
managed by the core plugin (e.g. ports, networks, subnets). This
|
||||
can be achieved by importing the Neutron Manager and getting a direct
|
||||
can be achieved by importing the plugins directory and getting a direct
|
||||
reference to the core plugin:
|
||||
|
||||
.. code:: python
|
||||
|
||||
from neutron import manager
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
plugin.create_port(context, port_dict)
|
||||
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import collections
|
|||
import imp
|
||||
import os
|
||||
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_middleware import base
|
||||
|
@ -29,7 +30,6 @@ import webob.exc
|
|||
from neutron._i18n import _, _LE, _LI, _LW
|
||||
from neutron.common import exceptions
|
||||
import neutron.extensions
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants as const
|
||||
from neutron.services import provider_configuration
|
||||
from neutron import wsgi
|
||||
|
@ -665,7 +665,7 @@ class PluginAwareExtensionManager(ExtensionManager):
|
|||
@classmethod
|
||||
def get_instance(cls):
|
||||
if cls._instance is None:
|
||||
service_plugins = manager.NeutronManager.get_service_plugins()
|
||||
service_plugins = directory.get_plugins()
|
||||
cls._instance = cls(get_extensions_path(service_plugins),
|
||||
service_plugins)
|
||||
return cls._instance
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# limitations under the License.
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
|
@ -26,7 +27,6 @@ from neutron.common import constants as n_const
|
|||
from neutron.common import rpc as n_rpc
|
||||
from neutron.common import topics
|
||||
from neutron.common import utils
|
||||
from neutron import manager
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -90,7 +90,7 @@ class DhcpAgentNotifyAPI(object):
|
|||
@property
|
||||
def plugin(self):
|
||||
if self._plugin is None:
|
||||
self._plugin = manager.NeutronManager.get_plugin()
|
||||
self._plugin = directory.get_plugin()
|
||||
return self._plugin
|
||||
|
||||
def _schedule_network(self, context, network, existing_agents):
|
||||
|
@ -166,8 +166,7 @@ class DhcpAgentNotifyAPI(object):
|
|||
if 'subnet' in payload and payload['subnet'].get('segment_id'):
|
||||
# if segment_id exists then the segment service plugin
|
||||
# must be loaded
|
||||
nm = manager.NeutronManager
|
||||
segment_plugin = nm.get_service_plugins()['segments']
|
||||
segment_plugin = directory.get_plugin('segments')
|
||||
segment = segment_plugin.get_segment(
|
||||
context, payload['subnet']['segment_id'])
|
||||
network['candidate_hosts'] = segment['hosts']
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
import random
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
|
||||
|
@ -24,8 +25,6 @@ from neutron.api.rpc.agentnotifiers import utils as ag_utils
|
|||
from neutron.common import rpc as n_rpc
|
||||
from neutron.common import topics
|
||||
from neutron.common import utils
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants as service_constants
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -57,8 +56,7 @@ class L3AgentNotifyAPI(object):
|
|||
shuffle_agents):
|
||||
"""Notify changed routers to hosting l3 agents."""
|
||||
adminContext = context if context.is_admin else context.elevated()
|
||||
plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
plugin = directory.get_plugin(constants.L3)
|
||||
for router_id in router_ids:
|
||||
hosts = plugin.get_hosts_to_notify(adminContext, router_id)
|
||||
if shuffle_agents:
|
||||
|
@ -87,8 +85,7 @@ class L3AgentNotifyAPI(object):
|
|||
def _notification(self, context, method, router_ids, operation,
|
||||
shuffle_agents, schedule_routers=True):
|
||||
"""Notify all the agents that are hosting the routers."""
|
||||
plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
plugin = directory.get_plugin(constants.L3)
|
||||
if not plugin:
|
||||
LOG.error(_LE('No plugin for L3 routing registered. Cannot notify '
|
||||
'agents with the message %s'), method)
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
# under the License.
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
import six
|
||||
|
@ -21,8 +22,6 @@ from neutron.common import rpc as n_rpc
|
|||
from neutron.common import topics
|
||||
from neutron.common import utils
|
||||
from neutron.db import agentschedulers_db
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants as service_constants
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -38,8 +37,7 @@ class MeteringAgentNotifyAPI(object):
|
|||
def _agent_notification(self, context, method, routers):
|
||||
"""Notify l3 metering agents hosted by l3 agent hosts."""
|
||||
adminContext = context if context.is_admin else context.elevated()
|
||||
plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
plugin = directory.get_plugin(constants.L3)
|
||||
|
||||
l3_routers = {}
|
||||
state = agentschedulers_db.get_admin_state_up_filter()
|
||||
|
@ -74,8 +72,7 @@ class MeteringAgentNotifyAPI(object):
|
|||
|
||||
def _notification(self, context, method, routers):
|
||||
"""Notify all the agents that are hosting the routers."""
|
||||
plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
plugin = directory.get_plugin(constants.L3)
|
||||
if utils.is_extension_supported(
|
||||
plugin, constants.L3_AGENT_SCHEDULER_EXT_ALIAS):
|
||||
self._agent_notification(context, method, routers)
|
||||
|
|
|
@ -15,11 +15,11 @@ import copy
|
|||
import pprint
|
||||
import time
|
||||
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import importutils
|
||||
|
||||
from neutron.api.rpc.callbacks import exceptions
|
||||
from neutron import manager
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -196,7 +196,7 @@ class CachedResourceConsumerTracker(object):
|
|||
|
||||
def _update_consumer_versions(self):
|
||||
new_tracker = ResourceConsumerTracker()
|
||||
neutron_plugin = manager.NeutronManager.get_plugin()
|
||||
neutron_plugin = directory.get_plugin()
|
||||
agents_db = _import_agents_db()
|
||||
# If you use RPC callbacks, your plugin needs to implement
|
||||
# AgentsDbMixin so that we know which resource versions your
|
||||
|
|
|
@ -19,6 +19,7 @@ import operator
|
|||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_log import log as logging
|
||||
|
@ -34,7 +35,6 @@ from neutron.db import api as db_api
|
|||
from neutron.db import provisioning_blocks
|
||||
from neutron.extensions import portbindings
|
||||
from neutron.extensions import segment as segment_ext
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import utils as p_utils
|
||||
from neutron.quota import resource_registry
|
||||
|
||||
|
@ -79,7 +79,7 @@ class DhcpRpcCallback(object):
|
|||
def _get_active_networks(self, context, **kwargs):
|
||||
"""Retrieve and return a list of the active networks."""
|
||||
host = kwargs.get('host')
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
if utils.is_extension_supported(
|
||||
plugin, constants.DHCP_AGENT_SCHEDULER_EXT_ALIAS):
|
||||
if cfg.CONF.network_auto_schedule:
|
||||
|
@ -140,7 +140,7 @@ class DhcpRpcCallback(object):
|
|||
host = kwargs.get('host')
|
||||
LOG.debug('get_active_networks_info from %s', host)
|
||||
networks = self._get_active_networks(context, **kwargs)
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
filters = {'network_id': [network['id'] for network in networks]}
|
||||
ports = plugin.get_ports(context, filters=filters)
|
||||
filters['enable_dhcp'] = [True]
|
||||
|
@ -153,7 +153,7 @@ class DhcpRpcCallback(object):
|
|||
# inside a segment. If the segment service plugin is loaded and
|
||||
# there are active dhcp enabled subnets, then filter out the subnets
|
||||
# that are not on the host's segment.
|
||||
seg_plug = manager.NeutronManager.get_service_plugins().get(
|
||||
seg_plug = directory.get_plugin(
|
||||
segment_ext.SegmentPluginBase.get_plugin_type())
|
||||
seg_subnets = [subnet for subnet in subnets
|
||||
if subnet.get('segment_id')]
|
||||
|
@ -189,7 +189,7 @@ class DhcpRpcCallback(object):
|
|||
LOG.debug('Network %(network_id)s requested from '
|
||||
'%(host)s', {'network_id': network_id,
|
||||
'host': host})
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
try:
|
||||
network = plugin.get_network(context, network_id)
|
||||
except exceptions.NetworkNotFound:
|
||||
|
@ -198,7 +198,7 @@ class DhcpRpcCallback(object):
|
|||
return
|
||||
filters = dict(network_id=[network_id])
|
||||
subnets = plugin.get_subnets(context, filters=filters)
|
||||
seg_plug = manager.NeutronManager.get_service_plugins().get(
|
||||
seg_plug = directory.get_plugin(
|
||||
segment_ext.SegmentPluginBase.get_plugin_type())
|
||||
if seg_plug and subnets:
|
||||
seg_subnets = [subnet for subnet in subnets
|
||||
|
@ -231,7 +231,7 @@ class DhcpRpcCallback(object):
|
|||
LOG.debug('DHCP port deletion for %(network_id)s request from '
|
||||
'%(host)s',
|
||||
{'network_id': network_id, 'host': host})
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
plugin.delete_ports_by_device_id(context, device_id, network_id)
|
||||
|
||||
@db_api.retry_db_errors
|
||||
|
@ -255,7 +255,7 @@ class DhcpRpcCallback(object):
|
|||
port['port'][portbindings.HOST_ID] = host
|
||||
if 'mac_address' not in port['port']:
|
||||
port['port']['mac_address'] = constants.ATTR_NOT_SPECIFIED
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
return self._port_action(plugin, context, port, 'create_port')
|
||||
|
||||
@db_api.retry_db_errors
|
||||
|
@ -265,7 +265,7 @@ class DhcpRpcCallback(object):
|
|||
port = kwargs.get('port')
|
||||
port['id'] = kwargs.get('port_id')
|
||||
port['port'][portbindings.HOST_ID] = host
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
try:
|
||||
old_port = plugin.get_port(context, port['id'])
|
||||
if (old_port['device_id'] != n_const.DEVICE_ID_RESERVED_DHCP_PORT
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_log import helpers as log_helpers
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
|
@ -20,7 +21,6 @@ import oslo_messaging
|
|||
from neutron.common import constants
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron.common import topics
|
||||
from neutron import manager
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -85,7 +85,7 @@ class DVRServerRpcCallback(object):
|
|||
@property
|
||||
def plugin(self):
|
||||
if not getattr(self, '_plugin', None):
|
||||
self._plugin = manager.NeutronManager.get_plugin()
|
||||
self._plugin = directory.get_plugin()
|
||||
return self._plugin
|
||||
|
||||
def get_dvr_mac_address_list(self, context):
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
|
@ -26,8 +27,6 @@ from neutron import context as neutron_context
|
|||
from neutron.db import api as db_api
|
||||
from neutron.extensions import l3
|
||||
from neutron.extensions import portbindings
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants as plugin_constants
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -52,14 +51,13 @@ class L3RpcCallback(object):
|
|||
@property
|
||||
def plugin(self):
|
||||
if not hasattr(self, '_plugin'):
|
||||
self._plugin = manager.NeutronManager.get_plugin()
|
||||
self._plugin = directory.get_plugin()
|
||||
return self._plugin
|
||||
|
||||
@property
|
||||
def l3plugin(self):
|
||||
if not hasattr(self, '_l3plugin'):
|
||||
self._l3plugin = manager.NeutronManager.get_service_plugins()[
|
||||
plugin_constants.L3_ROUTER_NAT]
|
||||
self._l3plugin = directory.get_plugin(constants.L3)
|
||||
return self._l3plugin
|
||||
|
||||
def get_router_ids(self, context, host):
|
||||
|
@ -209,8 +207,7 @@ class L3RpcCallback(object):
|
|||
return net_id
|
||||
|
||||
def get_service_plugin_list(self, context, **kwargs):
|
||||
plugins = manager.NeutronManager.get_service_plugins()
|
||||
return plugins.keys()
|
||||
return directory.get_plugins().keys()
|
||||
|
||||
@db_api.retry_db_errors
|
||||
def update_floatingip_statuses(self, context, router_id, fip_statuses):
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
# 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.common import constants
|
||||
from neutron import manager
|
||||
|
||||
|
||||
class MetadataRpcCallback(object):
|
||||
|
@ -36,7 +36,7 @@ class MetadataRpcCallback(object):
|
|||
@property
|
||||
def plugin(self):
|
||||
if not hasattr(self, '_plugin'):
|
||||
self._plugin = manager.NeutronManager.get_plugin()
|
||||
self._plugin = directory.get_plugin()
|
||||
return self._plugin
|
||||
|
||||
def get_ports(self, context, filters):
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
|
||||
|
@ -20,7 +21,6 @@ from neutron.common import constants
|
|||
from neutron.common import rpc as n_rpc
|
||||
from neutron.common import topics
|
||||
from neutron.common import utils
|
||||
from neutron import manager
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -74,7 +74,7 @@ class SecurityGroupServerRpcCallback(object):
|
|||
|
||||
@property
|
||||
def plugin(self):
|
||||
return manager.NeutronManager.get_plugin()
|
||||
return directory.get_plugin()
|
||||
|
||||
def _get_devices_info(self, context, devices):
|
||||
return dict(
|
||||
|
|
|
@ -13,13 +13,13 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron.api.v2 import base
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants
|
||||
from neutron.quota import resource_registry
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -73,10 +73,7 @@ def build_resource_info(plural_mappings, resource_map, which_service,
|
|||
which_service = constants.CORE
|
||||
if action_map is None:
|
||||
action_map = {}
|
||||
if which_service != constants.CORE:
|
||||
plugin = manager.NeutronManager.get_service_plugins()[which_service]
|
||||
else:
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin(which_service)
|
||||
path_prefix = getattr(plugin, "path_prefix", "")
|
||||
LOG.debug('Service %(service)s assigned prefix: %(prefix)s',
|
||||
{'service': which_service, 'prefix': path_prefix})
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# limitations under the License.
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_service import wsgi as base_wsgi
|
||||
import routes as routes_mapper
|
||||
|
@ -73,7 +74,8 @@ class APIRouter(base_wsgi.Router):
|
|||
|
||||
def __init__(self, **local_config):
|
||||
mapper = routes_mapper.Mapper()
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
manager.init()
|
||||
plugin = directory.get_plugin()
|
||||
ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
|
||||
ext_mgr.extend_resources("2.0", attributes.RESOURCE_ATTRIBUTE_MAP)
|
||||
|
||||
|
|
|
@ -19,11 +19,13 @@ subnets.
|
|||
|
||||
import sys
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron.common import config
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron import context
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -31,9 +33,9 @@ def main():
|
|||
config.setup_logging()
|
||||
|
||||
cxt = context.get_admin_context()
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
l3_plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
constants.L3_ROUTER_NAT)
|
||||
manager.init()
|
||||
plugin = directory.get_plugin()
|
||||
l3_plugin = directory.get_plugin(constants.L3)
|
||||
notifier = n_rpc.get_notifier('network')
|
||||
for network in plugin.get_networks(cxt):
|
||||
notifier.info(cxt, 'network.exists', {'network': network})
|
||||
|
|
|
@ -13,10 +13,11 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron.common import exceptions as n_exc
|
||||
from neutron.core_extensions import base
|
||||
from neutron.db import api as db_api
|
||||
from neutron import manager
|
||||
from neutron.objects.qos import policy as policy_object
|
||||
from neutron.plugins.common import constants as plugin_constants
|
||||
from neutron.services.qos import qos_consts
|
||||
|
@ -27,8 +28,8 @@ class QosCoreResourceExtension(base.CoreResourceExtension):
|
|||
@property
|
||||
def plugin_loaded(self):
|
||||
if not hasattr(self, '_plugin_loaded'):
|
||||
service_plugins = manager.NeutronManager.get_service_plugins()
|
||||
self._plugin_loaded = plugin_constants.QOS in service_plugins
|
||||
self._plugin_loaded = (
|
||||
plugin_constants.QOS in directory.get_plugins())
|
||||
return self._plugin_loaded
|
||||
|
||||
def _get_policy_obj(self, context, policy_id):
|
||||
|
|
|
@ -19,6 +19,7 @@ import debtcollector
|
|||
from eventlet import greenthread
|
||||
from neutron_lib.api import converters
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
|
@ -43,7 +44,6 @@ from neutron.db import api as db_api
|
|||
from neutron.db.models import agent as agent_model
|
||||
from neutron.extensions import agent as ext_agent
|
||||
from neutron.extensions import availability_zone as az_ext
|
||||
from neutron import manager
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -455,7 +455,7 @@ class AgentExtRpcCallback(object):
|
|||
"server start timestamp: %(server_time)s", log_dict)
|
||||
return
|
||||
if not self.plugin:
|
||||
self.plugin = manager.NeutronManager.get_plugin()
|
||||
self.plugin = directory.get_plugin()
|
||||
agent_status, agent_state = self.plugin.create_or_update_agent(
|
||||
context, agent_state)
|
||||
self._update_local_agent_resource_versions(context, agent_state)
|
||||
|
|
|
@ -20,6 +20,7 @@ from neutron_lib.api import validators
|
|||
from neutron_lib import constants
|
||||
from neutron_lib.db import utils as db_utils
|
||||
from neutron_lib import exceptions as exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as os_db_exc
|
||||
from oslo_db.sqlalchemy import utils as sa_utils
|
||||
|
@ -55,11 +56,9 @@ from neutron.extensions import l3
|
|||
from neutron import ipam
|
||||
from neutron.ipam import exceptions as ipam_exc
|
||||
from neutron.ipam import subnet_alloc
|
||||
from neutron import manager
|
||||
from neutron import neutron_plugin_base_v2
|
||||
from neutron.objects import base as base_obj
|
||||
from neutron.objects import subnetpool as subnetpool_obj
|
||||
from neutron.plugins.common import constants as service_constants
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -584,8 +583,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||
raise exc.BadRequest(resource='subnets', msg=reason)
|
||||
|
||||
def _update_router_gw_ports(self, context, network, subnet):
|
||||
l3plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
l3plugin = directory.get_plugin(constants.L3)
|
||||
if l3plugin:
|
||||
gw_ports = self._get_router_gw_ports_by_network(context,
|
||||
network['id'])
|
||||
|
@ -1347,9 +1345,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||
except l3.RouterNotFound:
|
||||
return
|
||||
else:
|
||||
l3plugin = (
|
||||
manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT))
|
||||
l3plugin = directory.get_plugin(constants.L3)
|
||||
if l3plugin:
|
||||
try:
|
||||
ctx_admin = context.elevated()
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_log import helpers as log_helpers
|
||||
|
@ -33,7 +34,6 @@ from neutron.db.models import dvr as dvr_models
|
|||
from neutron.db import models_v2
|
||||
from neutron.extensions import dvr as ext_dvr
|
||||
from neutron.extensions import portbindings
|
||||
from neutron import manager
|
||||
|
||||
_deprecate._moved_global('DistributedVirtualRouterMacAddress',
|
||||
new_module=dvr_models)
|
||||
|
@ -61,7 +61,7 @@ cfg.CONF.register_opts(dvr_mac_address_opts)
|
|||
def _delete_mac_associated_with_agent(resource, event, trigger, context, agent,
|
||||
**kwargs):
|
||||
host = agent['host']
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
if [a for a in plugin.get_agents(context, filters={'host': [host]})
|
||||
if a['id'] != agent['id']]:
|
||||
# there are still agents on this host, don't mess with the mac entry
|
||||
|
@ -98,7 +98,7 @@ class DVRDbMixin(ext_dvr.DVRMacAddressPluginBase):
|
|||
return self._plugin
|
||||
except AttributeError:
|
||||
pass
|
||||
self._plugin = manager.NeutronManager.get_plugin()
|
||||
self._plugin = directory.get_plugin()
|
||||
return self._plugin
|
||||
|
||||
def _get_dvr_mac_address_by_host(self, context, host):
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
# under the License.
|
||||
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import constants as lib_constants
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from sqlalchemy.orm import exc
|
||||
from sqlalchemy.sql import expression as expr
|
||||
|
||||
|
@ -34,11 +35,9 @@ from neutron.db import models_v2
|
|||
from neutron.db import rbac_db_models as rbac_db
|
||||
from neutron.extensions import external_net
|
||||
from neutron.extensions import rbac as rbac_ext
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants as service_constants
|
||||
|
||||
|
||||
DEVICE_OWNER_ROUTER_GW = lib_constants.DEVICE_OWNER_ROUTER_GW
|
||||
DEVICE_OWNER_ROUTER_GW = constants.DEVICE_OWNER_ROUTER_GW
|
||||
|
||||
_deprecate._moved_global('ExternalNetwork', new_module=ext_net_models)
|
||||
|
||||
|
@ -180,8 +179,7 @@ class External_net_db_mixin(object):
|
|||
net_data[external_net.EXTERNAL] = False
|
||||
|
||||
def _process_l3_delete(self, context, network_id):
|
||||
l3plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
l3plugin = directory.get_plugin(constants.L3)
|
||||
if l3plugin:
|
||||
l3plugin.delete_disassociated_floatingips(context, network_id)
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# under the License.
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_log import log as logging
|
||||
|
@ -36,8 +37,6 @@ from neutron.db.models import l3_attrs
|
|||
from neutron.db.models import l3agent as rb_model
|
||||
from neutron.extensions import l3agentscheduler
|
||||
from neutron.extensions import router_availability_zone as router_az
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants as service_constants
|
||||
|
||||
|
||||
_deprecate._moved_global('RouterL3AgentBinding',
|
||||
|
@ -169,8 +168,7 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
|
|||
router_id = router['id']
|
||||
agent_id = agent['id']
|
||||
if self.router_scheduler:
|
||||
plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
plugin = directory.get_plugin(constants.L3)
|
||||
try:
|
||||
if router.get('ha'):
|
||||
self.router_scheduler.create_ha_port_and_bind(
|
||||
|
@ -217,8 +215,7 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
|
|||
self._unbind_router(context, router_id, agent_id)
|
||||
|
||||
router = self.get_router(context, router_id)
|
||||
plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
plugin = directory.get_plugin(constants.L3)
|
||||
if router.get('ha'):
|
||||
plugin.delete_ha_interfaces_on_host(context, router_id, agent.host)
|
||||
# NOTE(Swami): Need to verify if there are DVR serviceable
|
||||
|
|
|
@ -18,8 +18,9 @@ import itertools
|
|||
from debtcollector import removals
|
||||
import netaddr
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import constants as lib_constants
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
from oslo_utils import uuidutils
|
||||
|
@ -46,8 +47,6 @@ from neutron.db import models_v2
|
|||
from neutron.db import standardattrdescription_db as st_attr
|
||||
from neutron.extensions import external_net
|
||||
from neutron.extensions import l3
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants
|
||||
from neutron.plugins.common import utils as p_utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -58,10 +57,10 @@ _deprecate._moved_global('Router', new_module=l3_models)
|
|||
_deprecate._moved_global('FloatingIP', new_module=l3_models)
|
||||
|
||||
|
||||
DEVICE_OWNER_HA_REPLICATED_INT = lib_constants.DEVICE_OWNER_HA_REPLICATED_INT
|
||||
DEVICE_OWNER_ROUTER_INTF = lib_constants.DEVICE_OWNER_ROUTER_INTF
|
||||
DEVICE_OWNER_ROUTER_GW = lib_constants.DEVICE_OWNER_ROUTER_GW
|
||||
DEVICE_OWNER_FLOATINGIP = lib_constants.DEVICE_OWNER_FLOATINGIP
|
||||
DEVICE_OWNER_HA_REPLICATED_INT = constants.DEVICE_OWNER_HA_REPLICATED_INT
|
||||
DEVICE_OWNER_ROUTER_INTF = constants.DEVICE_OWNER_ROUTER_INTF
|
||||
DEVICE_OWNER_ROUTER_GW = constants.DEVICE_OWNER_ROUTER_GW
|
||||
DEVICE_OWNER_FLOATINGIP = constants.DEVICE_OWNER_FLOATINGIP
|
||||
EXTERNAL_GW_INFO = l3.EXTERNAL_GW_INFO
|
||||
|
||||
# Maps API field to DB column
|
||||
|
@ -108,7 +107,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
|||
|
||||
@property
|
||||
def _core_plugin(self):
|
||||
return manager.NeutronManager.get_plugin()
|
||||
return directory.get_plugin()
|
||||
|
||||
def _get_router(self, context, router_id):
|
||||
try:
|
||||
|
@ -224,13 +223,13 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
|||
@db_api.retry_if_session_inactive()
|
||||
def update_router(self, context, id, router):
|
||||
r = router['router']
|
||||
gw_info = r.pop(EXTERNAL_GW_INFO, lib_constants.ATTR_NOT_SPECIFIED)
|
||||
gw_info = r.pop(EXTERNAL_GW_INFO, constants.ATTR_NOT_SPECIFIED)
|
||||
original = self.get_router(context, id)
|
||||
# check whether router needs and can be rescheduled to the proper
|
||||
# l3 agent (associated with given external network);
|
||||
# do check before update in DB as an exception will be raised
|
||||
# in case no proper l3 agent found
|
||||
if gw_info != lib_constants.ATTR_NOT_SPECIFIED:
|
||||
if gw_info != constants.ATTR_NOT_SPECIFIED:
|
||||
candidates = self._check_router_needs_rescheduling(
|
||||
context, id, gw_info)
|
||||
# Update the gateway outside of the DB update since it involves L2
|
||||
|
@ -241,8 +240,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
|||
candidates = None
|
||||
router_db = self._update_router_db(context, id, r)
|
||||
if candidates:
|
||||
l3_plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
constants.L3_ROUTER_NAT)
|
||||
l3_plugin = directory.get_plugin(constants.L3)
|
||||
l3_plugin.reschedule_router(context, id, candidates)
|
||||
updated = self._make_router_dict(router_db)
|
||||
registry.notify(resources.ROUTER, events.AFTER_UPDATE, self,
|
||||
|
@ -278,11 +276,10 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
|||
|
||||
# first get plugin supporting l3 agent scheduling
|
||||
# (either l3 service plugin or core_plugin)
|
||||
l3_plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
constants.L3_ROUTER_NAT)
|
||||
l3_plugin = directory.get_plugin(constants.L3)
|
||||
if (not utils.is_extension_supported(
|
||||
l3_plugin,
|
||||
lib_constants.L3_AGENT_SCHEDULER_EXT_ALIAS) or
|
||||
constants.L3_AGENT_SCHEDULER_EXT_ALIAS) or
|
||||
l3_plugin.router_scheduler is None):
|
||||
# that might mean that we are dealing with non-agent-based
|
||||
# implementation of l3 services
|
||||
|
@ -321,7 +318,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
|||
# Port has no 'tenant-id', as it is hidden from user
|
||||
port_data = {'tenant_id': '', # intentionally not set
|
||||
'network_id': network_id,
|
||||
'fixed_ips': ext_ips or lib_constants.ATTR_NOT_SPECIFIED,
|
||||
'fixed_ips': ext_ips or constants.ATTR_NOT_SPECIFIED,
|
||||
'device_id': router['id'],
|
||||
'device_owner': DEVICE_OWNER_ROUTER_GW,
|
||||
'admin_state_up': True,
|
||||
|
@ -1023,11 +1020,11 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
|||
RouterPort.router_id, models_v2.IPAllocation.ip_address).join(
|
||||
models_v2.Port, models_v2.IPAllocation).filter(
|
||||
models_v2.Port.network_id == internal_port['network_id'],
|
||||
RouterPort.port_type.in_(lib_constants.ROUTER_INTERFACE_OWNERS),
|
||||
RouterPort.port_type.in_(constants.ROUTER_INTERFACE_OWNERS),
|
||||
models_v2.IPAllocation.subnet_id == internal_subnet['id']
|
||||
).join(gw_port, gw_port.device_id == RouterPort.router_id).filter(
|
||||
gw_port.network_id == external_network_id,
|
||||
gw_port.device_owner == lib_constants.DEVICE_OWNER_ROUTER_GW
|
||||
gw_port.device_owner == constants.DEVICE_OWNER_ROUTER_GW
|
||||
).distinct()
|
||||
|
||||
first_router_id = None
|
||||
|
@ -1172,7 +1169,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
|||
gw_port = router.gw_port
|
||||
for fixed_ip in gw_port.fixed_ips:
|
||||
addr = netaddr.IPAddress(fixed_ip.ip_address)
|
||||
if addr.version == lib_constants.IP_VERSION_4:
|
||||
if addr.version == constants.IP_VERSION_4:
|
||||
next_hop = fixed_ip.ip_address
|
||||
break
|
||||
return {'fixed_ip_address': internal_ip_address,
|
||||
|
@ -1190,7 +1187,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
|||
return any(s.ip_version == 4 for s in net.subnets)
|
||||
|
||||
def _create_floatingip(self, context, floatingip,
|
||||
initial_status=lib_constants.FLOATINGIP_STATUS_ACTIVE):
|
||||
initial_status=constants.FLOATINGIP_STATUS_ACTIVE):
|
||||
fip = floatingip['floatingip']
|
||||
fip_id = uuidutils.generate_uuid()
|
||||
|
||||
|
@ -1212,7 +1209,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
|||
'admin_state_up': True,
|
||||
'device_id': 'PENDING',
|
||||
'device_owner': DEVICE_OWNER_FLOATINGIP,
|
||||
'status': lib_constants.PORT_STATUS_NOTAPPLICABLE,
|
||||
'status': constants.PORT_STATUS_NOTAPPLICABLE,
|
||||
'name': ''}
|
||||
if fip.get('floating_ip_address'):
|
||||
port['fixed_ips'] = [
|
||||
|
@ -1278,7 +1275,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
|||
|
||||
@db_api.retry_if_session_inactive()
|
||||
def create_floatingip(self, context, floatingip,
|
||||
initial_status=lib_constants.FLOATINGIP_STATUS_ACTIVE):
|
||||
initial_status=constants.FLOATINGIP_STATUS_ACTIVE):
|
||||
return self._create_floatingip(context, floatingip, initial_status)
|
||||
|
||||
def _update_floatingip(self, context, id, floatingip):
|
||||
|
@ -1629,8 +1626,8 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
|||
|
||||
port['subnets'] = []
|
||||
port['extra_subnets'] = []
|
||||
port['address_scopes'] = {lib_constants.IP_VERSION_4: None,
|
||||
lib_constants.IP_VERSION_6: None}
|
||||
port['address_scopes'] = {constants.IP_VERSION_4: None,
|
||||
constants.IP_VERSION_6: None}
|
||||
|
||||
scopes = {}
|
||||
for subnet in subnets_by_network[port['network_id']]:
|
||||
|
@ -1665,18 +1662,18 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
|||
for floating_ip in floating_ips:
|
||||
router = routers_dict.get(floating_ip['router_id'])
|
||||
if router:
|
||||
router_floatingips = router.get(lib_constants.FLOATINGIP_KEY,
|
||||
router_floatingips = router.get(constants.FLOATINGIP_KEY,
|
||||
[])
|
||||
router_floatingips.append(floating_ip)
|
||||
router[lib_constants.FLOATINGIP_KEY] = router_floatingips
|
||||
router[constants.FLOATINGIP_KEY] = router_floatingips
|
||||
|
||||
def _process_interfaces(self, routers_dict, interfaces):
|
||||
for interface in interfaces:
|
||||
router = routers_dict.get(interface['device_id'])
|
||||
if router:
|
||||
router_interfaces = router.get(lib_constants.INTERFACE_KEY, [])
|
||||
router_interfaces = router.get(constants.INTERFACE_KEY, [])
|
||||
router_interfaces.append(interface)
|
||||
router[lib_constants.INTERFACE_KEY] = router_interfaces
|
||||
router[constants.INTERFACE_KEY] = router_interfaces
|
||||
|
||||
def _get_router_info_list(self, context, router_ids=None, active=None,
|
||||
device_owners=None):
|
||||
|
@ -1803,7 +1800,7 @@ class L3_NAT_db_mixin(L3_NAT_dbonly_mixin, L3RpcNotifierMixin):
|
|||
return router_interface_info
|
||||
|
||||
def create_floatingip(self, context, floatingip,
|
||||
initial_status=lib_constants.FLOATINGIP_STATUS_ACTIVE):
|
||||
initial_status=constants.FLOATINGIP_STATUS_ACTIVE):
|
||||
floatingip_dict = super(L3_NAT_db_mixin, self).create_floatingip(
|
||||
context, floatingip, initial_status)
|
||||
router_id = floatingip_dict['router_id']
|
||||
|
@ -1851,8 +1848,7 @@ def _prevent_l3_port_delete_callback(resource, event, trigger, **kwargs):
|
|||
context = kwargs['context']
|
||||
port_id = kwargs['port_id']
|
||||
port_check = kwargs['port_check']
|
||||
l3plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
constants.L3_ROUTER_NAT)
|
||||
l3plugin = directory.get_plugin(constants.L3)
|
||||
if l3plugin and port_check:
|
||||
l3plugin.prevent_l3_port_deletion(context, port_id)
|
||||
|
||||
|
@ -1860,14 +1856,12 @@ def _prevent_l3_port_delete_callback(resource, event, trigger, **kwargs):
|
|||
def _notify_routers_callback(resource, event, trigger, **kwargs):
|
||||
context = kwargs['context']
|
||||
router_ids = kwargs['router_ids']
|
||||
l3plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
constants.L3_ROUTER_NAT)
|
||||
l3plugin = directory.get_plugin(constants.L3)
|
||||
l3plugin.notify_routers_updated(context, router_ids)
|
||||
|
||||
|
||||
def _notify_subnet_gateway_ip_update(resource, event, trigger, **kwargs):
|
||||
l3plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
constants.L3_ROUTER_NAT)
|
||||
l3plugin = directory.get_plugin(constants.L3)
|
||||
if not l3plugin:
|
||||
return
|
||||
context = kwargs['context']
|
||||
|
@ -1875,7 +1869,7 @@ def _notify_subnet_gateway_ip_update(resource, event, trigger, **kwargs):
|
|||
subnet_id = kwargs['subnet_id']
|
||||
query = context.session.query(models_v2.Port).filter_by(
|
||||
network_id=network_id,
|
||||
device_owner=lib_constants.DEVICE_OWNER_ROUTER_GW)
|
||||
device_owner=constants.DEVICE_OWNER_ROUTER_GW)
|
||||
query = query.join(models_v2.Port.fixed_ips).filter(
|
||||
models_v2.IPAllocation.subnet_id == subnet_id)
|
||||
router_ids = set(port['device_id'] for port in query)
|
||||
|
@ -1899,8 +1893,7 @@ def _notify_subnetpool_address_scope_update(resource, event,
|
|||
query = query.distinct()
|
||||
|
||||
router_ids = [r[0] for r in query]
|
||||
l3plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
constants.L3_ROUTER_NAT)
|
||||
l3plugin = directory.get_plugin(constants.L3)
|
||||
l3plugin.notify_routers_updated(context, router_ids)
|
||||
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import collections
|
|||
from neutron_lib.api import validators
|
||||
from neutron_lib import constants as const
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_log import helpers as log_helper
|
||||
from oslo_log import log as logging
|
||||
|
@ -39,8 +40,6 @@ from neutron.db import models_v2
|
|||
from neutron.extensions import l3
|
||||
from neutron.extensions import portbindings
|
||||
from neutron.ipam import utils as ipam_utils
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants
|
||||
from neutron.plugins.common import utils as p_utils
|
||||
|
||||
|
||||
|
@ -505,8 +504,7 @@ class L3_NAT_with_dvr_db_mixin(l3_db.L3_NAT_db_mixin,
|
|||
L3_NAT_with_dvr_db_mixin, self).remove_router_interface(
|
||||
context, router_id, interface_info)
|
||||
|
||||
plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
constants.L3_ROUTER_NAT)
|
||||
plugin = directory.get_plugin(const.L3)
|
||||
router_hosts_before = plugin._get_dvr_hosts_for_router(
|
||||
context, router_id)
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# under the License.
|
||||
|
||||
from neutron_lib import constants as n_const
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_log import log as logging
|
||||
from sqlalchemy import or_
|
||||
|
||||
|
@ -27,8 +28,6 @@ from neutron.db import l3_agentschedulers_db as l3agent_sch_db
|
|||
from neutron.db.models import l3agent as rb_model
|
||||
from neutron.db import models_v2
|
||||
from neutron.extensions import portbindings
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants as service_constants
|
||||
from neutron.plugins.ml2 import db as ml2_db
|
||||
from neutron.plugins.ml2 import models as ml2_models
|
||||
|
||||
|
@ -95,8 +94,7 @@ class L3_DVRsch_db_mixin(l3agent_sch_db.L3AgentSchedulerDbMixin):
|
|||
# Make sure we create the floatingip agent gateway port
|
||||
# for the destination node if fip is associated with this
|
||||
# fixed port
|
||||
l3plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
l3plugin = directory.get_plugin(n_const.L3)
|
||||
(
|
||||
l3plugin.
|
||||
check_for_fip_and_create_agent_gw_port_on_host_if_not_exists(
|
||||
|
@ -372,8 +370,7 @@ def _notify_l3_agent_new_port(resource, event, trigger, **kwargs):
|
|||
return
|
||||
|
||||
if n_utils.is_dvr_serviced(port['device_owner']):
|
||||
l3plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
l3plugin = directory.get_plugin(n_const.L3)
|
||||
context = kwargs['context']
|
||||
l3plugin.dvr_handle_new_service_port(context, port)
|
||||
l3plugin.update_arp_entry_for_dvr_service_port(context, port)
|
||||
|
@ -382,8 +379,7 @@ def _notify_l3_agent_new_port(resource, event, trigger, **kwargs):
|
|||
def _notify_port_delete(event, resource, trigger, **kwargs):
|
||||
context = kwargs['context']
|
||||
port = kwargs['port']
|
||||
l3plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
l3plugin = directory.get_plugin(n_const.L3)
|
||||
if port:
|
||||
port_host = port.get(portbindings.HOST_ID)
|
||||
allowed_address_pairs_list = port.get('allowed_address_pairs')
|
||||
|
@ -406,8 +402,7 @@ def _notify_l3_agent_port_update(resource, event, trigger, **kwargs):
|
|||
original_device_owner = original_port.get('device_owner', '')
|
||||
new_device_owner = new_port.get('device_owner', '')
|
||||
is_new_device_dvr_serviced = n_utils.is_dvr_serviced(new_device_owner)
|
||||
l3plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
l3plugin = directory.get_plugin(n_const.L3)
|
||||
context = kwargs['context']
|
||||
is_port_no_longer_serviced = (
|
||||
n_utils.is_dvr_serviced(original_device_owner) and
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
# under the License.
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import directory
|
||||
from sqlalchemy import func
|
||||
from sqlalchemy import sql
|
||||
|
||||
|
@ -25,8 +26,6 @@ from neutron.db.models import l3 as l3_models
|
|||
from neutron.db.models import l3_attrs
|
||||
from neutron.db.models import l3agent as rb_model
|
||||
from neutron.extensions import portbindings
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants as service_constants
|
||||
|
||||
|
||||
class L3_HA_scheduler_db_mixin(l3_sch_db.AZL3AgentSchedulerDbMixin):
|
||||
|
@ -103,8 +102,7 @@ def _notify_l3_agent_ha_port_update(resource, event, trigger, **kwargs):
|
|||
if (new_device_owner == constants.DEVICE_OWNER_ROUTER_HA_INTF and
|
||||
new_port['status'] == constants.PORT_STATUS_ACTIVE and
|
||||
original_port['status'] != new_port['status']):
|
||||
l3plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
l3plugin = directory.get_plugin(constants.L3)
|
||||
l3plugin.l3_rpc_notifier.routers_updated_on_host(
|
||||
context, [new_port['device_id']], host)
|
||||
|
||||
|
|
|
@ -13,13 +13,12 @@
|
|||
# under the License.
|
||||
|
||||
from neutron_lib import constants as consts
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
|
||||
from neutron._i18n import _LE
|
||||
from neutron.common import utils
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants as service_constants
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -32,8 +31,7 @@ class MeteringRpcCallbacks(object):
|
|||
self.meter_plugin = meter_plugin
|
||||
|
||||
def get_sync_data_metering(self, context, **kwargs):
|
||||
l3_plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
l3_plugin = directory.get_plugin(consts.L3)
|
||||
if not l3_plugin:
|
||||
return
|
||||
|
||||
|
|
|
@ -17,13 +17,13 @@ import abc
|
|||
|
||||
from neutron_lib.db import model_base
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.ext import declarative
|
||||
from sqlalchemy.orm import validates
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron import manager
|
||||
|
||||
|
||||
ACCESS_SHARED = 'access_as_shared'
|
||||
|
@ -97,7 +97,7 @@ class NetworkRBAC(RBACColumns, model_base.BASEV2):
|
|||
|
||||
def get_valid_actions(self):
|
||||
actions = (ACCESS_SHARED,)
|
||||
pl = manager.NeutronManager.get_plugin()
|
||||
pl = directory.get_plugin()
|
||||
if 'external-net' in pl.supported_extension_aliases:
|
||||
actions += (ACCESS_EXTERNAL,)
|
||||
return actions
|
||||
|
|
|
@ -17,13 +17,13 @@ import abc
|
|||
from neutron_lib.api import converters
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions as nexception
|
||||
from neutron_lib.plugins import directory
|
||||
import six
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.api import extensions
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.api.v2 import base
|
||||
from neutron import manager
|
||||
|
||||
ADDRESS_SCOPE = 'address_scope'
|
||||
ADDRESS_SCOPES = '%ss' % ADDRESS_SCOPE
|
||||
|
@ -118,7 +118,7 @@ class Address_scope(extensions.ExtensionDescriptor):
|
|||
"""Returns Ext Resources."""
|
||||
my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
|
||||
attr.PLURALS.update(dict(my_plurals))
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
collection_name = ADDRESS_SCOPES.replace('_', '-')
|
||||
params = RESOURCE_ATTRIBUTE_MAP.get(ADDRESS_SCOPES, dict())
|
||||
controller = base.create_resource(collection_name,
|
||||
|
|
|
@ -17,13 +17,13 @@ import abc
|
|||
|
||||
from neutron_lib.api import converters
|
||||
from neutron_lib import exceptions
|
||||
from neutron_lib.plugins import directory
|
||||
import six
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.api import extensions
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.api.v2 import base
|
||||
from neutron import manager
|
||||
|
||||
|
||||
# Attribute Map
|
||||
|
@ -100,7 +100,7 @@ class Agent(extensions.ExtensionDescriptor):
|
|||
"""Returns Ext Resources."""
|
||||
my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
|
||||
attr.PLURALS.update(dict(my_plurals))
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
params = RESOURCE_ATTRIBUTE_MAP.get(RESOURCE_NAME + 's')
|
||||
controller = base.create_resource(RESOURCE_NAME + 's',
|
||||
RESOURCE_NAME,
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
# under the License.
|
||||
|
||||
from neutron_lib.api import converters
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron.api.v2 import base
|
||||
from neutron import manager
|
||||
|
||||
RESOURCE_NAME = "auto_allocated_topology"
|
||||
COLLECTION_NAME = "auto_allocated_topologies"
|
||||
|
@ -67,8 +67,7 @@ class Auto_allocated_topology(extensions.ExtensionDescriptor):
|
|||
params = RESOURCE_ATTRIBUTE_MAP.get(COLLECTION_NAME, dict())
|
||||
controller = base.create_resource(COLLECTION_NAME,
|
||||
EXT_ALIAS,
|
||||
manager.NeutronManager.
|
||||
get_service_plugins()[EXT_ALIAS],
|
||||
directory.get_plugin(EXT_ALIAS),
|
||||
params, allow_bulk=False)
|
||||
return [extensions.ResourceExtension(EXT_ALIAS, controller)]
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import abc
|
|||
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import exceptions
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_serialization import jsonutils
|
||||
import six
|
||||
|
||||
|
@ -23,7 +24,6 @@ from neutron._i18n import _
|
|||
from neutron.api import extensions
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.api.v2 import base
|
||||
from neutron import manager
|
||||
|
||||
|
||||
AZ_HINTS_DB_LEN = 255
|
||||
|
@ -106,7 +106,7 @@ class Availability_zone(extensions.ExtensionDescriptor):
|
|||
"""Returns Ext Resources."""
|
||||
my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
|
||||
attr.PLURALS.update(dict(my_plurals))
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
params = RESOURCE_ATTRIBUTE_MAP.get(AVAILABILITY_ZONES)
|
||||
controller = base.create_resource(AVAILABILITY_ZONES,
|
||||
RESOURCE_NAME, plugin, params)
|
||||
|
|
|
@ -17,6 +17,7 @@ import abc
|
|||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions
|
||||
from neutron_lib.plugins import directory
|
||||
import six
|
||||
|
||||
from neutron._i18n import _
|
||||
|
@ -25,7 +26,6 @@ from neutron.api.v2 import base
|
|||
from neutron.api.v2 import resource
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron.extensions import agent
|
||||
from neutron import manager
|
||||
from neutron import policy
|
||||
from neutron import wsgi
|
||||
|
||||
|
@ -37,7 +37,7 @@ DHCP_AGENTS = DHCP_AGENT + 's'
|
|||
|
||||
class NetworkSchedulerController(wsgi.Controller):
|
||||
def index(self, request, **kwargs):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
policy.enforce(request.context,
|
||||
"get_%s" % DHCP_NETS,
|
||||
{})
|
||||
|
@ -45,7 +45,7 @@ class NetworkSchedulerController(wsgi.Controller):
|
|||
request.context, kwargs['agent_id'])
|
||||
|
||||
def create(self, request, body, **kwargs):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
policy.enforce(request.context,
|
||||
"create_%s" % DHCP_NET,
|
||||
{})
|
||||
|
@ -57,7 +57,7 @@ class NetworkSchedulerController(wsgi.Controller):
|
|||
return result
|
||||
|
||||
def delete(self, request, id, **kwargs):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
policy.enforce(request.context,
|
||||
"delete_%s" % DHCP_NET,
|
||||
{})
|
||||
|
@ -70,7 +70,7 @@ class NetworkSchedulerController(wsgi.Controller):
|
|||
|
||||
class DhcpAgentsHostingNetworkController(wsgi.Controller):
|
||||
def index(self, request, **kwargs):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
policy.enforce(request.context,
|
||||
"get_%s" % DHCP_AGENTS,
|
||||
{})
|
||||
|
|
|
@ -15,13 +15,13 @@
|
|||
from neutron_lib.api import converters
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import exceptions as nexception
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron._i18n import _
|
||||
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
|
||||
|
||||
|
||||
|
@ -74,8 +74,7 @@ class InvalidFlavorServiceType(nexception.InvalidInput):
|
|||
|
||||
def _validate_flavor_service_type(validate_type, valid_values=None):
|
||||
"""Ensure requested flavor service type plugin is loaded."""
|
||||
plugins = manager.NeutronManager.get_service_plugins()
|
||||
if validate_type not in plugins:
|
||||
if not directory.get_plugin(validate_type):
|
||||
raise InvalidFlavorServiceType(service_type=validate_type)
|
||||
|
||||
validators.add_validator('validate_flavor_service_type',
|
||||
|
@ -204,8 +203,7 @@ class Flavors(extensions.ExtensionDescriptor):
|
|||
plural_mappings,
|
||||
RESOURCE_ATTRIBUTE_MAP,
|
||||
constants.FLAVORS)
|
||||
plugin = manager.NeutronManager.get_service_plugins()[
|
||||
constants.FLAVORS]
|
||||
plugin = directory.get_plugin(constants.FLAVORS)
|
||||
for collection_name in SUB_RESOURCE_ATTRIBUTE_MAP:
|
||||
# Special handling needed for sub-resources with 'y' ending
|
||||
# (e.g. proxies -> proxy)
|
||||
|
|
|
@ -17,6 +17,7 @@ import abc
|
|||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
import webob.exc
|
||||
|
@ -27,8 +28,6 @@ from neutron.api.v2 import base
|
|||
from neutron.api.v2 import resource
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron.extensions import agent
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants as service_constants
|
||||
from neutron import policy
|
||||
from neutron import wsgi
|
||||
|
||||
|
@ -44,8 +43,7 @@ L3_AGENTS = L3_AGENT + 's'
|
|||
|
||||
class RouterSchedulerController(wsgi.Controller):
|
||||
def get_plugin(self):
|
||||
plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
plugin = directory.get_plugin(constants.L3)
|
||||
if not plugin:
|
||||
LOG.error(_LE('No plugin for L3 routing registered to handle '
|
||||
'router scheduling'))
|
||||
|
@ -87,8 +85,7 @@ class RouterSchedulerController(wsgi.Controller):
|
|||
|
||||
class L3AgentsHostingRouterController(wsgi.Controller):
|
||||
def get_plugin(self):
|
||||
plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
plugin = directory.get_plugin(constants.L3)
|
||||
if not plugin:
|
||||
LOG.error(_LE('No plugin for L3 routing registered to handle '
|
||||
'router scheduling'))
|
||||
|
|
|
@ -18,6 +18,7 @@ import itertools
|
|||
import re
|
||||
|
||||
from neutron_lib.api import converters
|
||||
from neutron_lib.plugins import directory
|
||||
import six
|
||||
|
||||
from neutron.api import extensions
|
||||
|
@ -25,7 +26,6 @@ from neutron.api.v2 import attributes as attr
|
|||
from neutron.api.v2 import base
|
||||
from neutron.api.v2 import resource_helper
|
||||
from neutron.common import constants as common_constants
|
||||
from neutron import manager
|
||||
from neutron.objects.qos import rule as rule_object
|
||||
from neutron.plugins.common import constants
|
||||
from neutron.services.qos import qos_consts
|
||||
|
@ -169,7 +169,7 @@ class Qos(extensions.ExtensionDescriptor):
|
|||
translate_name=True,
|
||||
allow_bulk=True)
|
||||
|
||||
plugin = manager.NeutronManager.get_service_plugins()[constants.QOS]
|
||||
plugin = directory.get_plugin(constants.QOS)
|
||||
for collection_name in SUB_RESOURCE_ATTRIBUTE_MAP:
|
||||
resource_name = collection_name[:-1]
|
||||
parent = SUB_RESOURCE_ATTRIBUTE_MAP[collection_name].get('parent')
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
from neutron_lib.api import converters
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import importutils
|
||||
import webob
|
||||
|
@ -26,7 +27,6 @@ from neutron.api.v2 import base
|
|||
from neutron.api.v2 import resource
|
||||
from neutron.common import constants as const
|
||||
from neutron.common import exceptions
|
||||
from neutron import manager
|
||||
from neutron.pecan_wsgi import controllers
|
||||
from neutron.pecan_wsgi.controllers import utils as pecan_utils
|
||||
from neutron import quota
|
||||
|
@ -153,7 +153,7 @@ class Quotasv2(extensions.ExtensionDescriptor):
|
|||
def get_resources(cls):
|
||||
"""Returns Ext Resources."""
|
||||
controller = resource.Resource(
|
||||
QuotaSetsController(manager.NeutronManager.get_plugin()),
|
||||
QuotaSetsController(directory.get_plugin()),
|
||||
faults=base.FAULT_MAP)
|
||||
return [extensions.ResourceExtension(
|
||||
Quotasv2.get_alias(),
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# under the License.
|
||||
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.api import extensions
|
||||
|
@ -21,7 +22,6 @@ from neutron.api.v2 import attributes as attr
|
|||
from neutron.api.v2 import base
|
||||
from neutron.conf import quota
|
||||
from neutron.db import rbac_db_models
|
||||
from neutron import manager
|
||||
from neutron.quota import resource_registry
|
||||
|
||||
|
||||
|
@ -106,7 +106,7 @@ class Rbac(extensions.ExtensionDescriptor):
|
|||
"""Returns Ext Resources."""
|
||||
plural_mappings = {'rbac_policies': 'rbac_policy'}
|
||||
attr.PLURALS.update(plural_mappings)
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
params = RESOURCE_ATTRIBUTE_MAP['rbac_policies']
|
||||
collection_name = 'rbac-policies'
|
||||
resource_name = 'rbac_policy'
|
||||
|
|
|
@ -19,6 +19,7 @@ import netaddr
|
|||
from neutron_lib.api import validators
|
||||
from neutron_lib import constants as const
|
||||
from neutron_lib import exceptions as nexception
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_utils import netutils
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
@ -29,7 +30,6 @@ from neutron.api.v2 import attributes as attr
|
|||
from neutron.api.v2 import base
|
||||
from neutron.common import exceptions
|
||||
from neutron.conf import quota
|
||||
from neutron import manager
|
||||
from neutron.quota import resource_registry
|
||||
|
||||
|
||||
|
@ -306,7 +306,7 @@ class Securitygroup(extensions.ExtensionDescriptor):
|
|||
my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
|
||||
attr.PLURALS.update(dict(my_plurals))
|
||||
exts = []
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
for resource_name in ['security_group', 'security_group_rule']:
|
||||
collection_name = resource_name.replace('_', '-') + "s"
|
||||
params = RESOURCE_ATTRIBUTE_MAP.get(resource_name + "s", dict())
|
||||
|
|
|
@ -17,12 +17,12 @@ import six
|
|||
|
||||
from neutron_lib.api import converters
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.api.v2 import base
|
||||
from neutron.extensions import providernet
|
||||
from neutron import manager
|
||||
|
||||
SEGMENT = 'segment'
|
||||
SEGMENTS = '%ss' % SEGMENT
|
||||
|
@ -115,7 +115,7 @@ class Segment(extensions.ExtensionDescriptor):
|
|||
controller = base.create_resource(
|
||||
SEGMENTS,
|
||||
SEGMENT,
|
||||
manager.NeutronManager.get_service_plugins()[SEGMENTS],
|
||||
directory.get_plugin(SEGMENTS),
|
||||
resource_attributes)
|
||||
return [extensions.ResourceExtension(SEGMENTS,
|
||||
controller,
|
||||
|
|
|
@ -15,6 +15,7 @@ import abc
|
|||
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import exceptions
|
||||
from neutron_lib.plugins import directory
|
||||
import six
|
||||
import webob.exc
|
||||
|
||||
|
@ -23,7 +24,6 @@ from neutron.api import extensions
|
|||
from neutron.api.v2 import attributes
|
||||
from neutron.api.v2 import base
|
||||
from neutron.api.v2 import resource as api_resource
|
||||
from neutron import manager
|
||||
from neutron.services import service_base
|
||||
|
||||
|
||||
|
@ -74,8 +74,7 @@ def validate_tags(body):
|
|||
|
||||
class TagController(object):
|
||||
def __init__(self):
|
||||
self.plugin = (manager.NeutronManager.get_service_plugins()
|
||||
[TAG_PLUGIN_TYPE])
|
||||
self.plugin = directory.get_plugin(TAG_PLUGIN_TYPE)
|
||||
|
||||
def index(self, request, **kwargs):
|
||||
# GET /v2.0/networks/{network_id}/tags
|
||||
|
|
|
@ -18,6 +18,7 @@ import random
|
|||
|
||||
import netaddr
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_log import log
|
||||
from oslo_utils import uuidutils
|
||||
|
@ -29,7 +30,6 @@ from neutron.ipam import exceptions as ipam_exc
|
|||
from neutron.ipam import requests as ipam_req
|
||||
from neutron.ipam import subnet_alloc
|
||||
from neutron.ipam import utils as ipam_utils
|
||||
from neutron import manager
|
||||
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
@ -110,7 +110,7 @@ class NeutronDbSubnet(ipam_base.Subnet):
|
|||
|
||||
@classmethod
|
||||
def _fetch_subnet(cls, context, id):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
return plugin._get_subnet(context, id)
|
||||
|
||||
def __init__(self, internal_id, ctx, cidr=None,
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
# under the License.
|
||||
|
||||
from collections import defaultdict
|
||||
import weakref
|
||||
|
||||
from neutron_lib import constants as lib_const
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
|
@ -102,8 +102,11 @@ class NeutronManager(object):
|
|||
Neutron's Manager class is responsible for parsing a config file and
|
||||
instantiating the correct plugin that concretely implements
|
||||
neutron_plugin_base class.
|
||||
The caller should make sure that NeutronManager is a singleton.
|
||||
"""
|
||||
# TODO(armax): use of the singleton pattern for this class is vestigial,
|
||||
# and it is mainly relied on by the unit tests. It is safer to get rid
|
||||
# of it once the entire codebase (neutron + subprojects) has switched
|
||||
# entirely to using the plugins directory.
|
||||
_instance = None
|
||||
__trace_args__ = {"name": "rpc"}
|
||||
|
||||
|
@ -123,18 +126,17 @@ class NeutronManager(object):
|
|||
# for performance metrics.
|
||||
plugin_provider = cfg.CONF.core_plugin
|
||||
LOG.info(_LI("Loading core plugin: %s"), plugin_provider)
|
||||
self.plugin = self._get_plugin_instance(CORE_PLUGINS_NAMESPACE,
|
||||
plugin_provider)
|
||||
# NOTE(armax): keep hold of the actual plugin object
|
||||
plugin = self._get_plugin_instance(CORE_PLUGINS_NAMESPACE,
|
||||
plugin_provider)
|
||||
directory.add_plugin(lib_const.CORE, plugin)
|
||||
msg = validate_post_plugin_load()
|
||||
if msg:
|
||||
LOG.critical(msg)
|
||||
raise Exception(msg)
|
||||
|
||||
# core plugin as a part of plugin collection simplifies
|
||||
# checking extensions
|
||||
# TODO(enikanorov): make core plugin the same as
|
||||
# the rest of service plugins
|
||||
self.service_plugins = {constants.CORE: self.plugin}
|
||||
# load services from the core plugin first
|
||||
self._load_services_from_core_plugin(plugin)
|
||||
self._load_service_plugins()
|
||||
# Used by pecan WSGI
|
||||
self.resource_plugin_mappings = {}
|
||||
|
@ -161,16 +163,15 @@ class NeutronManager(object):
|
|||
plugin_class = self.load_class_for_provider(namespace, plugin_provider)
|
||||
return plugin_class()
|
||||
|
||||
def _load_services_from_core_plugin(self):
|
||||
def _load_services_from_core_plugin(self, plugin):
|
||||
"""Puts core plugin in service_plugins for supported services."""
|
||||
LOG.debug("Loading services supported by the core plugin")
|
||||
|
||||
# supported service types are derived from supported extensions
|
||||
for ext_alias in getattr(self.plugin,
|
||||
"supported_extension_aliases", []):
|
||||
for ext_alias in getattr(plugin, "supported_extension_aliases", []):
|
||||
if ext_alias in constants.EXT_TO_SERVICE_MAPPING:
|
||||
service_type = constants.EXT_TO_SERVICE_MAPPING[ext_alias]
|
||||
self.service_plugins[service_type] = self.plugin
|
||||
directory.add_plugin(service_type, plugin)
|
||||
LOG.info(_LI("Service %s is supported by the core plugin"),
|
||||
service_type)
|
||||
|
||||
|
@ -184,9 +185,6 @@ class NeutronManager(object):
|
|||
Starts from the core plugin and checks if it supports
|
||||
advanced services then loads classes provided in configuration.
|
||||
"""
|
||||
# load services from the core plugin first
|
||||
self._load_services_from_core_plugin()
|
||||
|
||||
plugin_providers = cfg.CONF.service_plugins
|
||||
plugin_providers.extend(self._get_default_service_plugins())
|
||||
LOG.debug("Loading service plugins: %s", plugin_providers)
|
||||
|
@ -201,22 +199,25 @@ class NeutronManager(object):
|
|||
# only one implementation of svc_type allowed
|
||||
# specifying more than one plugin
|
||||
# for the same type is a fatal exception
|
||||
if plugin_inst.get_plugin_type() in self.service_plugins:
|
||||
# TODO(armax): simplify this by moving the conditional into the
|
||||
# directory itself.
|
||||
plugin_type = plugin_inst.get_plugin_type()
|
||||
if directory.get_plugin(plugin_type):
|
||||
raise ValueError(_("Multiple plugins for service "
|
||||
"%s were configured") %
|
||||
plugin_inst.get_plugin_type())
|
||||
"%s were configured") % plugin_type)
|
||||
|
||||
self.service_plugins[plugin_inst.get_plugin_type()] = plugin_inst
|
||||
directory.add_plugin(plugin_type, plugin_inst)
|
||||
|
||||
# search for possible agent notifiers declared in service plugin
|
||||
# (needed by agent management extension)
|
||||
if (hasattr(self.plugin, 'agent_notifiers') and
|
||||
plugin = directory.get_plugin()
|
||||
if (hasattr(plugin, 'agent_notifiers') and
|
||||
hasattr(plugin_inst, 'agent_notifiers')):
|
||||
self.plugin.agent_notifiers.update(plugin_inst.agent_notifiers)
|
||||
plugin.agent_notifiers.update(plugin_inst.agent_notifiers)
|
||||
|
||||
LOG.debug("Successfully loaded %(type)s plugin. "
|
||||
"Description: %(desc)s",
|
||||
{"type": plugin_inst.get_plugin_type(),
|
||||
{"type": plugin_type,
|
||||
"desc": plugin_inst.get_plugin_description()})
|
||||
|
||||
@classmethod
|
||||
|
@ -240,23 +241,6 @@ class NeutronManager(object):
|
|||
cls._create_instance()
|
||||
return cls._instance
|
||||
|
||||
@classmethod
|
||||
def get_plugin(cls):
|
||||
# Return a weakref to minimize gc-preventing references.
|
||||
return weakref.proxy(cls.get_instance().plugin)
|
||||
|
||||
@classmethod
|
||||
def get_service_plugins(cls):
|
||||
# Return weakrefs to minimize gc-preventing references.
|
||||
service_plugins = cls.get_instance().service_plugins
|
||||
return dict((x, weakref.proxy(y))
|
||||
for x, y in six.iteritems(service_plugins))
|
||||
|
||||
@classmethod
|
||||
def get_unique_service_plugins(cls):
|
||||
service_plugins = cls.get_instance().service_plugins
|
||||
return tuple(weakref.proxy(x) for x in set(service_plugins.values()))
|
||||
|
||||
@classmethod
|
||||
def set_plugin_for_resource(cls, resource, plugin):
|
||||
cls.get_instance().resource_plugin_mappings[resource] = plugin
|
||||
|
@ -283,7 +267,7 @@ class NeutronManager(object):
|
|||
# probably should be removed
|
||||
@classmethod
|
||||
def get_service_plugin_by_path_prefix(cls, path_prefix):
|
||||
service_plugins = cls.get_unique_service_plugins()
|
||||
service_plugins = directory.get_unique_plugins()
|
||||
for service_plugin in service_plugins:
|
||||
plugin_path_prefix = getattr(service_plugin, 'path_prefix', None)
|
||||
if plugin_path_prefix and plugin_path_prefix == path_prefix:
|
||||
|
@ -298,3 +282,10 @@ class NeutronManager(object):
|
|||
@classmethod
|
||||
def get_resources_for_path_prefix(cls, path_prefix):
|
||||
return cls.get_instance().path_prefix_resource_mappings[path_prefix]
|
||||
|
||||
|
||||
def init():
|
||||
"""Call to load the plugins (core+services) machinery."""
|
||||
# TODO(armax): use is_loaded() when available
|
||||
if not directory.get_plugins():
|
||||
NeutronManager.get_instance()
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
from keystoneauth1 import loading as ks_loading
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions as exc
|
||||
from neutron_lib.plugins import directory
|
||||
from novaclient import client as nova_client
|
||||
from novaclient import exceptions as nova_exceptions
|
||||
from oslo_config import cfg
|
||||
|
@ -28,7 +29,6 @@ from neutron.callbacks import events
|
|||
from neutron.callbacks import registry
|
||||
from neutron.callbacks import resources
|
||||
from neutron import context
|
||||
from neutron import manager
|
||||
from neutron.notifiers import batch_notifier
|
||||
|
||||
|
||||
|
@ -102,15 +102,6 @@ class Notifier(object):
|
|||
'name': VIF_DELETED,
|
||||
'tag': port['id']}
|
||||
|
||||
@property
|
||||
def _plugin(self):
|
||||
# NOTE(arosen): this cannot be set in __init__ currently since
|
||||
# this class is initialized at the same time as NeutronManager()
|
||||
# which is decorated with synchronized()
|
||||
if not hasattr(self, '_plugin_ref'):
|
||||
self._plugin_ref = manager.NeutronManager.get_plugin()
|
||||
return self._plugin_ref
|
||||
|
||||
def _send_nova_notification(self, resource, event, trigger,
|
||||
action=None, original=None, data=None,
|
||||
**kwargs):
|
||||
|
@ -162,7 +153,7 @@ class Notifier(object):
|
|||
|
||||
ctx = context.get_admin_context()
|
||||
try:
|
||||
port = self._plugin.get_port(ctx, port_id)
|
||||
port = directory.get_plugin().get_port(ctx, port_id)
|
||||
except exc.PortNotFound:
|
||||
LOG.debug("Port %s was deleted, no need to send any "
|
||||
"notification", port_id)
|
||||
|
|
|
@ -14,15 +14,14 @@
|
|||
# backends
|
||||
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from neutron import manager
|
||||
|
||||
|
||||
# Common database operation implementations
|
||||
def _get_filter_query(context, model, **kwargs):
|
||||
# TODO(jlibosva): decompose _get_collection_query from plugin instance
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
with context.session.begin(subtransactions=True):
|
||||
filters = _kwargs_to_filters(**kwargs)
|
||||
query = plugin._get_collection_query(context, model, filters)
|
||||
|
@ -46,7 +45,7 @@ def get_objects(context, model, _pager=None, **kwargs):
|
|||
with context.session.begin(subtransactions=True):
|
||||
filters = _kwargs_to_filters(**kwargs)
|
||||
# TODO(ihrachys): decompose _get_collection from plugin instance
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
return plugin._get_collection(
|
||||
context, model,
|
||||
# TODO(ihrachys): avoid this no-op call per model found
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_versionedobjects import base as obj_base
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
|
||||
from neutron import manager
|
||||
from neutron.objects import base
|
||||
from neutron.services.qos import qos_consts
|
||||
|
||||
|
@ -42,7 +42,7 @@ class QosRuleType(base.NeutronObject):
|
|||
def get_objects(cls, validate_filters=True, **kwargs):
|
||||
if validate_filters:
|
||||
cls.validate_filters(**kwargs)
|
||||
core_plugin = manager.NeutronManager.get_plugin()
|
||||
core_plugin = directory.get_plugin()
|
||||
# TODO(ihrachys): apply filters to returned result
|
||||
return [cls(type=type_)
|
||||
for type_ in core_plugin.supported_qos_rule_types]
|
||||
|
|
|
@ -13,11 +13,11 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.plugins import directory
|
||||
from pecan import hooks
|
||||
import webob
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron import manager
|
||||
|
||||
|
||||
class OwnershipValidationHook(hooks.PecanHook):
|
||||
|
@ -38,7 +38,7 @@ class OwnershipValidationHook(hooks.PecanHook):
|
|||
if (neutron_context.is_admin or neutron_context.is_advsvc or
|
||||
resource not in ('port', 'subnet')):
|
||||
return
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
network = plugin.get_network(neutron_context,
|
||||
resource_item['network_id'])
|
||||
# do not perform the check on shared networks
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_log import log
|
||||
|
||||
from neutron._i18n import _LW
|
||||
|
@ -31,13 +32,14 @@ LOG = log.getLogger(__name__)
|
|||
|
||||
|
||||
def initialize_all():
|
||||
manager.init()
|
||||
ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
|
||||
ext_mgr.extend_resources("2.0", attributes.RESOURCE_ATTRIBUTE_MAP)
|
||||
# At this stage we have a fully populated resource attribute map;
|
||||
# build Pecan controllers and routes for all core resources
|
||||
for resource, collection in router.RESOURCES.items():
|
||||
resource_registry.register_resource_by_name(resource)
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
new_controller = res_ctrl.CollectionsController(collection, resource,
|
||||
plugin=plugin)
|
||||
manager.NeutronManager.set_controller_for_resource(
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# under the License.
|
||||
|
||||
from neutron_lib import constants as n_const
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_log import log
|
||||
from oslo_utils import uuidutils
|
||||
|
@ -28,7 +29,6 @@ from neutron.callbacks import resources
|
|||
from neutron.db.models import securitygroup as sg_models
|
||||
from neutron.db import models_v2
|
||||
from neutron.extensions import portbindings
|
||||
from neutron import manager
|
||||
from neutron.plugins.ml2 import models
|
||||
from neutron.services.segments import exceptions as seg_exc
|
||||
|
||||
|
@ -215,7 +215,7 @@ def get_sg_ids_grouped_by_port(context, port_ids):
|
|||
|
||||
|
||||
def make_port_dict_with_security_groups(port, sec_groups):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
port_dict = plugin._make_port_dict(port)
|
||||
port_dict['security_groups'] = sec_groups
|
||||
port_dict['security_group_rules'] = []
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
from neutron_lib import constants as const
|
||||
from neutron_lib import exceptions
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
|
@ -22,8 +23,6 @@ from neutron._i18n import _, _LW
|
|||
from neutron import context as n_context
|
||||
from neutron.db import api as db_api
|
||||
from neutron.db import l3_hamode_db
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants as service_constants
|
||||
from neutron.plugins.ml2 import driver_api as api
|
||||
from neutron.plugins.ml2.drivers.l2pop import config # noqa
|
||||
from neutron.plugins.ml2.drivers.l2pop import db as l2pop_db
|
||||
|
@ -238,8 +237,7 @@ class L2populationMechanismDriver(api.MechanismDriver):
|
|||
def update_port_down(self, context):
|
||||
port = context.current
|
||||
agent_host = context.host
|
||||
l3plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
l3plugin = directory.get_plugin(const.L3)
|
||||
# when agent transitions to backup, don't remove flood flows
|
||||
if agent_host and l3plugin and getattr(
|
||||
l3plugin, "list_router_ids_on_host", None):
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# under the License.
|
||||
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
|
@ -24,7 +25,6 @@ from neutron.callbacks import resources
|
|||
from neutron.db import models_v2
|
||||
from neutron.db import segments_db
|
||||
from neutron.extensions import dns
|
||||
from neutron import manager
|
||||
from neutron.objects import network as net_obj
|
||||
from neutron.objects import ports as port_obj
|
||||
from neutron.plugins.common import utils as plugin_utils
|
||||
|
@ -264,7 +264,7 @@ class DNSExtensionDriver(api.ExtensionDriver):
|
|||
dns_data_db)
|
||||
|
||||
def _get_network(self, context, network_id):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
return plugin.get_network(context, network_id)
|
||||
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ from eventlet import greenthread
|
|||
from neutron_lib.api import validators
|
||||
from neutron_lib import constants as const
|
||||
from neutron_lib import exceptions as exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as os_db_exception
|
||||
from oslo_log import helpers as log_helpers
|
||||
|
@ -71,8 +72,6 @@ from neutron.extensions import portbindings
|
|||
from neutron.extensions import portsecurity as psec
|
||||
from neutron.extensions import providernet as provider
|
||||
from neutron.extensions import vlantransparent
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants as service_constants
|
||||
from neutron.plugins.ml2.common import exceptions as ml2_exc
|
||||
from neutron.plugins.ml2 import config # noqa
|
||||
from neutron.plugins.ml2 import db
|
||||
|
@ -1589,8 +1588,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||
self._pre_delete_port(context, id, l3_port_check)
|
||||
# TODO(armax): get rid of the l3 dependency in the with block
|
||||
router_ids = []
|
||||
l3plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
l3plugin = directory.get_plugin(const.L3)
|
||||
|
||||
session = context.session
|
||||
with session.begin(subtransactions=True):
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
from neutron_lib import constants as n_const
|
||||
from neutron_lib import exceptions
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_log import log
|
||||
import oslo_messaging
|
||||
from sqlalchemy.orm import exc
|
||||
|
@ -29,7 +30,6 @@ from neutron.db import l3_hamode_db
|
|||
from neutron.db import provisioning_blocks
|
||||
from neutron.extensions import portbindings
|
||||
from neutron.extensions import portsecurity as psec
|
||||
from neutron import manager
|
||||
from neutron.plugins.ml2 import db as ml2_db
|
||||
from neutron.plugins.ml2 import driver_api as api
|
||||
from neutron.plugins.ml2.drivers import type_tunnel
|
||||
|
@ -70,7 +70,7 @@ class RpcCallbacks(type_tunnel.TunnelRpcCallbackMixin):
|
|||
"%(agent_id)s with host %(host)s",
|
||||
{'device': device, 'agent_id': agent_id, 'host': host})
|
||||
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
port_id = plugin._device_to_port_id(rpc_context, device)
|
||||
port_context = plugin.get_bound_port_context(rpc_context,
|
||||
port_id,
|
||||
|
@ -175,7 +175,7 @@ class RpcCallbacks(type_tunnel.TunnelRpcCallbackMixin):
|
|||
LOG.debug("Device %(device)s no longer exists at agent "
|
||||
"%(agent_id)s",
|
||||
{'device': device, 'agent_id': agent_id})
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
port_id = plugin._device_to_port_id(rpc_context, device)
|
||||
port_exists = True
|
||||
if (host and not plugin.port_bound_to_host(rpc_context,
|
||||
|
@ -206,7 +206,7 @@ class RpcCallbacks(type_tunnel.TunnelRpcCallbackMixin):
|
|||
host = kwargs.get('host')
|
||||
LOG.debug("Device %(device)s up at agent %(agent_id)s",
|
||||
{'device': device, 'agent_id': agent_id})
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
port_id = plugin._device_to_port_id(rpc_context, device)
|
||||
port = plugin.port_bound_to_host(rpc_context, port_id, host)
|
||||
if host and not port:
|
||||
|
@ -232,7 +232,7 @@ class RpcCallbacks(type_tunnel.TunnelRpcCallbackMixin):
|
|||
n_const.PORT_STATUS_ACTIVE, host, port=port)
|
||||
|
||||
def update_port_status_to_active(self, port, rpc_context, port_id, host):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
if port and port['device_owner'] == n_const.DEVICE_OWNER_DVR_INTERFACE:
|
||||
# NOTE(kevinbenton): we have to special case DVR ports because of
|
||||
# the special multi-binding status update logic they have that
|
||||
|
@ -254,7 +254,7 @@ class RpcCallbacks(type_tunnel.TunnelRpcCallbackMixin):
|
|||
|
||||
def notify_ha_port_status(self, port_id, rpc_context,
|
||||
status, host, port=None):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
l2pop_driver = plugin.mechanism_manager.mech_drivers.get(
|
||||
'l2population')
|
||||
if not l2pop_driver:
|
||||
|
|
|
@ -18,6 +18,7 @@ import re
|
|||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_log import log as logging
|
||||
|
@ -251,11 +252,7 @@ class OwnerCheck(policy.Check):
|
|||
# resource is handled by the core plugin. It might be worth
|
||||
# having a way to map resources to plugins so to make this
|
||||
# check more general
|
||||
# NOTE(ihrachys): if import is put in global, circular
|
||||
# import failure occurs
|
||||
manager = importutils.import_module('neutron.manager')
|
||||
f = getattr(manager.NeutronManager.get_instance().plugin,
|
||||
'get_%s' % parent_res)
|
||||
f = getattr(directory.get_plugin(), 'get_%s' % parent_res)
|
||||
# f *must* exist, if not found it is better to let neutron
|
||||
# explode. Check will be performed with admin context
|
||||
context = importutils.import_module('neutron.context')
|
||||
|
|
|
@ -17,6 +17,7 @@ import inspect
|
|||
import os
|
||||
import random
|
||||
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
@ -36,7 +37,6 @@ from neutron.common import rpc as n_rpc
|
|||
from neutron.conf import service
|
||||
from neutron import context
|
||||
from neutron.db import api as session
|
||||
from neutron import manager
|
||||
from neutron import worker as neutron_worker
|
||||
from neutron import wsgi
|
||||
|
||||
|
@ -150,9 +150,8 @@ class RpcReportsWorker(RpcWorker):
|
|||
|
||||
|
||||
def _get_rpc_workers():
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
service_plugins = (
|
||||
manager.NeutronManager.get_service_plugins().values())
|
||||
plugin = directory.get_plugin()
|
||||
service_plugins = directory.get_plugins().values()
|
||||
|
||||
if cfg.CONF.rpc_workers < 1:
|
||||
cfg.CONF.set_override('rpc_workers', 1)
|
||||
|
@ -185,8 +184,8 @@ def _get_rpc_workers():
|
|||
|
||||
|
||||
def _get_plugins_workers():
|
||||
# NOTE(twilson) get_service_plugins also returns the core plugin
|
||||
plugins = manager.NeutronManager.get_unique_service_plugins()
|
||||
# NOTE(twilson) get_plugins also returns the core plugin
|
||||
plugins = directory.get_unique_plugins()
|
||||
|
||||
# TODO(twilson) Instead of defaulting here, come up with a good way to
|
||||
# share a common get_workers default between NeutronPluginBaseV2 and
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_log import log as logging
|
||||
from sqlalchemy import sql
|
||||
|
@ -33,8 +35,6 @@ from neutron.db.models import external_net as ext_net_models
|
|||
from neutron.db import models_v2
|
||||
from neutron.db import standard_attr
|
||||
from neutron.extensions import l3
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants
|
||||
from neutron.plugins.common import utils as p_utils
|
||||
from neutron.services.auto_allocate import exceptions
|
||||
from neutron.services.auto_allocate import models
|
||||
|
@ -101,14 +101,13 @@ class AutoAllocatedTopologyMixin(common_db_mixin.CommonDbMixin):
|
|||
@property
|
||||
def core_plugin(self):
|
||||
if not getattr(self, '_core_plugin', None):
|
||||
self._core_plugin = manager.NeutronManager.get_plugin()
|
||||
self._core_plugin = directory.get_plugin()
|
||||
return self._core_plugin
|
||||
|
||||
@property
|
||||
def l3_plugin(self):
|
||||
if not getattr(self, '_l3_plugin', None):
|
||||
self._l3_plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
constants.L3_ROUTER_NAT)
|
||||
self._l3_plugin = directory.get_plugin(constants.L3)
|
||||
return self._l3_plugin
|
||||
|
||||
def get_auto_allocated_topology(self, context, tenant_id, fields=None):
|
||||
|
|
|
@ -10,12 +10,11 @@ The required changes to a core plugin are in that case:
|
|||
anymore.
|
||||
- Remove "router" from 'supported_extension_aliases'.
|
||||
- Modify any 'self' references to members in L3_NAT_db_mixin to instead use
|
||||
'manager.NeutronManager.get_service_plugins().get(constants.L3_ROUTER_NAT)'
|
||||
'directory.get_plugin(constants.L3)'
|
||||
For example,
|
||||
self.prevent_l3_port_deletion(...)
|
||||
becomes something like
|
||||
plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
constants.L3_ROUTER_NAT)
|
||||
plugin = directory.get_plugin(constants.L3)
|
||||
if plugin:
|
||||
plugin.prevent_l3_port_deletion(...)
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
from neutron_lib import constants as lib_const
|
||||
from neutron_lib import exceptions as lib_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
|
@ -22,7 +23,6 @@ from neutron.callbacks import events
|
|||
from neutron.callbacks import registry
|
||||
from neutron.callbacks import resources
|
||||
from neutron.db import servicetype_db as st_db
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants
|
||||
from neutron.services import provider_configuration
|
||||
from neutron.services import service_base
|
||||
|
@ -64,8 +64,7 @@ class DriverController(object):
|
|||
@property
|
||||
def _flavor_plugin(self):
|
||||
if not hasattr(self, '_flavor_plugin_ref'):
|
||||
_service_plugins = manager.NeutronManager.get_service_plugins()
|
||||
self._flavor_plugin_ref = _service_plugins[constants.FLAVORS]
|
||||
self._flavor_plugin_ref = directory.get_plugin(constants.FLAVORS)
|
||||
return self._flavor_plugin_ref
|
||||
|
||||
def _set_router_provider(self, resource, event, trigger, context, router,
|
||||
|
|
|
@ -19,6 +19,7 @@ import functools
|
|||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_log import helpers as log_helpers
|
||||
from oslo_utils import uuidutils
|
||||
|
@ -286,7 +287,7 @@ def _add_segment_host_mapping_for_segment(resource, event, trigger,
|
|||
|
||||
if not segment.physical_network:
|
||||
return
|
||||
cp = manager.NeutronManager.get_plugin()
|
||||
cp = directory.get_plugin()
|
||||
check_segment_for_agent = getattr(cp, 'check_segment_for_agent', None)
|
||||
if not hasattr(cp, 'get_agents') or not check_segment_for_agent:
|
||||
# not an agent-supporting plugin
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.callbacks import events
|
||||
|
@ -24,13 +26,12 @@ from neutron.db import models_v2
|
|||
from neutron.extensions import ip_allocation
|
||||
from neutron.extensions import l2_adjacency
|
||||
from neutron.extensions import segment
|
||||
from neutron import manager
|
||||
from neutron.services.segments import db
|
||||
from neutron.services.segments import exceptions
|
||||
|
||||
|
||||
def _extend_network_dict_binding(plugin, network_res, network_db):
|
||||
if not manager.NeutronManager.get_service_plugins().get('segments'):
|
||||
if not directory.get_plugin('segments'):
|
||||
return
|
||||
|
||||
# TODO(carl_baldwin) Make this work with service subnets when it's a thing.
|
||||
|
@ -44,7 +45,7 @@ def _extend_subnet_dict_binding(plugin, subnet_res, subnet_db):
|
|||
|
||||
|
||||
def _extend_port_dict_binding(plugin, port_res, port_db):
|
||||
if not manager.NeutronManager.get_service_plugins().get('segments'):
|
||||
if not directory.get_plugin('segments'):
|
||||
return
|
||||
|
||||
value = ip_allocation.IP_ALLOCATION_IMMEDIATE
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
import collections
|
||||
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_log import helpers as log_helpers
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
|
@ -26,7 +27,6 @@ from neutron.api.rpc.handlers import resources_rpc
|
|||
from neutron.common import rpc as n_rpc
|
||||
from neutron.db import api as db_api
|
||||
from neutron.extensions import portbindings
|
||||
from neutron import manager
|
||||
from neutron.objects import trunk as trunk_objects
|
||||
from neutron.services.trunk import constants as trunk_consts
|
||||
from neutron.services.trunk import exceptions as trunk_exc
|
||||
|
@ -76,7 +76,7 @@ class TrunkSkeleton(object):
|
|||
@property
|
||||
def core_plugin(self):
|
||||
if not self._core_plugin:
|
||||
self._core_plugin = manager.NeutronManager.get_plugin()
|
||||
self._core_plugin = directory.get_plugin()
|
||||
return self._core_plugin
|
||||
|
||||
@log_helpers.log_method_call
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
from neutron_lib.api import converters
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.common import utils as n_utils
|
||||
from neutron.extensions import portbindings
|
||||
from neutron import manager
|
||||
from neutron.objects import trunk as trunk_objects
|
||||
from neutron.plugins.ml2 import driver_api as api
|
||||
from neutron.services.trunk import exceptions as trunk_exc
|
||||
|
@ -102,7 +102,7 @@ class TrunkPortValidator(object):
|
|||
def is_bound(self, context):
|
||||
"""Return true if the port is bound, false otherwise."""
|
||||
# Validate that the given port_id does not have a port binding.
|
||||
core_plugin = manager.NeutronManager.get_plugin()
|
||||
core_plugin = directory.get_plugin()
|
||||
self._port = core_plugin.get_port(context, self.port_id)
|
||||
return bool(self._port.get(portbindings.HOST_ID))
|
||||
|
||||
|
@ -112,7 +112,7 @@ class TrunkPortValidator(object):
|
|||
# An unbound port can be trunked, always.
|
||||
return True
|
||||
|
||||
trunk_plugin = manager.NeutronManager.get_service_plugins()['trunk']
|
||||
trunk_plugin = directory.get_plugin('trunk')
|
||||
vif_type = self._port.get(portbindings.VIF_TYPE)
|
||||
binding_host = self._port.get(portbindings.HOST_ID)
|
||||
|
||||
|
@ -135,7 +135,7 @@ class TrunkPortValidator(object):
|
|||
|
||||
def check_not_in_use(self, context):
|
||||
"""Raises PortInUse for ports assigned for device purposes."""
|
||||
core_plugin = manager.NeutronManager.get_plugin()
|
||||
core_plugin = directory.get_plugin()
|
||||
self._port = core_plugin.get_port(context, self.port_id)
|
||||
# NOTE(armax): the trunk extension itself does not make use of the
|
||||
# device_id field, because it has no reason to. If need be, this
|
||||
|
@ -175,7 +175,7 @@ class SubPortsValidator(object):
|
|||
If the network or port cannot be obtained, or if MTU is not defined,
|
||||
returns None.
|
||||
"""
|
||||
core_plugin = manager.NeutronManager.get_plugin()
|
||||
core_plugin = directory.get_plugin()
|
||||
|
||||
if not n_utils.is_extension_supported(core_plugin, 'net-mtu'):
|
||||
return
|
||||
|
|
|
@ -12,14 +12,15 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron.common import utils
|
||||
from neutron import manager
|
||||
|
||||
|
||||
def get_agent_types_by_host(context, host):
|
||||
"""Return the agent types registered on the host."""
|
||||
agent_types = []
|
||||
core_plugin = manager.NeutronManager.get_plugin()
|
||||
core_plugin = directory.get_plugin()
|
||||
if utils.is_extension_supported(core_plugin, 'agent'):
|
||||
agents = core_plugin.get_agents(
|
||||
context.elevated(), filters={'host': [host]})
|
||||
|
|
|
@ -30,6 +30,7 @@ from debtcollector import moves
|
|||
import eventlet.timeout
|
||||
import fixtures
|
||||
import mock
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_concurrency.fixture import lockutils
|
||||
from oslo_config import cfg
|
||||
from oslo_messaging import conffixture as messaging_conffixture
|
||||
|
@ -302,6 +303,7 @@ class BaseTestCase(DietTestCase):
|
|||
self.setup_rpc_mocks()
|
||||
self.setup_config()
|
||||
self.setup_test_registry_instance()
|
||||
self.setup_test_directory_instance()
|
||||
|
||||
policy.init()
|
||||
self.addCleanup(policy.reset)
|
||||
|
@ -371,6 +373,14 @@ class BaseTestCase(DietTestCase):
|
|||
mock.patch.object(registry, '_get_callback_manager',
|
||||
return_value=self._callback_manager).start()
|
||||
|
||||
def setup_test_directory_instance(self):
|
||||
"""Give a private copy of the directory to each test."""
|
||||
# TODO(armax): switch to using a fixture to stop relying on stubbing
|
||||
# out _get_plugin_directory directly.
|
||||
self._plugin_directory = directory._PluginDirectory()
|
||||
mock.patch.object(directory, '_get_plugin_directory',
|
||||
return_value=self._plugin_directory).start()
|
||||
|
||||
def setup_config(self, args=None):
|
||||
"""Tests that need a non-default config can override this method."""
|
||||
self.config_parse(args=args)
|
||||
|
@ -391,11 +401,13 @@ class BaseTestCase(DietTestCase):
|
|||
for k, v in six.iteritems(kw):
|
||||
CONF.set_override(k, v, group)
|
||||
|
||||
def setup_coreplugin(self, core_plugin=None):
|
||||
def setup_coreplugin(self, core_plugin=None, load_plugins=True):
|
||||
cp = PluginFixture(core_plugin)
|
||||
self.useFixture(cp)
|
||||
self.patched_dhcp_periodic = cp.patched_dhcp_periodic
|
||||
self.patched_default_svc_plugins = cp.patched_default_svc_plugins
|
||||
if load_plugins:
|
||||
manager.init()
|
||||
|
||||
def setup_notification_driver(self, notification_driver=None):
|
||||
self.addCleanup(fake_notifier.reset)
|
||||
|
|
|
@ -14,6 +14,7 @@ import uuid
|
|||
|
||||
import mock
|
||||
from neutron_lib import constants as n_const
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_policy import policy as oslo_policy
|
||||
|
@ -26,7 +27,6 @@ from neutron import context
|
|||
from neutron import manager
|
||||
from neutron.pecan_wsgi.controllers import root as controllers
|
||||
from neutron.pecan_wsgi.controllers import utils as controller_utils
|
||||
from neutron.plugins.common import constants
|
||||
from neutron import policy
|
||||
from neutron.tests.common import helpers
|
||||
from neutron.tests.functional.pecan_wsgi import test_functional
|
||||
|
@ -56,7 +56,7 @@ class TestRootController(test_functional.PecanFunctionalTest):
|
|||
def setUp(self):
|
||||
super(TestRootController, self).setUp()
|
||||
self.setup_service_plugin()
|
||||
self.plugin = manager.NeutronManager.get_plugin()
|
||||
self.plugin = directory.get_plugin()
|
||||
self.ctx = context.get_admin_context()
|
||||
|
||||
def setup_service_plugin(self):
|
||||
|
@ -438,7 +438,7 @@ class TestPaginationAndSorting(test_functional.PecanFunctionalTest):
|
|||
cfg.CONF.set_override('allow_pagination', True)
|
||||
cfg.CONF.set_override('allow_sorting', True)
|
||||
super(TestPaginationAndSorting, self).setUp()
|
||||
self.plugin = manager.NeutronManager.get_plugin()
|
||||
self.plugin = directory.get_plugin()
|
||||
self.ctx = context.get_admin_context()
|
||||
self._create_networks(self.RESOURCE_COUNT)
|
||||
self.networks = self._get_collection()['networks']
|
||||
|
@ -658,7 +658,7 @@ class TestRequestProcessing(TestRootController):
|
|||
self.assertEqual('router', self.req_stash['resource_type'])
|
||||
# make sure the core plugin was identified as the handler for ports
|
||||
self.assertEqual(
|
||||
manager.NeutronManager.get_service_plugins()['L3_ROUTER_NAT'],
|
||||
directory.get_plugin(n_const.L3),
|
||||
self.req_stash['plugin'])
|
||||
|
||||
def test_service_plugin_uri(self):
|
||||
|
@ -684,10 +684,9 @@ class TestRouterController(TestResourceController):
|
|||
['neutron.services.l3_router.l3_router_plugin.L3RouterPlugin',
|
||||
'neutron.services.flavors.flavors_plugin.FlavorsPlugin'])
|
||||
super(TestRouterController, self).setUp()
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
ctx = context.get_admin_context()
|
||||
service_plugins = manager.NeutronManager.get_service_plugins()
|
||||
l3_plugin = service_plugins[constants.L3_ROUTER_NAT]
|
||||
l3_plugin = directory.get_plugin(n_const.L3)
|
||||
network_id = pecan_utils.create_network(ctx, plugin)['id']
|
||||
self.subnet = pecan_utils.create_subnet(ctx, plugin, network_id)
|
||||
self.router = pecan_utils.create_router(ctx, l3_plugin)
|
||||
|
@ -734,7 +733,7 @@ class TestDHCPAgentShimControllers(test_functional.PecanFunctionalTest):
|
|||
'create_dhcp-networks': 'role:admin',
|
||||
'delete_dhcp-networks': 'role:admin'}),
|
||||
overwrite=False)
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
ctx = context.get_admin_context()
|
||||
self.network = pecan_utils.create_network(ctx, plugin)
|
||||
self.agent = helpers.register_dhcp_agent()
|
||||
|
@ -788,8 +787,7 @@ class TestL3AgentShimControllers(test_functional.PecanFunctionalTest):
|
|||
'get_l3-routers': 'role:admin'}),
|
||||
overwrite=False)
|
||||
ctx = context.get_admin_context()
|
||||
service_plugins = manager.NeutronManager.get_service_plugins()
|
||||
l3_plugin = service_plugins[constants.L3_ROUTER_NAT]
|
||||
l3_plugin = directory.get_plugin(n_const.L3)
|
||||
self.router = pecan_utils.create_router(ctx, l3_plugin)
|
||||
self.agent = helpers.register_l3_agent()
|
||||
# NOTE(blogan): Not sending notifications because this test is for
|
||||
|
|
|
@ -24,17 +24,19 @@ from pecan.testing import load_test_app
|
|||
import testtools
|
||||
|
||||
from neutron.api import extensions as exts
|
||||
from neutron import manager
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
||||
|
||||
class PecanFunctionalTest(testlib_api.SqlTestCase):
|
||||
|
||||
def setUp(self, service_plugins=None, extensions=None):
|
||||
self.setup_coreplugin('ml2')
|
||||
self.setup_coreplugin('ml2', load_plugins=False)
|
||||
super(PecanFunctionalTest, self).setUp()
|
||||
self.addCleanup(exts.PluginAwareExtensionManager.clear_instance)
|
||||
self.addCleanup(set_config, {}, overwrite=True)
|
||||
self.set_config_overrides()
|
||||
manager.init()
|
||||
ext_mgr = exts.PluginAwareExtensionManager.get_instance()
|
||||
if extensions:
|
||||
ext_mgr.extensions = extensions
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_policy import policy as oslo_policy
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
|
@ -283,7 +284,7 @@ class TestMetricsNotifierHook(test_functional.PecanFunctionalTest):
|
|||
def test_bad_create_doesnt_emit_end(self):
|
||||
req_headers = {'X-Project-Id': 'tenid', 'X-Roles': 'admin'}
|
||||
payload = {'network': {'name': 'meh'}}
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
with mock.patch.object(plugin, 'create_network',
|
||||
side_effect=ValueError):
|
||||
response = self.app.post_json(
|
||||
|
@ -305,7 +306,7 @@ class TestMetricsNotifierHook(test_functional.PecanFunctionalTest):
|
|||
self.assertEqual(201, response.status_int)
|
||||
json_body = jsonutils.loads(response.body)
|
||||
self.mock_notifier.reset_mock()
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
with mock.patch.object(plugin, 'update_network',
|
||||
side_effect=ValueError):
|
||||
response = self.app.put_json(
|
||||
|
@ -327,7 +328,7 @@ class TestMetricsNotifierHook(test_functional.PecanFunctionalTest):
|
|||
self.assertEqual(201, response.status_int)
|
||||
json_body = jsonutils.loads(response.body)
|
||||
self.mock_notifier.reset_mock()
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
with mock.patch.object(plugin, 'delete_network',
|
||||
side_effect=ValueError):
|
||||
response = self.app.delete(
|
||||
|
|
|
@ -25,6 +25,7 @@ from oslo_config import cfg
|
|||
import psutil
|
||||
|
||||
from neutron.common import utils
|
||||
from neutron import manager
|
||||
from neutron import service
|
||||
from neutron.tests import base
|
||||
from neutron import worker as neutron_worker
|
||||
|
@ -223,7 +224,7 @@ class TestRPCServer(TestNeutronServer):
|
|||
|
||||
def setUp(self):
|
||||
super(TestRPCServer, self).setUp()
|
||||
self.setup_coreplugin('ml2')
|
||||
self.setup_coreplugin('ml2', load_plugins=False)
|
||||
self._plugin_patcher = mock.patch(TARGET_PLUGIN, autospec=True)
|
||||
self.plugin = self._plugin_patcher.start()
|
||||
self.plugin.return_value.rpc_workers_supported = True
|
||||
|
@ -235,7 +236,7 @@ class TestRPCServer(TestNeutronServer):
|
|||
# receiving SIGHUP.
|
||||
with mock.patch("neutron.service.RpcWorker.start") as start_method:
|
||||
with mock.patch(
|
||||
"neutron.manager.NeutronManager.get_plugin"
|
||||
"neutron_lib.plugins.directory.get_plugin"
|
||||
) as get_plugin:
|
||||
start_method.side_effect = self._fake_start
|
||||
get_plugin.return_value = self.plugin
|
||||
|
@ -257,12 +258,13 @@ class TestPluginWorker(TestNeutronServer):
|
|||
|
||||
def setUp(self):
|
||||
super(TestPluginWorker, self).setUp()
|
||||
self.setup_coreplugin('ml2')
|
||||
self.setup_coreplugin('ml2', load_plugins=False)
|
||||
self._plugin_patcher = mock.patch(TARGET_PLUGIN, autospec=True)
|
||||
self.plugin = self._plugin_patcher.start()
|
||||
manager.init()
|
||||
|
||||
def _start_plugin(self, workers=1):
|
||||
with mock.patch('neutron.manager.NeutronManager.get_plugin') as gp:
|
||||
with mock.patch('neutron_lib.plugins.directory.get_plugin') as gp:
|
||||
gp.return_value = self.plugin
|
||||
plugin_workers_launcher = service.start_plugins_workers()
|
||||
plugin_workers_launcher.wait()
|
||||
|
|
|
@ -19,6 +19,7 @@ import abc
|
|||
|
||||
import fixtures
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
import six
|
||||
|
||||
from neutron import context
|
||||
|
@ -76,6 +77,7 @@ class PluginClientFixture(AbstractClientFixture):
|
|||
self.useFixture(testlib_api.StaticSqlFixture())
|
||||
self.useFixture(self.plugin_conf)
|
||||
self.useFixture(base.PluginFixture(self.plugin_conf.plugin_name))
|
||||
manager.init()
|
||||
|
||||
@property
|
||||
def ctx(self):
|
||||
|
@ -85,7 +87,7 @@ class PluginClientFixture(AbstractClientFixture):
|
|||
|
||||
@property
|
||||
def plugin(self):
|
||||
return manager.NeutronManager.get_plugin()
|
||||
return directory.get_plugin()
|
||||
|
||||
@property
|
||||
def NotFound(self):
|
||||
|
|
|
@ -13,13 +13,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 six.moves import http_client as httplib
|
||||
from webob import exc
|
||||
|
||||
from neutron import context
|
||||
from neutron.extensions import portbindings
|
||||
from neutron import manager
|
||||
from neutron.tests.unit.db import test_db_base_plugin_v2
|
||||
|
||||
|
||||
|
@ -75,7 +75,7 @@ class PortBindingsTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
self._check_response_no_portbindings(non_admin_port)
|
||||
|
||||
def test_ports_vif_details(self):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
cfg.CONF.set_default('allow_overlapping_ips', True)
|
||||
with self.port(), self.port():
|
||||
ctx = context.get_admin_context()
|
||||
|
|
|
@ -18,6 +18,7 @@ import contextlib
|
|||
|
||||
import mock
|
||||
from neutron_lib import constants as const
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
import oslo_messaging
|
||||
from oslo_utils import netutils
|
||||
|
@ -33,7 +34,6 @@ from neutron import context
|
|||
from neutron.db import securitygroups_rpc_base as sg_db_rpc
|
||||
from neutron.extensions import allowedaddresspairs as addr_pair
|
||||
from neutron.extensions import securitygroup as ext_sg
|
||||
from neutron import manager
|
||||
from neutron.tests import base
|
||||
from neutron.tests import tools
|
||||
from neutron.tests.unit.extensions import test_securitygroup as test_sg
|
||||
|
@ -123,7 +123,7 @@ class SGServerRpcCallBackTestCase(test_sg.SecurityGroupDBTestCase):
|
|||
plugin = plugin or TEST_PLUGIN_CLASS
|
||||
set_firewall_driver(FIREWALL_NOOP_DRIVER)
|
||||
super(SGServerRpcCallBackTestCase, self).setUp(plugin)
|
||||
self.notifier = manager.NeutronManager.get_plugin().notifier
|
||||
self.notifier = directory.get_plugin().notifier
|
||||
self.rpc = securitygroups_rpc.SecurityGroupServerRpcCallback()
|
||||
|
||||
def _test_security_group_port(self, device_owner, gw_ip,
|
||||
|
@ -284,7 +284,7 @@ class SGServerRpcCallBackTestCase(test_sg.SecurityGroupDBTestCase):
|
|||
|
||||
@contextlib.contextmanager
|
||||
def _port_with_addr_pairs_and_security_group(self):
|
||||
plugin_obj = manager.NeutronManager.get_plugin()
|
||||
plugin_obj = directory.get_plugin()
|
||||
if ('allowed-address-pairs'
|
||||
not in plugin_obj.supported_extension_aliases):
|
||||
self.skipTest("Test depends on allowed-address-pairs extension")
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
import datetime
|
||||
import mock
|
||||
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
|
||||
|
@ -184,11 +185,10 @@ class TestDhcpAgentNotifyAPI(base.BaseTestCase):
|
|||
self.notifier.plugin.get_network.return_value = {'id': network_id}
|
||||
segment_sp = mock.Mock()
|
||||
segment_sp.get_segment.return_value = segment
|
||||
with mock.patch('neutron.manager.NeutronManager.get_service_plugins',
|
||||
return_value={'segments': segment_sp}):
|
||||
self._test__notify_agents('subnet_create_end',
|
||||
expected_scheduling=1, expected_casts=1,
|
||||
payload=subnet)
|
||||
directory.add_plugin('segments', segment_sp)
|
||||
self._test__notify_agents('subnet_create_end',
|
||||
expected_scheduling=1, expected_casts=1,
|
||||
payload=subnet)
|
||||
get_agents = self.notifier.plugin.get_dhcp_agents_hosting_networks
|
||||
get_agents.assert_called_once_with(
|
||||
mock.ANY, [network_id], hosts=segment['hosts'])
|
||||
|
|
|
@ -110,7 +110,7 @@ class CachedResourceConsumerTrackerTest(base.BaseTestCase):
|
|||
tracker.set_versions(CONSUMER_1,
|
||||
{TEST_RESOURCE_TYPE: TEST_VERSION_A})
|
||||
|
||||
self.get_plugin = mock.patch('neutron.manager.NeutronManager'
|
||||
self.get_plugin = mock.patch('neutron_lib.plugins.directory'
|
||||
'.get_plugin').start()
|
||||
|
||||
self.get_plugin.return_value = _FakePlugin()
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
import mock
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_db import exception as db_exc
|
||||
|
||||
from neutron.api.rpc.handlers import dhcp_rpc
|
||||
|
@ -32,10 +33,8 @@ class TestDhcpRpcCallback(base.BaseTestCase):
|
|||
|
||||
def setUp(self):
|
||||
super(TestDhcpRpcCallback, self).setUp()
|
||||
self.plugin_p = mock.patch('neutron.manager.NeutronManager.get_plugin')
|
||||
get_plugin = self.plugin_p.start()
|
||||
self.plugin = mock.MagicMock()
|
||||
get_plugin.return_value = self.plugin
|
||||
directory.add_plugin(constants.CORE, self.plugin)
|
||||
self.callbacks = dhcp_rpc.DhcpRpcCallback()
|
||||
self.log_p = mock.patch('neutron.api.rpc.handlers.dhcp_rpc.LOG')
|
||||
self.log = self.log_p.start()
|
||||
|
@ -44,10 +43,8 @@ class TestDhcpRpcCallback(base.BaseTestCase):
|
|||
self.mock_set_dirty = set_dirty_p.start()
|
||||
self.utils_p = mock.patch('neutron.plugins.common.utils.create_port')
|
||||
self.utils = self.utils_p.start()
|
||||
self.segment_p = mock.patch(
|
||||
'neutron.manager.NeutronManager.get_service_plugins')
|
||||
self.get_service_plugins = self.segment_p.start()
|
||||
self.segment_plugin = mock.MagicMock()
|
||||
directory.add_plugin('segments', self.segment_plugin)
|
||||
|
||||
def test_group_by_network_id(self):
|
||||
port1 = {'network_id': 'a'}
|
||||
|
@ -72,9 +69,6 @@ class TestDhcpRpcCallback(base.BaseTestCase):
|
|||
self.assertEqual(expected, networks)
|
||||
|
||||
def test_get_active_networks_info_with_routed_networks(self):
|
||||
self.get_service_plugins.return_value = {
|
||||
'segments': self.segment_plugin
|
||||
}
|
||||
plugin_retval = [{'id': 'a'}, {'id': 'b'}]
|
||||
port = {'network_id': 'a'}
|
||||
subnets = [{'network_id': 'b', 'id': 'c', 'segment_id': '1'},
|
||||
|
@ -213,22 +207,13 @@ class TestDhcpRpcCallback(base.BaseTestCase):
|
|||
self._test_get_network_info()
|
||||
|
||||
def test_get_network_info_with_routed_network(self):
|
||||
self.get_service_plugins.return_value = {
|
||||
'segments': self.segment_plugin
|
||||
}
|
||||
self._test_get_network_info(segmented_network=True,
|
||||
routed_network=True)
|
||||
|
||||
def test_get_network_info_with_segmented_network_but_not_routed(self):
|
||||
self.get_service_plugins.return_value = {
|
||||
'segments': self.segment_plugin
|
||||
}
|
||||
self._test_get_network_info(segmented_network=True)
|
||||
|
||||
def test_get_network_info_with_non_segmented_network(self):
|
||||
self.get_service_plugins.return_value = {
|
||||
'segments': self.segment_plugin
|
||||
}
|
||||
self._test_get_network_info()
|
||||
|
||||
def test_update_dhcp_port_verify_port_action_port_dict(self):
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
# limitations under the License.
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
|
||||
from neutron.api.rpc.handlers import l3_rpc
|
||||
from neutron import context
|
||||
from neutron import manager
|
||||
from neutron.tests.unit.db import test_db_base_plugin_v2
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
||||
|
@ -28,7 +28,7 @@ class TestL3RpcCallback(testlib_api.SqlTestCase):
|
|||
def setUp(self):
|
||||
super(TestL3RpcCallback, self).setUp()
|
||||
self.setup_coreplugin(test_db_base_plugin_v2.DB_PLUGIN_KLASS)
|
||||
self.plugin = manager.NeutronManager.get_plugin()
|
||||
self.plugin = directory.get_plugin()
|
||||
self.ctx = context.get_admin_context()
|
||||
cfg.CONF.set_override('ipv6_pd_enabled', True)
|
||||
self.callbacks = l3_rpc.L3RpcCallback()
|
||||
|
|
|
@ -18,6 +18,7 @@ import copy
|
|||
|
||||
import fixtures
|
||||
import mock
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
|
@ -34,7 +35,6 @@ from neutron.api import extensions
|
|||
from neutron.api.v2 import attributes
|
||||
from neutron.common import config
|
||||
from neutron.common import exceptions
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants
|
||||
from neutron import quota
|
||||
from neutron.tests import base
|
||||
|
@ -1004,7 +1004,7 @@ class ExtensionExtendedAttributeTestCase(base.BaseTestCase):
|
|||
# the global attribute map
|
||||
attributes.RESOURCE_ATTRIBUTE_MAP.update(
|
||||
extattr.EXTENDED_ATTRIBUTES_2_0)
|
||||
self.agentscheduler_dbMinxin = manager.NeutronManager.get_plugin()
|
||||
self.agentscheduler_dbMinxin = directory.get_plugin()
|
||||
self.addCleanup(self.restore_attribute_map)
|
||||
|
||||
quota.QUOTAS._driver = None
|
||||
|
|
|
@ -19,6 +19,7 @@ import mock
|
|||
from neutron_lib.api import converters
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_policy import policy as oslo_policy
|
||||
|
@ -36,7 +37,6 @@ from neutron.api.v2 import base as v2_base
|
|||
from neutron.api.v2 import router
|
||||
from neutron.callbacks import registry
|
||||
from neutron import context
|
||||
from neutron import manager
|
||||
from neutron import policy
|
||||
from neutron import quota
|
||||
from neutron.quota import resource_registry
|
||||
|
@ -101,7 +101,7 @@ class APIv2TestBase(base.BaseTestCase):
|
|||
# Create the default configurations
|
||||
self.config_parse()
|
||||
# Update the plugin
|
||||
self.setup_coreplugin(plugin)
|
||||
self.setup_coreplugin(plugin, load_plugins=False)
|
||||
cfg.CONF.set_override('allow_pagination', True)
|
||||
cfg.CONF.set_override('allow_sorting', True)
|
||||
self._plugin_patcher = mock.patch(plugin, autospec=True)
|
||||
|
@ -1160,7 +1160,7 @@ class SubresourceTest(base.BaseTestCase):
|
|||
self.useFixture(tools.AttributeMapMemento())
|
||||
|
||||
self.config_parse()
|
||||
self.setup_coreplugin(plugin)
|
||||
self.setup_coreplugin(plugin, load_plugins=False)
|
||||
|
||||
self._plugin_patcher = mock.patch(plugin, autospec=True)
|
||||
self.plugin = self._plugin_patcher.start()
|
||||
|
@ -1188,7 +1188,7 @@ class SubresourceTest(base.BaseTestCase):
|
|||
parent = SUB_RESOURCES['dummy'].get('parent')
|
||||
params = RESOURCE_ATTRIBUTE_MAP['dummies']
|
||||
member_actions = {'mactions': 'GET'}
|
||||
_plugin = manager.NeutronManager.get_plugin()
|
||||
_plugin = directory.get_plugin()
|
||||
controller = v2_base.create_resource(collection_name, resource_name,
|
||||
_plugin, params,
|
||||
member_actions=member_actions,
|
||||
|
@ -1492,15 +1492,14 @@ class ExtensionTestCase(base.BaseTestCase):
|
|||
self.config_parse()
|
||||
|
||||
# Update the plugin and extensions path
|
||||
self.setup_coreplugin(plugin)
|
||||
self.setup_coreplugin(plugin, load_plugins=False)
|
||||
cfg.CONF.set_override('api_extensions_path', EXTDIR)
|
||||
|
||||
self._plugin_patcher = mock.patch(plugin, autospec=True)
|
||||
self.plugin = self._plugin_patcher.start()
|
||||
|
||||
# Instantiate mock plugin and enable the V2attributes extension
|
||||
manager.NeutronManager.get_plugin().supported_extension_aliases = (
|
||||
["v2attrs"])
|
||||
self.plugin.return_value.supported_extension_aliases = ["v2attrs"]
|
||||
|
||||
api = router.APIRouter()
|
||||
self.api = webtest.TestApp(api)
|
||||
|
|
|
@ -48,7 +48,7 @@ class QosCoreResourceExtensionTestCase(base.BaseTestCase):
|
|||
plugins = {}
|
||||
if plugin_loaded:
|
||||
plugins[plugin_constants.QOS] = None
|
||||
return mock.patch('neutron.manager.NeutronManager.get_service_plugins',
|
||||
return mock.patch('neutron_lib.plugins.directory.get_plugins',
|
||||
return_value=plugins)
|
||||
|
||||
def test_process_fields_no_qos_plugin_loaded(self):
|
||||
|
|
|
@ -17,6 +17,7 @@ import datetime
|
|||
|
||||
import mock
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as db_exc
|
||||
import oslo_messaging
|
||||
|
@ -37,8 +38,6 @@ from neutron.db.models import l3agent as rb_model
|
|||
from neutron.extensions import agent
|
||||
from neutron.extensions import dhcpagentscheduler
|
||||
from neutron.extensions import l3agentscheduler
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants as service_constants
|
||||
from neutron.tests.common import helpers
|
||||
from neutron.tests import fake_notifier
|
||||
from neutron.tests import tools
|
||||
|
@ -257,8 +256,7 @@ class OvsAgentSchedulerTestCaseBase(test_l3.L3NatTestCaseMixin,
|
|||
# the global attribute map
|
||||
attributes.RESOURCE_ATTRIBUTE_MAP.update(
|
||||
agent.RESOURCE_ATTRIBUTE_MAP)
|
||||
self.l3plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
self.l3plugin = directory.get_plugin(constants.L3)
|
||||
self.l3_notify_p = mock.patch(
|
||||
'neutron.extensions.l3agentscheduler.notify')
|
||||
self.patched_l3_notify = self.l3_notify_p.start()
|
||||
|
@ -531,7 +529,7 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
|
|||
self.assertEqual(0, len(dhcp_agents['agents']))
|
||||
|
||||
def test_network_scheduler_with_hosted_network(self):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
helpers.register_dhcp_agent(DHCP_HOSTA)
|
||||
with self.port() as port1:
|
||||
dhcp_agents = self._list_dhcp_agents_hosting_network(
|
||||
|
@ -619,7 +617,7 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
|
|||
self.assertEqual(0, num_after_remove)
|
||||
|
||||
def test_list_active_networks_on_not_registered_yet_dhcp_agent(self):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
nets = plugin.list_active_networks_on_active_dhcp_agent(
|
||||
self.adminContext, host=DHCP_HOSTA)
|
||||
self.assertEqual([], nets)
|
||||
|
@ -674,9 +672,7 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
|
|||
agt.heartbeat_timestamp - datetime.timedelta(hours=1))
|
||||
self.adminContext.session.commit()
|
||||
|
||||
plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
|
||||
plugin = directory.get_plugin(constants.L3)
|
||||
plugin.reschedule_routers_from_down_agents()
|
||||
|
||||
def _set_agent_admin_state_up(self, host, state):
|
||||
|
@ -693,8 +689,7 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
|
|||
# schedule the router to host A
|
||||
l3_rpc_cb.get_router_ids(self.adminContext, host=L3_HOSTA)
|
||||
|
||||
plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
plugin = directory.get_plugin(constants.L3)
|
||||
mock.patch.object(
|
||||
plugin, 'reschedule_router',
|
||||
side_effect=[
|
||||
|
@ -715,14 +710,12 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
|
|||
mock_ctx = mock.Mock()
|
||||
get_ctx.return_value = mock_ctx
|
||||
mock_ctx.session.query.side_effect = db_exc.DBError()
|
||||
plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
plugin = directory.get_plugin(constants.L3)
|
||||
# check that no exception is raised
|
||||
plugin.reschedule_routers_from_down_agents()
|
||||
|
||||
def test_router_rescheduler_iterates_after_reschedule_failure(self):
|
||||
plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
plugin = directory.get_plugin(constants.L3)
|
||||
l3_rpc_cb = l3_rpc.L3RpcCallback()
|
||||
self._register_agent_states()
|
||||
with self.router() as r1, self.router() as r2:
|
||||
|
@ -754,8 +747,7 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
|
|||
self.assertFalse(rr.called)
|
||||
|
||||
def test_router_is_not_rescheduled_if_agent_is_back_online(self):
|
||||
plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
plugin = directory.get_plugin(constants.L3)
|
||||
l3_rpc_cb = l3_rpc.L3RpcCallback()
|
||||
agent = helpers.register_l3_agent(host=L3_HOSTA)
|
||||
with self.router(),\
|
||||
|
@ -1301,7 +1293,7 @@ class OvsDhcpAgentNotifierTestCase(test_agent.AgentDBTestMixIn,
|
|||
mock.patch.object(
|
||||
self.plugin, 'filter_hosts_with_network_access',
|
||||
side_effect=lambda context, network_id, hosts: hosts).start()
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
self.dhcp_notifier = plugin.agent_notifiers[constants.AGENT_TYPE_DHCP]
|
||||
self.dhcp_notifier_cast = mock.patch(
|
||||
'neutron.api.rpc.agentnotifiers.dhcp_rpc_agent_api.'
|
||||
|
@ -1434,7 +1426,7 @@ class OvsDhcpAgentNotifierTestCase(test_agent.AgentDBTestMixIn,
|
|||
dhcp_notifier_schedule = mock.patch(
|
||||
'neutron.api.rpc.agentnotifiers.dhcp_rpc_agent_api.'
|
||||
'DhcpAgentNotifyAPI._schedule_network').start()
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
with self.subnet() as subnet,\
|
||||
self.port(subnet=subnet, device_id=device_id),\
|
||||
mock.patch.object(plugin,
|
||||
|
@ -1490,8 +1482,7 @@ class OvsL3AgentNotifierTestCase(test_l3.L3NatTestCaseMixin,
|
|||
fake_notifier.reset()
|
||||
|
||||
def test_router_add_to_l3_agent_notification(self):
|
||||
l3_plugin = (manager.NeutronManager.get_service_plugins()
|
||||
[service_constants.L3_ROUTER_NAT])
|
||||
l3_plugin = directory.get_plugin(constants.L3)
|
||||
l3_notifier = l3_plugin.agent_notifiers[constants.AGENT_TYPE_L3]
|
||||
with mock.patch.object(
|
||||
l3_notifier.client,
|
||||
|
@ -1513,8 +1504,7 @@ class OvsL3AgentNotifierTestCase(test_l3.L3NatTestCaseMixin,
|
|||
self._assert_notify(notifications, expected_event_type)
|
||||
|
||||
def test_router_remove_from_l3_agent_notification(self):
|
||||
l3_plugin = (manager.NeutronManager.get_service_plugins()
|
||||
[service_constants.L3_ROUTER_NAT])
|
||||
l3_plugin = directory.get_plugin(constants.L3)
|
||||
l3_notifier = l3_plugin.agent_notifiers[constants.AGENT_TYPE_L3]
|
||||
with mock.patch.object(
|
||||
l3_notifier.client,
|
||||
|
@ -1539,8 +1529,7 @@ class OvsL3AgentNotifierTestCase(test_l3.L3NatTestCaseMixin,
|
|||
self._assert_notify(notifications, expected_event_type)
|
||||
|
||||
def test_agent_updated_l3_agent_notification(self):
|
||||
l3_plugin = (manager.NeutronManager.get_service_plugins()
|
||||
[service_constants.L3_ROUTER_NAT])
|
||||
l3_plugin = directory.get_plugin(constants.L3)
|
||||
l3_notifier = l3_plugin.agent_notifiers[constants.AGENT_TYPE_L3]
|
||||
with mock.patch.object(
|
||||
l3_notifier.client,
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# limitations under the License.
|
||||
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from webob import exc as web_exc
|
||||
|
||||
|
@ -23,7 +24,6 @@ from neutron.db import portsecurity_db
|
|||
from neutron.extensions import allowedaddresspairs as addr_pair
|
||||
from neutron.extensions import portsecurity as psec
|
||||
from neutron.extensions import securitygroup as secgroup
|
||||
from neutron import manager
|
||||
from neutron.tests.unit.db import test_db_base_plugin_v2
|
||||
|
||||
|
||||
|
@ -37,7 +37,7 @@ class AllowedAddressPairTestCase(
|
|||
super(AllowedAddressPairTestCase, self).setUp(plugin)
|
||||
|
||||
# Check if a plugin supports security groups
|
||||
plugin_obj = manager.NeutronManager.get_plugin()
|
||||
plugin_obj = directory.get_plugin()
|
||||
self._skip_port_security = ('port-security' not in
|
||||
plugin_obj.supported_extension_aliases)
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import mock
|
|||
import netaddr
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions as lib_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from neutron_lib.utils import helpers
|
||||
from oslo_concurrency import lockutils
|
||||
from oslo_config import cfg
|
||||
|
@ -56,7 +57,6 @@ from neutron.db.models import securitygroup as sg_models
|
|||
from neutron.db import models_v2
|
||||
from neutron.db import standard_attr
|
||||
from neutron.ipam import exceptions as ipam_exc
|
||||
from neutron import manager
|
||||
from neutron.tests import base
|
||||
from neutron.tests import tools
|
||||
from neutron.tests.unit.api import test_extensions
|
||||
|
@ -93,7 +93,7 @@ def _fake_get_sorting_helper(self, request):
|
|||
# instead of directly using NeutronDbPluginV2TestCase
|
||||
def _get_create_db_method(resource):
|
||||
ml2_method = '_create_%s_db' % resource
|
||||
if hasattr(manager.NeutronManager.get_plugin(), ml2_method):
|
||||
if hasattr(directory.get_plugin(), ml2_method):
|
||||
return ml2_method
|
||||
else:
|
||||
return 'create_%s' % resource
|
||||
|
@ -120,7 +120,7 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase):
|
|||
plugin = DB_PLUGIN_KLASS
|
||||
|
||||
# Update the plugin
|
||||
self.setup_coreplugin(plugin)
|
||||
self.setup_coreplugin(plugin, load_plugins=False)
|
||||
cfg.CONF.set_override(
|
||||
'service_plugins',
|
||||
[test_lib.test_config.get(key, default)
|
||||
|
@ -138,7 +138,7 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase):
|
|||
self.port_create_status = 'ACTIVE'
|
||||
|
||||
def _is_native_bulk_supported():
|
||||
plugin_obj = manager.NeutronManager.get_plugin()
|
||||
plugin_obj = directory.get_plugin()
|
||||
native_bulk_attr_name = ("_%s__native_bulk_support"
|
||||
% plugin_obj.__class__.__name__)
|
||||
return getattr(plugin_obj, native_bulk_attr_name, False)
|
||||
|
@ -148,9 +148,9 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase):
|
|||
def _is_native_pagination_support():
|
||||
native_pagination_attr_name = (
|
||||
"_%s__native_pagination_support" %
|
||||
manager.NeutronManager.get_plugin().__class__.__name__)
|
||||
directory.get_plugin().__class__.__name__)
|
||||
return (cfg.CONF.allow_pagination and
|
||||
getattr(manager.NeutronManager.get_plugin(),
|
||||
getattr(directory.get_plugin(),
|
||||
native_pagination_attr_name, False))
|
||||
|
||||
self._skip_native_pagination = not _is_native_pagination_support()
|
||||
|
@ -158,12 +158,12 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase):
|
|||
def _is_native_sorting_support():
|
||||
native_sorting_attr_name = (
|
||||
"_%s__native_sorting_support" %
|
||||
manager.NeutronManager.get_plugin().__class__.__name__)
|
||||
directory.get_plugin().__class__.__name__)
|
||||
return (cfg.CONF.allow_sorting and
|
||||
getattr(manager.NeutronManager.get_plugin(),
|
||||
getattr(directory.get_plugin(),
|
||||
native_sorting_attr_name, False))
|
||||
|
||||
self.plugin = manager.NeutronManager.get_plugin()
|
||||
self.plugin = directory.get_plugin()
|
||||
self._skip_native_sorting = not _is_native_sorting_support()
|
||||
if ext_mgr:
|
||||
self.ext_api = test_extensions.setup_extensions_middleware(ext_mgr)
|
||||
|
@ -1083,7 +1083,7 @@ class TestPortsV2(NeutronDbPluginV2TestCase):
|
|||
tenid = p['port']['tenant_id']
|
||||
ctx = context.Context(user_id=None, tenant_id=tenid,
|
||||
is_admin=False)
|
||||
pl = manager.NeutronManager.get_plugin()
|
||||
pl = directory.get_plugin()
|
||||
count = pl.get_ports_count(ctx, filters={'tenant_id': [tenid]})
|
||||
self.assertEqual(4, count)
|
||||
|
||||
|
@ -1098,9 +1098,9 @@ class TestPortsV2(NeutronDbPluginV2TestCase):
|
|||
|
||||
with mock.patch('six.moves.builtins.hasattr',
|
||||
new=fakehasattr):
|
||||
orig = manager.NeutronManager.get_plugin().create_port
|
||||
orig = directory.get_plugin().create_port
|
||||
method_to_patch = _get_create_db_method('port')
|
||||
with mock.patch.object(manager.NeutronManager.get_plugin(),
|
||||
with mock.patch.object(directory.get_plugin(),
|
||||
method_to_patch) as patched_plugin:
|
||||
|
||||
def side_effect(*args, **kwargs):
|
||||
|
@ -1123,7 +1123,7 @@ class TestPortsV2(NeutronDbPluginV2TestCase):
|
|||
self.skipTest("Plugin does not support native bulk port create")
|
||||
ctx = context.get_admin_context()
|
||||
with self.network() as net:
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
orig = plugin.create_port
|
||||
method_to_patch = _get_create_db_method('port')
|
||||
with mock.patch.object(plugin, method_to_patch) as patched_plugin:
|
||||
|
@ -2443,7 +2443,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
|||
res.status_int)
|
||||
|
||||
def test_delete_ports_by_device_id(self):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
ctx = context.get_admin_context()
|
||||
with self.subnet() as subnet:
|
||||
with self.port(subnet=subnet, device_id='owner1') as p1,\
|
||||
|
@ -2486,7 +2486,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
|||
expected_code=webob.exc.HTTPOk.code)
|
||||
|
||||
def test_delete_ports_by_device_id_second_call_failure(self):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
self._test_delete_ports_by_device_id_second_call_failure(plugin)
|
||||
|
||||
def _test_delete_ports_ignores_port_not_found(self, plugin):
|
||||
|
@ -2509,7 +2509,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
|||
"deleting some of the same ports.")
|
||||
|
||||
def test_delete_ports_ignores_port_not_found(self):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
self._test_delete_ports_ignores_port_not_found(plugin)
|
||||
|
||||
|
||||
|
@ -2597,7 +2597,7 @@ class TestNetworksV2(NeutronDbPluginV2TestCase):
|
|||
# must query db to see whether subnet's shared attribute
|
||||
# has been updated or not
|
||||
ctx = context.Context('', '', is_admin=True)
|
||||
subnet_db = manager.NeutronManager.get_plugin().get_subnet(
|
||||
subnet_db = directory.get_plugin().get_subnet(
|
||||
ctx, subnet['subnet']['id'])
|
||||
self.assertTrue(subnet_db['shared'])
|
||||
|
||||
|
@ -2774,12 +2774,12 @@ class TestNetworksV2(NeutronDbPluginV2TestCase):
|
|||
return False
|
||||
return real_has_attr(item, attr)
|
||||
|
||||
orig = manager.NeutronManager.get_plugin().create_network
|
||||
orig = directory.get_plugin().create_network
|
||||
#ensures the API choose the emulation code path
|
||||
with mock.patch('six.moves.builtins.hasattr',
|
||||
new=fakehasattr):
|
||||
method_to_patch = _get_create_db_method('network')
|
||||
with mock.patch.object(manager.NeutronManager.get_plugin(),
|
||||
with mock.patch.object(directory.get_plugin(),
|
||||
method_to_patch) as patched_plugin:
|
||||
|
||||
def side_effect(*args, **kwargs):
|
||||
|
@ -2796,9 +2796,9 @@ class TestNetworksV2(NeutronDbPluginV2TestCase):
|
|||
def test_create_networks_bulk_native_plugin_failure(self):
|
||||
if self._skip_native_bulk:
|
||||
self.skipTest("Plugin does not support native bulk network create")
|
||||
orig = manager.NeutronManager.get_plugin().create_network
|
||||
orig = directory.get_plugin().create_network
|
||||
method_to_patch = _get_create_db_method('network')
|
||||
with mock.patch.object(manager.NeutronManager.get_plugin(),
|
||||
with mock.patch.object(directory.get_plugin(),
|
||||
method_to_patch) as patched_plugin:
|
||||
|
||||
def side_effect(*args, **kwargs):
|
||||
|
@ -3249,9 +3249,9 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
|
||||
with mock.patch('six.moves.builtins.hasattr',
|
||||
new=fakehasattr):
|
||||
orig = manager.NeutronManager.get_plugin().create_subnet
|
||||
orig = directory.get_plugin().create_subnet
|
||||
method_to_patch = _get_create_db_method('subnet')
|
||||
with mock.patch.object(manager.NeutronManager.get_plugin(),
|
||||
with mock.patch.object(directory.get_plugin(),
|
||||
method_to_patch) as patched_plugin:
|
||||
|
||||
def side_effect(*args, **kwargs):
|
||||
|
@ -3272,7 +3272,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
def test_create_subnets_bulk_native_plugin_failure(self):
|
||||
if self._skip_native_bulk:
|
||||
self.skipTest("Plugin does not support native bulk subnet create")
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
orig = plugin.create_subnet
|
||||
method_to_patch = _get_create_db_method('subnet')
|
||||
with mock.patch.object(plugin, method_to_patch) as patched_plugin:
|
||||
|
@ -4043,7 +4043,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
|
||||
def _test_validate_subnet_ipv6_modes(self, cur_subnet=None,
|
||||
expect_success=True, **modes):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
ctx = context.get_admin_context()
|
||||
new_subnet = {'ip_version': 6,
|
||||
'cidr': 'fe80::/64',
|
||||
|
@ -4060,7 +4060,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
|
||||
def _test_validate_subnet_ipv6_pd_modes(self, cur_subnet=None,
|
||||
expect_success=True, **modes):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
ctx = context.get_admin_context()
|
||||
new_subnet = {'ip_version': 6,
|
||||
'cidr': n_const.PROVISIONAL_IPV6_PD_PREFIX,
|
||||
|
@ -4252,7 +4252,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
'_get_subnet',
|
||||
return_value=v6_subnet).start()
|
||||
# Add an IPv6 auto-address subnet to the network
|
||||
with mock.patch.object(manager.NeutronManager.get_plugin(),
|
||||
with mock.patch.object(directory.get_plugin(),
|
||||
'update_port') as mock_updated_port:
|
||||
v6_subnet = self._make_subnet(self.fmt, network, 'fe80::1',
|
||||
'fe80::/64', ip_version=6,
|
||||
|
@ -4945,7 +4945,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
'ip_version': 4,
|
||||
'enable_dhcp': True,
|
||||
'tenant_id': network['network']['tenant_id']}
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
if hasattr(plugin, '_validate_subnet'):
|
||||
self.assertRaises(lib_exc.InvalidInput,
|
||||
plugin._validate_subnet,
|
||||
|
@ -5274,7 +5274,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
'dns_nameservers': ['8.8.8.8'],
|
||||
'host_routes': [{'destination': '135.207.0.0/16',
|
||||
'nexthop': '1.2.3.4'}]}
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
e = self.assertRaises(exception,
|
||||
plugin._validate_subnet,
|
||||
context.get_admin_context(),
|
||||
|
@ -6355,7 +6355,7 @@ class NeutronDbPluginV2AsMixinTestCase(NeutronDbPluginV2TestCase,
|
|||
self.assertEqual(net['status'], 'BUILD')
|
||||
|
||||
def test_get_user_allocation_for_dhcp_port_returns_none(self):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
with self.network() as net, self.network() as net1:
|
||||
with self.subnet(network=net, cidr='10.0.0.0/24') as subnet,\
|
||||
self.subnet(network=net1, cidr='10.0.1.0/24') as subnet1:
|
||||
|
@ -6409,7 +6409,7 @@ class TestNetworks(testlib_api.SqlTestCase):
|
|||
def _test_update_shared_net_used(self,
|
||||
device_owner,
|
||||
expected_exception=None):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
ctx = context.get_admin_context()
|
||||
network, net_id = self._create_network(plugin, ctx)
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
import mock
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron.callbacks import events
|
||||
from neutron.callbacks import registry
|
||||
|
@ -24,7 +25,6 @@ from neutron.db import dvr_mac_db
|
|||
from neutron.db.models import dvr as dvr_models
|
||||
from neutron.extensions import dvr
|
||||
from neutron.extensions import portbindings
|
||||
from neutron import manager
|
||||
from neutron.tests.unit.plugins.ml2 import test_plugin
|
||||
|
||||
|
||||
|
@ -77,7 +77,7 @@ class DvrDbMixinTestCase(test_plugin.Ml2PluginV2TestCase):
|
|||
self.ctx, "foo_host_2")
|
||||
|
||||
def test_mac_not_cleared_on_agent_delete_event_with_remaining_agents(self):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
self._create_dvr_mac_entry('host_1', 'mac_1')
|
||||
self._create_dvr_mac_entry('host_2', 'mac_2')
|
||||
agent1 = {'host': 'host_1', 'id': 'a1'}
|
||||
|
@ -91,7 +91,7 @@ class DvrDbMixinTestCase(test_plugin.Ml2PluginV2TestCase):
|
|||
self.assertFalse(notifier.dvr_mac_address_update.called)
|
||||
|
||||
def test_mac_cleared_on_agent_delete_event(self):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
self._create_dvr_mac_entry('host_1', 'mac_1')
|
||||
self._create_dvr_mac_entry('host_2', 'mac_2')
|
||||
agent = {'host': 'host_1', 'id': 'a1'}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
import mock
|
||||
from neutron_lib import constants as n_const
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
import testtools
|
||||
|
||||
from neutron.callbacks import events
|
||||
|
@ -24,7 +25,6 @@ from neutron.callbacks import resources
|
|||
from neutron.db import l3_db
|
||||
from neutron.db.models import l3 as l3_models
|
||||
from neutron.extensions import l3
|
||||
from neutron import manager
|
||||
from neutron.tests import base
|
||||
|
||||
|
||||
|
@ -49,7 +49,7 @@ class TestL3_NAT_dbonly_mixin(base.BaseTestCase):
|
|||
def test__get_subnets_by_network_no_query(self):
|
||||
"""Basic test that no query is performed if no Ports are passed"""
|
||||
context = mock.Mock()
|
||||
with mock.patch.object(manager.NeutronManager, 'get_plugin') as get_p:
|
||||
with mock.patch.object(directory, 'get_plugin') as get_p:
|
||||
self.db._get_subnets_by_network_list(context, [])
|
||||
self.assertFalse(context.session.query.called)
|
||||
self.assertFalse(get_p.called)
|
||||
|
@ -61,7 +61,7 @@ class TestL3_NAT_dbonly_mixin(base.BaseTestCase):
|
|||
query.__iter__.return_value = [(mock.sentinel.subnet_db,
|
||||
mock.sentinel.address_scope_id)]
|
||||
|
||||
with mock.patch.object(manager.NeutronManager, 'get_plugin') as get_p:
|
||||
with mock.patch.object(directory, 'get_plugin') as get_p:
|
||||
get_p()._make_subnet_dict.return_value = {
|
||||
'network_id': mock.sentinel.network_id}
|
||||
subnets = self.db._get_subnets_by_network_list(
|
||||
|
@ -74,7 +74,7 @@ class TestL3_NAT_dbonly_mixin(base.BaseTestCase):
|
|||
def test__populate_ports_for_subnets_none(self):
|
||||
"""Basic test that the method runs correctly with no ports"""
|
||||
ports = []
|
||||
with mock.patch.object(manager.NeutronManager, 'get_plugin') as get_p:
|
||||
with mock.patch.object(directory, 'get_plugin') as get_p:
|
||||
get_p().get_networks.return_value = []
|
||||
self.db._populate_mtu_and_subnets_for_ports(mock.sentinel.context,
|
||||
ports)
|
||||
|
@ -96,7 +96,7 @@ class TestL3_NAT_dbonly_mixin(base.BaseTestCase):
|
|||
ports = [{'network_id': 'net_id',
|
||||
'id': 'port_id',
|
||||
'fixed_ips': [{'subnet_id': mock.sentinel.subnet_id}]}]
|
||||
with mock.patch.object(manager.NeutronManager, 'get_plugin') as get_p:
|
||||
with mock.patch.object(directory, 'get_plugin') as get_p:
|
||||
get_p().get_networks.return_value = [{'id': 'net_id', 'mtu': 1446}]
|
||||
self.db._populate_mtu_and_subnets_for_ports(mock.sentinel.context,
|
||||
ports)
|
||||
|
@ -147,19 +147,19 @@ class TestL3_NAT_dbonly_mixin(base.BaseTestCase):
|
|||
({'id': 'id2'}, 'scope2'),
|
||||
({'id': 'id3'}, 'scope3')], result)
|
||||
|
||||
@mock.patch.object(manager.NeutronManager, 'get_plugin')
|
||||
@mock.patch.object(directory, 'get_plugin')
|
||||
def test_prevent_l3_port_deletion_port_not_found(self, gp):
|
||||
# port not found doesn't prevent
|
||||
gp.return_value.get_port.side_effect = n_exc.PortNotFound(port_id='1')
|
||||
self.db.prevent_l3_port_deletion(None, None)
|
||||
|
||||
@mock.patch.object(manager.NeutronManager, 'get_plugin')
|
||||
@mock.patch.object(directory, 'get_plugin')
|
||||
def test_prevent_l3_port_device_owner_not_router(self, gp):
|
||||
# ignores other device owners
|
||||
gp.return_value.get_port.return_value = {'device_owner': 'cat'}
|
||||
self.db.prevent_l3_port_deletion(None, None)
|
||||
|
||||
@mock.patch.object(manager.NeutronManager, 'get_plugin')
|
||||
@mock.patch.object(directory, 'get_plugin')
|
||||
def test_prevent_l3_port_no_fixed_ips(self, gp):
|
||||
# without fixed IPs is allowed
|
||||
gp.return_value.get_port.return_value = {
|
||||
|
@ -168,7 +168,7 @@ class TestL3_NAT_dbonly_mixin(base.BaseTestCase):
|
|||
}
|
||||
self.db.prevent_l3_port_deletion(None, None)
|
||||
|
||||
@mock.patch.object(manager.NeutronManager, 'get_plugin')
|
||||
@mock.patch.object(directory, 'get_plugin')
|
||||
def test_prevent_l3_port_no_router(self, gp):
|
||||
# without router is allowed
|
||||
gp.return_value.get_port.return_value = {
|
||||
|
@ -179,7 +179,7 @@ class TestL3_NAT_dbonly_mixin(base.BaseTestCase):
|
|||
self.db.get_router.side_effect = l3.RouterNotFound(router_id='44')
|
||||
self.db.prevent_l3_port_deletion(mock.Mock(), None)
|
||||
|
||||
@mock.patch.object(manager.NeutronManager, 'get_plugin')
|
||||
@mock.patch.object(directory, 'get_plugin')
|
||||
def test_prevent_l3_port_existing_router(self, gp):
|
||||
gp.return_value.get_port.return_value = {
|
||||
'device_owner': n_const.DEVICE_OWNER_ROUTER_INTF,
|
||||
|
@ -189,7 +189,7 @@ class TestL3_NAT_dbonly_mixin(base.BaseTestCase):
|
|||
with testtools.ExpectedException(n_exc.ServicePortInUse):
|
||||
self.db.prevent_l3_port_deletion(mock.Mock(), None)
|
||||
|
||||
@mock.patch.object(manager.NeutronManager, 'get_plugin')
|
||||
@mock.patch.object(directory, 'get_plugin')
|
||||
def test_prevent_l3_port_existing_floating_ip(self, gp):
|
||||
gp.return_value.get_port.return_value = {
|
||||
'device_owner': n_const.DEVICE_OWNER_FLOATINGIP,
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
# limitations under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib import constants as l3_const
|
||||
from neutron_lib import constants as const
|
||||
from neutron_lib import exceptions
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_utils import uuidutils
|
||||
import testtools
|
||||
|
||||
|
@ -29,8 +30,6 @@ from neutron.db import common_db_mixin
|
|||
from neutron.db import l3_agentschedulers_db
|
||||
from neutron.db import l3_dvr_db
|
||||
from neutron.extensions import portbindings
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants as plugin_const
|
||||
from neutron.tests.unit.db import test_db_base_plugin_v2
|
||||
|
||||
_uuid = uuidutils.generate_uuid
|
||||
|
@ -47,7 +46,7 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
|
||||
def setUp(self):
|
||||
super(L3DvrTestCase, self).setUp(plugin='ml2')
|
||||
self.core_plugin = manager.NeutronManager.get_plugin()
|
||||
self.core_plugin = directory.get_plugin()
|
||||
self.ctx = context.get_admin_context()
|
||||
self.mixin = FakeL3Plugin()
|
||||
|
||||
|
@ -125,7 +124,7 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
self.mixin._update_distributed_attr.call_count)
|
||||
|
||||
def _test_get_device_owner(self, is_distributed=False,
|
||||
expected=l3_const.DEVICE_OWNER_ROUTER_INTF,
|
||||
expected=const.DEVICE_OWNER_ROUTER_INTF,
|
||||
pass_router_id=True):
|
||||
router = {
|
||||
'name': 'foo_router',
|
||||
|
@ -148,7 +147,7 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
def test__get_device_owner_distributed(self):
|
||||
self._test_get_device_owner(
|
||||
is_distributed=True,
|
||||
expected=l3_const.DEVICE_OWNER_DVR_INTERFACE,
|
||||
expected=const.DEVICE_OWNER_DVR_INTERFACE,
|
||||
pass_router_id=False)
|
||||
|
||||
def _test__is_distributed_router(self, router, expected):
|
||||
|
@ -173,34 +172,32 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
self._test__is_distributed_router(router, True)
|
||||
|
||||
def test__get_agent_gw_ports_exist_for_network(self):
|
||||
with mock.patch.object(manager.NeutronManager, 'get_plugin') as gp:
|
||||
plugin = mock.Mock()
|
||||
gp.return_value = plugin
|
||||
plugin.get_ports.return_value = []
|
||||
self.mixin._get_agent_gw_ports_exist_for_network(
|
||||
self.ctx, 'network_id', 'host', 'agent_id')
|
||||
plugin = mock.Mock()
|
||||
directory.add_plugin(const.CORE, plugin)
|
||||
plugin.get_ports.return_value = []
|
||||
self.mixin._get_agent_gw_ports_exist_for_network(
|
||||
self.ctx, 'network_id', 'host', 'agent_id')
|
||||
plugin.get_ports.assert_called_with(self.ctx, {
|
||||
'network_id': ['network_id'],
|
||||
'device_id': ['agent_id'],
|
||||
'device_owner': [l3_const.DEVICE_OWNER_AGENT_GW]})
|
||||
'device_owner': [const.DEVICE_OWNER_AGENT_GW]})
|
||||
|
||||
def _test_prepare_direct_delete_dvr_internal_ports(self, port):
|
||||
with mock.patch.object(manager.NeutronManager, 'get_plugin') as gp:
|
||||
plugin = mock.Mock()
|
||||
gp.return_value = plugin
|
||||
plugin.get_port.return_value = port
|
||||
self.mixin._router_exists = mock.Mock(return_value=True)
|
||||
self.assertRaises(exceptions.ServicePortInUse,
|
||||
self.mixin.prevent_l3_port_deletion,
|
||||
self.ctx,
|
||||
port['id'])
|
||||
plugin = mock.Mock()
|
||||
directory.add_plugin(const.CORE, plugin)
|
||||
plugin.get_port.return_value = port
|
||||
self.mixin._router_exists = mock.Mock(return_value=True)
|
||||
self.assertRaises(exceptions.ServicePortInUse,
|
||||
self.mixin.prevent_l3_port_deletion,
|
||||
self.ctx,
|
||||
port['id'])
|
||||
|
||||
def test_prevent_delete_floatingip_agent_gateway_port(self):
|
||||
port = {
|
||||
'id': 'my_port_id',
|
||||
'fixed_ips': mock.ANY,
|
||||
'device_id': 'r_id',
|
||||
'device_owner': l3_const.DEVICE_OWNER_AGENT_GW
|
||||
'device_owner': const.DEVICE_OWNER_AGENT_GW
|
||||
}
|
||||
self._test_prepare_direct_delete_dvr_internal_ports(port)
|
||||
|
||||
|
@ -209,7 +206,7 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
'id': 'my_port_id',
|
||||
'fixed_ips': mock.ANY,
|
||||
'device_id': 'r_id',
|
||||
'device_owner': l3_const.DEVICE_OWNER_ROUTER_SNAT
|
||||
'device_owner': const.DEVICE_OWNER_ROUTER_SNAT
|
||||
}
|
||||
self._test_prepare_direct_delete_dvr_internal_ports(port)
|
||||
|
||||
|
@ -248,7 +245,7 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
def test__port_has_ipv6_address_for_dvr_snat_port(self):
|
||||
port = {
|
||||
'id': 'my_port_id',
|
||||
'device_owner': l3_const.DEVICE_OWNER_ROUTER_SNAT,
|
||||
'device_owner': const.DEVICE_OWNER_ROUTER_SNAT,
|
||||
}
|
||||
result, pv6 = self.setup_port_has_ipv6_address(port)
|
||||
self.assertFalse(result)
|
||||
|
@ -257,7 +254,7 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
def test__port_has_ipv6_address_for_non_snat_ports(self):
|
||||
port = {
|
||||
'id': 'my_port_id',
|
||||
'device_owner': l3_const.DEVICE_OWNER_DVR_INTERFACE,
|
||||
'device_owner': const.DEVICE_OWNER_DVR_INTERFACE,
|
||||
}
|
||||
result, pv6 = self.setup_port_has_ipv6_address(port)
|
||||
self.assertTrue(result)
|
||||
|
@ -268,23 +265,22 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
'id': 'my_port_id',
|
||||
portbindings.HOST_ID: 'foo_host',
|
||||
'network_id': 'ext_network_id',
|
||||
'device_owner': l3_const.DEVICE_OWNER_ROUTER_GW
|
||||
'device_owner': const.DEVICE_OWNER_ROUTER_GW
|
||||
},
|
||||
{
|
||||
'id': 'my_new_port_id',
|
||||
portbindings.HOST_ID: 'my_foo_host',
|
||||
'network_id': 'ext_network_id',
|
||||
'device_owner': l3_const.DEVICE_OWNER_ROUTER_GW
|
||||
'device_owner': const.DEVICE_OWNER_ROUTER_GW
|
||||
}]
|
||||
with mock.patch.object(manager.NeutronManager, 'get_plugin') as gp:
|
||||
plugin = mock.Mock()
|
||||
gp.return_value = plugin
|
||||
plugin.get_ports.return_value = ports
|
||||
self.mixin.delete_floatingip_agent_gateway_port(
|
||||
self.ctx, port_host, 'ext_network_id')
|
||||
plugin = mock.Mock()
|
||||
directory.add_plugin(const.CORE, plugin)
|
||||
plugin.get_ports.return_value = ports
|
||||
self.mixin.delete_floatingip_agent_gateway_port(
|
||||
self.ctx, port_host, 'ext_network_id')
|
||||
plugin.get_ports.assert_called_with(self.ctx, filters={
|
||||
'network_id': ['ext_network_id'],
|
||||
'device_owner': [l3_const.DEVICE_OWNER_AGENT_GW]})
|
||||
'device_owner': [const.DEVICE_OWNER_AGENT_GW]})
|
||||
if port_host:
|
||||
plugin.ipam.delete_port.assert_called_once_with(
|
||||
self.ctx, 'my_port_id')
|
||||
|
@ -307,15 +303,16 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
gw_port_db = {
|
||||
'id': 'my_gw_id',
|
||||
'network_id': 'ext_net_id',
|
||||
'device_owner': l3_const.DEVICE_OWNER_ROUTER_GW
|
||||
'device_owner': const.DEVICE_OWNER_ROUTER_GW
|
||||
}
|
||||
router.gw_port = gw_port_db
|
||||
else:
|
||||
router.gw_port = None
|
||||
|
||||
with mock.patch.object(manager.NeutronManager, 'get_plugin') as gp,\
|
||||
mock.patch.object(l3_dvr_db.l3_db.L3_NAT_db_mixin,
|
||||
'_delete_current_gw_port'),\
|
||||
plugin = mock.Mock()
|
||||
directory.add_plugin(const.CORE, plugin)
|
||||
with mock.patch.object(l3_dvr_db.l3_db.L3_NAT_db_mixin,
|
||||
'_delete_current_gw_port'),\
|
||||
mock.patch.object(
|
||||
self.mixin,
|
||||
'_get_router') as grtr,\
|
||||
|
@ -328,8 +325,6 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
mock.patch.object(
|
||||
self.mixin.l3_rpc_notifier,
|
||||
'delete_fipnamespace_for_ext_net') as del_fip:
|
||||
plugin = mock.Mock()
|
||||
gp.return_value = plugin
|
||||
plugin.get_ports.return_value = port
|
||||
grtr.return_value = router
|
||||
self.mixin._delete_current_gw_port(
|
||||
|
@ -351,12 +346,12 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
port = [{
|
||||
'id': 'my_port_id',
|
||||
'network_id': 'ext_net_id',
|
||||
'device_owner': l3_const.DEVICE_OWNER_ROUTER_GW
|
||||
'device_owner': const.DEVICE_OWNER_ROUTER_GW
|
||||
},
|
||||
{
|
||||
'id': 'my_new_port_id',
|
||||
'network_id': 'ext_net_id',
|
||||
'device_owner': l3_const.DEVICE_OWNER_ROUTER_GW
|
||||
'device_owner': const.DEVICE_OWNER_ROUTER_GW
|
||||
}]
|
||||
rtr, plugin, d_csnat_port, d_agent_gw_port, del_fip = (
|
||||
self._setup_delete_current_gw_port_deletes_fip_agent_gw_port(
|
||||
|
@ -411,7 +406,7 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
def test_floatingip_on_port_not_host(self):
|
||||
router, fip = self._floatingip_on_port_test_setup(None)
|
||||
|
||||
self.assertNotIn(l3_const.FLOATINGIP_KEY, router)
|
||||
self.assertNotIn(const.FLOATINGIP_KEY, router)
|
||||
self.assertNotIn(n_const.FLOATINGIP_AGENT_INTF_KEY, router)
|
||||
|
||||
def test_floatingip_on_port_with_host(self):
|
||||
|
@ -419,9 +414,9 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
|
||||
self.assertTrue(self.mixin._get_fip_sync_interfaces.called)
|
||||
|
||||
self.assertIn(l3_const.FLOATINGIP_KEY, router)
|
||||
self.assertIn(const.FLOATINGIP_KEY, router)
|
||||
self.assertIn(n_const.FLOATINGIP_AGENT_INTF_KEY, router)
|
||||
self.assertIn(fip, router[l3_const.FLOATINGIP_KEY])
|
||||
self.assertIn(fip, router[const.FLOATINGIP_KEY])
|
||||
self.assertIn('fip_interface',
|
||||
router[n_const.FLOATINGIP_AGENT_INTF_KEY])
|
||||
|
||||
|
@ -509,24 +504,20 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
{'subnet_id': subnet2['subnet']['id']})
|
||||
|
||||
csnat_filters = {'device_owner':
|
||||
[l3_const.DEVICE_OWNER_ROUTER_SNAT]}
|
||||
[const.DEVICE_OWNER_ROUTER_SNAT]}
|
||||
csnat_ports = self.core_plugin.get_ports(
|
||||
self.ctx, filters=csnat_filters)
|
||||
self.assertEqual(2, len(csnat_ports))
|
||||
|
||||
dvr_filters = {'device_owner':
|
||||
[l3_const.DEVICE_OWNER_DVR_INTERFACE]}
|
||||
[const.DEVICE_OWNER_DVR_INTERFACE]}
|
||||
dvr_ports = self.core_plugin.get_ports(
|
||||
self.ctx, filters=dvr_filters)
|
||||
self.assertEqual(2, len(dvr_ports))
|
||||
|
||||
with mock.patch.object(manager.NeutronManager,
|
||||
'get_service_plugins') as get_svc_plugin:
|
||||
get_svc_plugin.return_value = {
|
||||
plugin_const.L3_ROUTER_NAT: plugin}
|
||||
self.mixin.manager = manager
|
||||
self.mixin.remove_router_interface(
|
||||
self.ctx, router['id'], {'port_id': dvr_ports[0]['id']})
|
||||
directory.add_plugin(const.L3, plugin)
|
||||
self.mixin.remove_router_interface(
|
||||
self.ctx, router['id'], {'port_id': dvr_ports[0]['id']})
|
||||
|
||||
csnat_ports = self.core_plugin.get_ports(
|
||||
self.ctx, filters=csnat_filters)
|
||||
|
@ -561,11 +552,7 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
{'subnet_id': subnet_v4['subnet']['id']})
|
||||
self.mixin.add_router_interface(self.ctx, router['id'],
|
||||
{'subnet_id': subnet_v6['subnet']['id']})
|
||||
get_svc_plugin = mock.patch.object(
|
||||
manager.NeutronManager, 'get_service_plugins').start()
|
||||
get_svc_plugin.return_value = {
|
||||
plugin_const.L3_ROUTER_NAT: plugin}
|
||||
self.mixin.manager = manager
|
||||
directory.add_plugin(const.L3, plugin)
|
||||
return router, subnet_v4, subnet_v6
|
||||
|
||||
def test_undo_router_interface_change_on_csnat_error(self):
|
||||
|
@ -610,12 +597,12 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
def test_remove_router_interface_csnat_ports_removal_with_ipv6(self):
|
||||
router, subnet_v4, subnet_v6 = self._setup_router_with_v4_and_v6()
|
||||
csnat_filters = {'device_owner':
|
||||
[l3_const.DEVICE_OWNER_ROUTER_SNAT]}
|
||||
[const.DEVICE_OWNER_ROUTER_SNAT]}
|
||||
csnat_ports = self.core_plugin.get_ports(
|
||||
self.ctx, filters=csnat_filters)
|
||||
self.assertEqual(2, len(csnat_ports))
|
||||
dvr_filters = {'device_owner':
|
||||
[l3_const.DEVICE_OWNER_DVR_INTERFACE]}
|
||||
[const.DEVICE_OWNER_DVR_INTERFACE]}
|
||||
dvr_ports = self.core_plugin.get_ports(
|
||||
self.ctx, filters=dvr_filters)
|
||||
self.assertEqual(2, len(dvr_ports))
|
||||
|
@ -642,7 +629,7 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
self.ctx, router['id'],
|
||||
{'subnet_id': subnet_v4['subnet']['id']})
|
||||
csnat_filters = {'device_owner':
|
||||
[l3_const.DEVICE_OWNER_ROUTER_SNAT]}
|
||||
[const.DEVICE_OWNER_ROUTER_SNAT]}
|
||||
csnat_ports = self.core_plugin.get_ports(
|
||||
self.ctx, filters=csnat_filters)
|
||||
self.core_plugin.update_port(self.ctx, csnat_ports[0]['id'],
|
||||
|
@ -697,46 +684,45 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
router_dict = {'name': 'test_router', 'admin_state_up': True,
|
||||
'distributed': True}
|
||||
router = self._create_router(router_dict)
|
||||
with mock.patch.object(manager.NeutronManager, 'get_plugin') as gp:
|
||||
plugin = mock.Mock()
|
||||
l3_notify = self.mixin.l3_rpc_notifier = mock.Mock()
|
||||
gp.return_value = plugin
|
||||
port = {
|
||||
'id': 'my_port_id',
|
||||
'fixed_ips': [
|
||||
{'subnet_id': '51edc9e0-24f9-47f2-8e1e-2a41cb691323',
|
||||
'ip_address': '10.0.0.11'},
|
||||
{'subnet_id': '2b7c8a07-6f8e-4937-8701-f1d5da1a807c',
|
||||
'ip_address': '10.0.0.21'},
|
||||
{'subnet_id': '48534187-f077-4e81-93ff-81ec4cc0ad3b',
|
||||
'ip_address': 'fd45:1515:7e0:0:f816:3eff:fe1a:1111'}],
|
||||
'mac_address': 'my_mac',
|
||||
'device_owner': device_owner
|
||||
}
|
||||
dvr_port = {
|
||||
'id': 'dvr_port_id',
|
||||
'fixed_ips': mock.ANY,
|
||||
'device_owner': l3_const.DEVICE_OWNER_DVR_INTERFACE,
|
||||
'device_id': router['id']
|
||||
}
|
||||
plugin.get_ports.return_value = [dvr_port]
|
||||
if action == 'add':
|
||||
self.mixin.update_arp_entry_for_dvr_service_port(
|
||||
self.ctx, port)
|
||||
self.assertEqual(3, l3_notify.add_arp_entry.call_count)
|
||||
elif action == 'del':
|
||||
self.mixin.delete_arp_entry_for_dvr_service_port(
|
||||
self.ctx, port)
|
||||
self.assertEqual(3, l3_notify.del_arp_entry.call_count)
|
||||
plugin = mock.Mock()
|
||||
directory.add_plugin(const.CORE, plugin)
|
||||
l3_notify = self.mixin.l3_rpc_notifier = mock.Mock()
|
||||
port = {
|
||||
'id': 'my_port_id',
|
||||
'fixed_ips': [
|
||||
{'subnet_id': '51edc9e0-24f9-47f2-8e1e-2a41cb691323',
|
||||
'ip_address': '10.0.0.11'},
|
||||
{'subnet_id': '2b7c8a07-6f8e-4937-8701-f1d5da1a807c',
|
||||
'ip_address': '10.0.0.21'},
|
||||
{'subnet_id': '48534187-f077-4e81-93ff-81ec4cc0ad3b',
|
||||
'ip_address': 'fd45:1515:7e0:0:f816:3eff:fe1a:1111'}],
|
||||
'mac_address': 'my_mac',
|
||||
'device_owner': device_owner
|
||||
}
|
||||
dvr_port = {
|
||||
'id': 'dvr_port_id',
|
||||
'fixed_ips': mock.ANY,
|
||||
'device_owner': const.DEVICE_OWNER_DVR_INTERFACE,
|
||||
'device_id': router['id']
|
||||
}
|
||||
plugin.get_ports.return_value = [dvr_port]
|
||||
if action == 'add':
|
||||
self.mixin.update_arp_entry_for_dvr_service_port(
|
||||
self.ctx, port)
|
||||
self.assertEqual(3, l3_notify.add_arp_entry.call_count)
|
||||
elif action == 'del':
|
||||
self.mixin.delete_arp_entry_for_dvr_service_port(
|
||||
self.ctx, port)
|
||||
self.assertEqual(3, l3_notify.del_arp_entry.call_count)
|
||||
|
||||
def test_update_arp_entry_for_dvr_service_port_added(self):
|
||||
action = 'add'
|
||||
device_owner = l3_const.DEVICE_OWNER_LOADBALANCER
|
||||
device_owner = const.DEVICE_OWNER_LOADBALANCER
|
||||
self._test_update_arp_entry_for_dvr_service_port(device_owner, action)
|
||||
|
||||
def test_update_arp_entry_for_dvr_service_port_deleted(self):
|
||||
action = 'del'
|
||||
device_owner = l3_const.DEVICE_OWNER_LOADBALANCER
|
||||
device_owner = const.DEVICE_OWNER_LOADBALANCER
|
||||
self._test_update_arp_entry_for_dvr_service_port(device_owner, action)
|
||||
|
||||
def test_add_router_interface_csnat_ports_failure(self):
|
||||
|
@ -766,7 +752,7 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
}
|
||||
router_ports = self.core_plugin.get_ports(self.ctx, filters)
|
||||
self.assertEqual(1, len(router_ports))
|
||||
self.assertEqual(l3_const.DEVICE_OWNER_ROUTER_GW,
|
||||
self.assertEqual(const.DEVICE_OWNER_ROUTER_GW,
|
||||
router_ports[0]['device_owner'])
|
||||
|
||||
def test_add_router_interface_by_port_failure(self):
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
import mock
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_utils import uuidutils
|
||||
|
@ -36,7 +37,6 @@ from neutron.extensions import l3
|
|||
from neutron.extensions import l3_ext_ha_mode
|
||||
from neutron.extensions import portbindings
|
||||
from neutron.extensions import providernet
|
||||
from neutron import manager
|
||||
from neutron.scheduler import l3_agent_scheduler
|
||||
from neutron.tests.common import helpers
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
@ -57,13 +57,14 @@ class L3HATestFramework(testlib_api.SqlTestCase):
|
|||
|
||||
self.admin_ctx = context.get_admin_context()
|
||||
self.setup_coreplugin('ml2')
|
||||
self.core_plugin = manager.NeutronManager.get_plugin()
|
||||
self.core_plugin = directory.get_plugin()
|
||||
notif_p = mock.patch.object(l3_hamode_db.L3_HA_NAT_db_mixin,
|
||||
'_notify_ha_interfaces_updated')
|
||||
self.notif_m = notif_p.start()
|
||||
cfg.CONF.set_override('allow_overlapping_ips', True)
|
||||
|
||||
self.plugin = FakeL3PluginWithAgents()
|
||||
directory.add_plugin(constants.L3, self.plugin)
|
||||
self.plugin.router_scheduler = l3_agent_scheduler.ChanceScheduler()
|
||||
self.agent1 = helpers.register_l3_agent()
|
||||
self.agent2 = helpers.register_l3_agent(
|
||||
|
@ -412,14 +413,10 @@ class L3HATestCase(L3HATestFramework):
|
|||
self.admin_ctx, [router['id']])
|
||||
self.assertEqual(2, len(bound_agents))
|
||||
|
||||
with mock.patch.object(manager.NeutronManager,
|
||||
'get_service_plugins') as mock_manager:
|
||||
self.plugin._unbind_ha_router(self.admin_ctx, router['id'])
|
||||
|
||||
self.plugin._unbind_ha_router(self.admin_ctx, router['id'])
|
||||
bound_agents = self.plugin.get_l3_agents_hosting_routers(
|
||||
self.admin_ctx, [router['id']])
|
||||
self.assertEqual(0, len(bound_agents))
|
||||
self.assertEqual(2, mock_manager.call_count)
|
||||
|
||||
def test_get_ha_sync_data_for_host_with_non_dvr_agent(self):
|
||||
with mock.patch.object(self.plugin,
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
# under the License.
|
||||
|
||||
from neutron_lib import exceptions
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron.api.v2 import base
|
||||
from neutron.db import servicetype_db
|
||||
from neutron.extensions import servicetype
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants
|
||||
from neutron.services import service_base
|
||||
|
||||
|
@ -70,8 +70,7 @@ class Dummy(object):
|
|||
@classmethod
|
||||
def get_resources(cls):
|
||||
"""Returns Extended Resource for dummy management."""
|
||||
n_mgr = manager.NeutronManager.get_instance()
|
||||
dummy_inst = n_mgr.get_service_plugins()['DUMMY']
|
||||
dummy_inst = directory.get_plugin('DUMMY')
|
||||
controller = base.create_resource(
|
||||
COLLECTION_NAME, RESOURCE_NAME, dummy_inst,
|
||||
RESOURCE_ATTRIBUTE_MAP[COLLECTION_NAME])
|
||||
|
|
|
@ -25,6 +25,7 @@ import webtest
|
|||
|
||||
from neutron.api import extensions
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron import manager
|
||||
from neutron import quota
|
||||
from neutron.tests import tools
|
||||
from neutron.tests.unit.api import test_extensions
|
||||
|
@ -55,8 +56,8 @@ class ExtensionTestCase(testlib_api.WebTestCase):
|
|||
# Create the default configurations
|
||||
self.config_parse()
|
||||
|
||||
#just stubbing core plugin with plugin
|
||||
self.setup_coreplugin(plugin)
|
||||
# just stubbing core plugin with plugin
|
||||
self.setup_coreplugin(plugin, load_plugins=False)
|
||||
cfg.CONF.set_override('core_plugin', plugin)
|
||||
if service_type:
|
||||
cfg.CONF.set_override('service_plugins', [plugin])
|
||||
|
@ -66,6 +67,8 @@ class ExtensionTestCase(testlib_api.WebTestCase):
|
|||
instance = self.plugin.return_value
|
||||
if service_type:
|
||||
instance.get_plugin_type.return_value = service_type
|
||||
manager.init()
|
||||
|
||||
if supported_extension_aliases is not None:
|
||||
instance.supported_extension_aliases = supported_extension_aliases
|
||||
if allow_pagination:
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
|
||||
import abc
|
||||
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron.api.v2 import base
|
||||
from neutron import manager
|
||||
from neutron.quota import resource_registry
|
||||
|
||||
|
||||
|
@ -64,7 +65,7 @@ class Extensionattribute(extensions.ExtensionDescriptor):
|
|||
def get_resources(cls):
|
||||
"""Returns Ext Resources."""
|
||||
exts = []
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
resource_name = 'ext_test_resource'
|
||||
collection_name = resource_name + "s"
|
||||
params = RESOURCE_ATTRIBUTE_MAP.get(collection_name, dict())
|
||||
|
|
|
@ -16,13 +16,13 @@ import math
|
|||
|
||||
import netaddr
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
|
||||
from neutron.common import utils
|
||||
from neutron import context
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.extensions import dns
|
||||
from neutron import manager
|
||||
from neutron.plugins.ml2 import config
|
||||
from neutron.tests.unit.db import test_db_base_plugin_v2
|
||||
from neutron.tests.unit.plugins.ml2 import test_plugin
|
||||
|
@ -125,7 +125,7 @@ class DnsExtensionTestCase(test_plugin.Ml2PluginV2TestCase):
|
|||
self.assertIn('mac_address', port['port'])
|
||||
ips = port['port']['fixed_ips']
|
||||
self.assertEqual(1, len(ips))
|
||||
subnet_db = manager.NeutronManager.get_plugin().get_subnet(
|
||||
subnet_db = directory.get_plugin().get_subnet(
|
||||
context.get_admin_context(), ips[0]['subnet_id'])
|
||||
self.assertIn(netaddr.IPAddress(ips[0]['ip_address']),
|
||||
netaddr.IPSet(netaddr.IPNetwork(subnet_db['cidr'])))
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
import mock
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_utils import uuidutils
|
||||
import testtools
|
||||
from webob import exc
|
||||
|
@ -22,7 +23,6 @@ from webob import exc
|
|||
from neutron import context
|
||||
from neutron.db import models_v2
|
||||
from neutron.extensions import external_net as external_net
|
||||
from neutron import manager
|
||||
from neutron.tests.unit.api.v2 import test_base
|
||||
from neutron.tests.unit.db import test_db_base_plugin_v2
|
||||
|
||||
|
@ -96,7 +96,7 @@ class ExtNetDBTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
query_params='router:external=False')
|
||||
|
||||
def test_get_network_succeeds_without_filter(self):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
ctx = context.Context(None, None, is_admin=True)
|
||||
result = plugin.get_networks(ctx, filters=None)
|
||||
self.assertEqual([], result)
|
||||
|
@ -126,19 +126,19 @@ class ExtNetDBTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
res = req.get_response(self.api)
|
||||
self.assertEqual(exc.HTTPOk.code, res.status_int)
|
||||
ctx = context.Context(None, None, is_admin=True)
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
result = plugin.get_networks(ctx)
|
||||
self.assertFalse(result[0]['shared'])
|
||||
|
||||
def test_network_filter_hook_admin_context(self):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
ctx = context.Context(None, None, is_admin=True)
|
||||
model = models_v2.Network
|
||||
conditions = plugin._network_filter_hook(ctx, model, [])
|
||||
self.assertEqual([], conditions)
|
||||
|
||||
def test_network_filter_hook_nonadmin_context(self):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
ctx = context.Context('edinson', 'cavani')
|
||||
model = models_v2.Network
|
||||
txt = ("networkrbacs.action = :action_1 AND "
|
||||
|
@ -184,13 +184,11 @@ class ExtNetDBTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
self.assertTrue(ext_net['network'][external_net.EXTERNAL])
|
||||
|
||||
def test_delete_network_check_disassociated_floatingips(self):
|
||||
with mock.patch.object(manager.NeutronManager,
|
||||
'get_service_plugins') as srv_plugins:
|
||||
l3_mock = mock.Mock()
|
||||
srv_plugins.return_value = {'L3_ROUTER_NAT': l3_mock}
|
||||
with self.network() as net:
|
||||
req = self.new_delete_request('networks', net['network']['id'])
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(exc.HTTPNoContent.code, res.status_int)
|
||||
(l3_mock.delete_disassociated_floatingips
|
||||
.assert_called_once_with(mock.ANY, net['network']['id']))
|
||||
l3_mock = mock.Mock()
|
||||
directory.add_plugin('L3_ROUTER_NAT', l3_mock)
|
||||
with self.network() as net:
|
||||
req = self.new_delete_request('networks', net['network']['id'])
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(exc.HTTPNoContent.code, res.status_int)
|
||||
(l3_mock.delete_disassociated_floatingips
|
||||
.assert_called_once_with(mock.ANY, net['network']['id']))
|
||||
|
|
|
@ -21,6 +21,7 @@ import mock
|
|||
import netaddr
|
||||
from neutron_lib import constants as lib_constants
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import importutils
|
||||
from oslo_utils import uuidutils
|
||||
|
@ -49,7 +50,6 @@ from neutron.db import models_v2
|
|||
from neutron.extensions import external_net
|
||||
from neutron.extensions import l3
|
||||
from neutron.extensions import portbindings
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants as service_constants
|
||||
from neutron.tests import base
|
||||
from neutron.tests.common import helpers
|
||||
|
@ -93,9 +93,9 @@ class L3NatExtensionTestCase(test_extensions_base.ExtensionTestCase):
|
|||
def setUp(self):
|
||||
super(L3NatExtensionTestCase, self).setUp()
|
||||
self._setUpExtension(
|
||||
'neutron.extensions.l3.RouterPluginBase', None,
|
||||
l3.RESOURCE_ATTRIBUTE_MAP, l3.L3, '',
|
||||
allow_pagination=True, allow_sorting=True,
|
||||
'neutron.services.l3_router.l3_router_plugin.L3RouterPlugin',
|
||||
lib_constants.L3, l3.RESOURCE_ATTRIBUTE_MAP,
|
||||
l3.L3, '', allow_pagination=True, allow_sorting=True,
|
||||
supported_extension_aliases=['router'],
|
||||
use_quota=True)
|
||||
|
||||
|
@ -257,8 +257,7 @@ class TestL3NatBasePlugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||
super(TestL3NatBasePlugin, self).delete_network(context, id)
|
||||
|
||||
def delete_port(self, context, id, l3_port_check=True):
|
||||
plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
plugin = directory.get_plugin(lib_constants.L3)
|
||||
if plugin:
|
||||
if l3_port_check:
|
||||
plugin.prevent_l3_port_deletion(context, id)
|
||||
|
@ -1244,7 +1243,7 @@ class L3NatTestCaseBase(L3NatTestCaseMixin):
|
|||
|
||||
def test_router_add_interface_delete_port_after_failure(self):
|
||||
with self.router() as r, self.subnet(enable_dhcp=False) as s:
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
# inject a failure in the update port that happens at the end
|
||||
# to ensure the port gets deleted
|
||||
with mock.patch.object(
|
||||
|
@ -2045,8 +2044,7 @@ class L3NatTestCaseBase(L3NatTestCaseMixin):
|
|||
self.assertIsNotNone(body['floatingip']['router_id'])
|
||||
|
||||
def test_create_floatingip_non_admin_context_agent_notification(self):
|
||||
plugin = manager.NeutronManager.get_service_plugins()[
|
||||
service_constants.L3_ROUTER_NAT]
|
||||
plugin = directory.get_plugin(lib_constants.L3)
|
||||
if not hasattr(plugin, 'l3_rpc_notifier'):
|
||||
self.skipTest("Plugin does not support l3_rpc_notifier")
|
||||
|
||||
|
@ -2848,8 +2846,7 @@ class L3NatTestCaseBase(L3NatTestCaseMixin):
|
|||
def test_floatingip_via_router_interface_returns_201(self):
|
||||
# Override get_router_for_floatingip, as
|
||||
# networking-midonet's L3 service plugin would do.
|
||||
plugin = manager.NeutronManager.get_service_plugins()[
|
||||
service_constants.L3_ROUTER_NAT]
|
||||
plugin = directory.get_plugin(lib_constants.L3)
|
||||
with mock.patch.object(plugin, "get_router_for_floatingip",
|
||||
self._get_router_for_floatingip_without_device_owner_check):
|
||||
self._test_floatingip_via_router_interface(exc.HTTPCreated.code)
|
||||
|
@ -2989,8 +2986,7 @@ class L3NatTestCaseBase(L3NatTestCaseMixin):
|
|||
self.assertEqual(exc.HTTPConflict.code, res.status_int)
|
||||
|
||||
def test_router_specify_id_backend(self):
|
||||
plugin = manager.NeutronManager.get_service_plugins()[
|
||||
service_constants.L3_ROUTER_NAT]
|
||||
plugin = directory.get_plugin(lib_constants.L3)
|
||||
router_req = {'router': {'id': _uuid(), 'name': 'router',
|
||||
'tenant_id': 'foo',
|
||||
'admin_state_up': True}}
|
||||
|
@ -3045,8 +3041,7 @@ class L3NatTestCaseBase(L3NatTestCaseMixin):
|
|||
|
||||
def test_create_router_gateway_fails_nested(self):
|
||||
# Force _update_router_gw_info failure
|
||||
plugin = manager.NeutronManager.get_service_plugins()[
|
||||
service_constants.L3_ROUTER_NAT]
|
||||
plugin = directory.get_plugin(lib_constants.L3)
|
||||
if not isinstance(plugin, l3_db.L3_NAT_dbonly_mixin):
|
||||
self.skipTest("Plugin is not L3_NAT_dbonly_mixin")
|
||||
ctx = context.Context('', 'foo')
|
||||
|
@ -3077,8 +3072,7 @@ class L3NatTestCaseBase(L3NatTestCaseMixin):
|
|||
|
||||
def test_create_router_gateway_fails_nested_delete_router_failed(self):
|
||||
# Force _update_router_gw_info failure
|
||||
plugin = manager.NeutronManager.get_service_plugins()[
|
||||
service_constants.L3_ROUTER_NAT]
|
||||
plugin = directory.get_plugin(lib_constants.L3)
|
||||
if not isinstance(plugin, l3_db.L3_NAT_dbonly_mixin):
|
||||
self.skipTest("Plugin is not L3_NAT_dbonly_mixin")
|
||||
ctx = context.Context('', 'foo')
|
||||
|
@ -3115,8 +3109,7 @@ class L3NatTestCaseBase(L3NatTestCaseMixin):
|
|||
|
||||
def test_router_add_interface_by_port_fails_nested(self):
|
||||
# Force _validate_router_port_info failure
|
||||
plugin = manager.NeutronManager.get_service_plugins()[
|
||||
service_constants.L3_ROUTER_NAT]
|
||||
plugin = directory.get_plugin(lib_constants.L3)
|
||||
if not isinstance(plugin, l3_db.L3_NAT_dbonly_mixin):
|
||||
self.skipTest("Plugin is not L3_NAT_dbonly_mixin")
|
||||
orig_update_port = self.plugin.update_port
|
||||
|
@ -3169,8 +3162,7 @@ class L3NatTestCaseBase(L3NatTestCaseMixin):
|
|||
"""Test to make sure notification to routers occurs when the gateway
|
||||
ip address of a subnet of the external network is changed.
|
||||
"""
|
||||
plugin = manager.NeutronManager.get_service_plugins()[
|
||||
service_constants.L3_ROUTER_NAT]
|
||||
plugin = directory.get_plugin(lib_constants.L3)
|
||||
if not hasattr(plugin, 'l3_rpc_notifier'):
|
||||
self.skipTest("Plugin does not support l3_rpc_notifier")
|
||||
# make sure the callback is registered.
|
||||
|
@ -3201,8 +3193,7 @@ class L3NatTestCaseBase(L3NatTestCaseMixin):
|
|||
['fake_device'], None)
|
||||
|
||||
def test__notify_subnetpool_address_scope_update(self):
|
||||
plugin = manager.NeutronManager.get_service_plugins()[
|
||||
service_constants.L3_ROUTER_NAT]
|
||||
plugin = directory.get_plugin(lib_constants.L3)
|
||||
|
||||
tenant_id = _uuid()
|
||||
with mock.patch.object(
|
||||
|
@ -3349,8 +3340,7 @@ class L3AgentDbTestCaseBase(L3NatTestCaseMixin):
|
|||
l3_rpc_agent_api_str = (
|
||||
'neutron.api.rpc.agentnotifiers.l3_rpc_agent_api.L3AgentNotifyAPI')
|
||||
with mock.patch(l3_rpc_agent_api_str):
|
||||
plugin = manager.NeutronManager.get_service_plugins()[
|
||||
service_constants.L3_ROUTER_NAT]
|
||||
plugin = directory.get_plugin(lib_constants.L3)
|
||||
notifyApi = plugin.l3_rpc_notifier
|
||||
kargs = [item for item in args]
|
||||
kargs.append(notifyApi)
|
||||
|
@ -3518,8 +3508,7 @@ class L3NatDBIntAgentSchedulingTestCase(L3BaseForIntTests,
|
|||
self.adminContext = context.get_admin_context()
|
||||
|
||||
def _assert_router_on_agent(self, router_id, agent_host):
|
||||
plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
plugin = directory.get_plugin(lib_constants.L3)
|
||||
agents = plugin.list_l3_agents_hosting_router(
|
||||
self.adminContext, router_id)['agents']
|
||||
self.assertEqual(1, len(agents))
|
||||
|
@ -3576,8 +3565,7 @@ class L3NatDBIntAgentSchedulingTestCase(L3BaseForIntTests,
|
|||
self._assert_router_on_agent(r['router']['id'], 'host2')
|
||||
|
||||
def test_router_update_gateway_scheduling_not_supported(self):
|
||||
plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
plugin = directory.get_plugin(lib_constants.L3)
|
||||
mock.patch.object(plugin, 'router_supports_scheduling',
|
||||
return_value=False).start()
|
||||
with self.router() as r:
|
||||
|
@ -3716,8 +3704,7 @@ class L3NatDBTestCaseMixin(object):
|
|||
|
||||
def setUp(self):
|
||||
super(L3NatDBTestCaseMixin, self).setUp()
|
||||
plugin = manager.NeutronManager.get_service_plugins()[
|
||||
service_constants.L3_ROUTER_NAT]
|
||||
plugin = directory.get_plugin(lib_constants.L3)
|
||||
if not isinstance(plugin, l3_db.L3_NAT_dbonly_mixin):
|
||||
self.skipTest("Plugin is not L3_NAT_dbonly_mixin")
|
||||
|
||||
|
@ -3726,8 +3713,7 @@ class L3NatDBTestCaseMixin(object):
|
|||
the exception is propagated.
|
||||
"""
|
||||
|
||||
plugin = manager.NeutronManager.get_service_plugins()[
|
||||
service_constants.L3_ROUTER_NAT]
|
||||
plugin = directory.get_plugin(lib_constants.L3)
|
||||
ctx = context.Context('', 'foo')
|
||||
|
||||
class MyException(Exception):
|
||||
|
@ -3760,8 +3746,7 @@ class L3NatDBSepTestCase(L3BaseForSepTests, L3NatTestCaseBase,
|
|||
"""Unit tests for a separate L3 routing service plugin."""
|
||||
|
||||
def test_port_deletion_prevention_handles_missing_port(self):
|
||||
pl = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
pl = directory.get_plugin(lib_constants.L3)
|
||||
self.assertIsNone(
|
||||
pl.prevent_l3_port_deletion(context.get_admin_context(), 'fakeid')
|
||||
)
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
import mock
|
||||
import netaddr
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_serialization import jsonutils
|
||||
|
@ -34,7 +35,6 @@ from neutron.db.models import l3 as l3_models
|
|||
from neutron.db import models_v2
|
||||
from neutron.extensions import l3
|
||||
from neutron.extensions import l3_ext_gw_mode
|
||||
from neutron import manager
|
||||
from neutron.objects import network as net_obj
|
||||
from neutron.objects import subnet as subnet_obj
|
||||
from neutron.tests import base
|
||||
|
@ -400,7 +400,7 @@ class ExtGwModeIntTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
|
|||
with self.router() as r, self.subnet() as s:
|
||||
ext_net_id = s['subnet']['network_id']
|
||||
self._set_net_external(ext_net_id)
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
with mock.patch.object(plugin, '_get_port',
|
||||
side_effect=ValueError()):
|
||||
self._set_router_external_gateway(r['router']['id'],
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# limitations under the License.
|
||||
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib.plugins import directory
|
||||
from webob import exc
|
||||
|
||||
from neutron import context
|
||||
|
@ -23,7 +24,6 @@ from neutron.db import portsecurity_db
|
|||
from neutron.db import securitygroups_db
|
||||
from neutron.extensions import portsecurity as psec
|
||||
from neutron.extensions import securitygroup as ext_sg
|
||||
from neutron import manager
|
||||
from neutron.tests.unit.db import test_db_base_plugin_v2
|
||||
from neutron.tests.unit.extensions import test_securitygroup
|
||||
|
||||
|
@ -41,7 +41,7 @@ class PortSecurityTestCase(
|
|||
super(PortSecurityTestCase, self).setUp(plugin=plugin, ext_mgr=ext_mgr)
|
||||
|
||||
# Check if a plugin supports security groups
|
||||
plugin_obj = manager.NeutronManager.get_plugin()
|
||||
plugin_obj = directory.get_plugin()
|
||||
self._skip_security_group = ('security-group' not in
|
||||
plugin_obj.supported_extension_aliases)
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import uuidutils
|
||||
from webob import exc as web_exc
|
||||
|
@ -23,7 +25,6 @@ from neutron.api import extensions
|
|||
from neutron.api.v2 import router
|
||||
from neutron import context
|
||||
from neutron.extensions import providernet as pnet
|
||||
from neutron import manager
|
||||
from neutron import quota
|
||||
from neutron.tests import tools
|
||||
from neutron.tests.unit.api import test_extensions
|
||||
|
@ -60,7 +61,7 @@ class ProvidernetExtensionTestCase(testlib_api.WebTestCase):
|
|||
self.useFixture(tools.AttributeMapMemento())
|
||||
|
||||
# Update the plugin and extensions path
|
||||
self.setup_coreplugin(plugin)
|
||||
self.setup_coreplugin(plugin, load_plugins=False)
|
||||
cfg.CONF.set_override('allow_pagination', True)
|
||||
cfg.CONF.set_override('allow_sorting', True)
|
||||
self._plugin_patcher = mock.patch(plugin, autospec=True)
|
||||
|
@ -68,9 +69,9 @@ class ProvidernetExtensionTestCase(testlib_api.WebTestCase):
|
|||
# Ensure Quota checks never fail because of mock
|
||||
instance = self.plugin.return_value
|
||||
instance.get_networks_count.return_value = 1
|
||||
# Instantiate mock plugin and enable the 'provider' extension
|
||||
manager.NeutronManager.get_plugin().supported_extension_aliases = (
|
||||
["provider"])
|
||||
# Register mock plugin and enable the 'provider' extension
|
||||
instance.supported_extension_aliases = ["provider"]
|
||||
directory.add_plugin(constants.CORE, instance)
|
||||
ext_mgr = ProviderExtensionManager()
|
||||
self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr)
|
||||
self.addCleanup(self._plugin_patcher.stop)
|
||||
|
|
|
@ -18,6 +18,7 @@ import contextlib
|
|||
import mock
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import constants as const
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
import oslo_db.exception as exc
|
||||
import six
|
||||
|
@ -31,7 +32,6 @@ from neutron.db import db_base_plugin_v2
|
|||
from neutron.db import securitygroups_db
|
||||
from neutron.extensions import securitygroup as ext_sg
|
||||
from neutron.extensions import standardattrdescription
|
||||
from neutron import manager
|
||||
from neutron.tests import base
|
||||
from neutron.tests.unit.db import test_db_base_plugin_v2
|
||||
|
||||
|
@ -589,7 +589,7 @@ class TestSecurityGroups(SecurityGroupDBTestCase):
|
|||
self.assertEqual(sg_rule[0][k], v)
|
||||
|
||||
def test_get_security_group_on_port_from_wrong_tenant(self):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
if not hasattr(plugin, '_get_security_groups_on_port'):
|
||||
self.skipTest("plugin doesn't use the mixin with this method")
|
||||
neutron_context = context.get_admin_context()
|
||||
|
|
|
@ -16,6 +16,7 @@ import datetime
|
|||
import six
|
||||
|
||||
import mock
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from neutron import context
|
||||
|
@ -55,15 +56,15 @@ class TimeStampChangedsinceTestCase(test_db_base_plugin_v2.
|
|||
ext_mgr = TimeStampExtensionManager()
|
||||
super(TimeStampChangedsinceTestCase, self).setUp(plugin=self.plugin,
|
||||
ext_mgr=ext_mgr)
|
||||
self.addCleanup(manager.NeutronManager.
|
||||
get_service_plugins()['timestamp'].
|
||||
unregister_db_events)
|
||||
self.addCleanup(
|
||||
directory.get_plugin('timestamp').unregister_db_events)
|
||||
self.addCleanup(manager.NeutronManager.clear_instance)
|
||||
|
||||
def setup_coreplugin(self, core_plugin=None):
|
||||
def setup_coreplugin(self, core_plugin=None, load_plugins=True):
|
||||
super(TimeStampChangedsinceTestCase, self).setup_coreplugin(
|
||||
self.plugin)
|
||||
self.plugin, load_plugins=False)
|
||||
self.patched_default_svc_plugins.return_value = ['timestamp']
|
||||
manager.init()
|
||||
|
||||
def _get_resp_with_changed_since(self, resource_type, changed_since):
|
||||
query_params = 'changed_since=%s' % changed_since
|
||||
|
@ -227,7 +228,7 @@ class TimeStampChangedsinceTestCase(test_db_base_plugin_v2.
|
|||
def test_timestamp_fields_ignored_in_update(self):
|
||||
ctx = context.get_admin_context()
|
||||
with self.port() as port:
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
port = plugin.get_port(ctx, port['port']['id'])
|
||||
port['name'] = 'updated'
|
||||
port['created_at'] = '2011-04-06T14:34:23'
|
||||
|
|
|
@ -17,6 +17,7 @@ import mock
|
|||
import netaddr
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron.common import constants as n_const
|
||||
from neutron import context
|
||||
|
@ -24,7 +25,6 @@ from neutron.ipam.drivers.neutrondb_ipam import db_models
|
|||
from neutron.ipam.drivers.neutrondb_ipam import driver
|
||||
from neutron.ipam import exceptions as ipam_exc
|
||||
from neutron.ipam import requests as ipam_req
|
||||
from neutron import manager
|
||||
from neutron.tests.unit.db import test_db_base_plugin_v2 as test_db_plugin
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
||||
|
@ -73,7 +73,7 @@ class TestNeutronDbIpamPool(testlib_api.SqlTestCase,
|
|||
self.setup_coreplugin(test_db_plugin.DB_PLUGIN_KLASS)
|
||||
|
||||
# Prepare environment for tests
|
||||
self.plugin = manager.NeutronManager.get_plugin()
|
||||
self.plugin = directory.get_plugin()
|
||||
self.ctx = context.get_admin_context()
|
||||
self.network, self.net_id = self._create_network(self.plugin,
|
||||
self.ctx)
|
||||
|
@ -264,7 +264,7 @@ class TestNeutronDbIpamSubnet(testlib_api.SqlTestCase,
|
|||
self.setup_coreplugin(test_db_plugin.DB_PLUGIN_KLASS)
|
||||
|
||||
# Prepare environment for tests
|
||||
self.plugin = manager.NeutronManager.get_plugin()
|
||||
self.plugin = directory.get_plugin()
|
||||
self.ctx = context.get_admin_context()
|
||||
self.network, self.net_id = self._create_network(self.plugin,
|
||||
self.ctx)
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
import mock
|
||||
import netaddr
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_utils import uuidutils
|
||||
|
@ -24,7 +25,6 @@ from neutron.common import exceptions as n_exc
|
|||
from neutron import context
|
||||
from neutron.ipam import requests as ipam_req
|
||||
from neutron.ipam import subnet_alloc
|
||||
from neutron import manager
|
||||
from neutron.tests.unit.db import test_db_base_plugin_v2
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
||||
|
@ -35,7 +35,7 @@ class TestSubnetAllocation(testlib_api.SqlTestCase):
|
|||
super(TestSubnetAllocation, self).setUp()
|
||||
self._tenant_id = 'test-tenant'
|
||||
self.setup_coreplugin(test_db_base_plugin_v2.DB_PLUGIN_KLASS)
|
||||
self.plugin = manager.NeutronManager.get_plugin()
|
||||
self.plugin = directory.get_plugin()
|
||||
self.ctx = context.get_admin_context()
|
||||
cfg.CONF.set_override('allow_overlapping_ips', True)
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
import mock
|
||||
from neutron_lib import constants as n_const
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from novaclient import exceptions as nova_exceptions
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import uuidutils
|
||||
|
@ -41,7 +42,7 @@ class TestNovaNotify(base.BaseTestCase):
|
|||
'device_owner': DEVICE_OWNER_COMPUTE}
|
||||
|
||||
self.nova_notifier = nova.Notifier()
|
||||
self.nova_notifier._plugin_ref = FakePlugin()
|
||||
directory.add_plugin(n_const.CORE, FakePlugin())
|
||||
|
||||
def test_notify_port_status_all_values(self):
|
||||
states = [n_const.PORT_STATUS_ACTIVE, n_const.PORT_STATUS_DOWN,
|
||||
|
@ -180,7 +181,7 @@ class TestNovaNotify(base.BaseTestCase):
|
|||
def test_delete_floatingip_deleted_port_no_notify(self):
|
||||
port_id = 'bee50827-bcee-4cc8-91c1-a27b0ce54222'
|
||||
with mock.patch.object(
|
||||
self.nova_notifier._plugin_ref, 'get_port',
|
||||
directory.get_plugin(), 'get_port',
|
||||
side_effect=n_exc.PortNotFound(port_id=port_id)):
|
||||
returned_obj = {'floatingip':
|
||||
{'port_id': port_id}}
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
|
||||
import mock
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron import context
|
||||
from neutron.db import models_v2
|
||||
from neutron import manager
|
||||
from neutron.objects import base
|
||||
from neutron.objects.db import api
|
||||
from neutron.tests import base as test_base
|
||||
|
@ -40,7 +40,7 @@ class GetObjectsTestCase(test_base.BaseTestCase):
|
|||
limit = mock.sentinel.limit
|
||||
pager = base.Pager(marker=marker, limit=limit)
|
||||
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
with mock.patch.object(plugin, '_get_collection') as get_collection:
|
||||
with mock.patch.object(api, 'get_object') as get_object:
|
||||
api.get_objects(ctxt, model, _pager=pager)
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
# class on the common base class for all objects
|
||||
|
||||
import mock
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron import manager
|
||||
from neutron.objects.qos import rule_type
|
||||
from neutron.services.qos import qos_consts
|
||||
from neutron.tests import base as test_base
|
||||
|
@ -27,12 +27,12 @@ DB_PLUGIN_KLASS = 'neutron.db.db_base_plugin_v2.NeutronDbPluginV2'
|
|||
class QosRuleTypeObjectTestCase(test_base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(QosRuleTypeObjectTestCase, self).setUp()
|
||||
self.config_parse()
|
||||
self.setup_coreplugin(DB_PLUGIN_KLASS)
|
||||
super(QosRuleTypeObjectTestCase, self).setUp()
|
||||
|
||||
def test_get_objects(self):
|
||||
core_plugin = manager.NeutronManager.get_plugin()
|
||||
core_plugin = directory.get_plugin()
|
||||
rule_types_mock = mock.PropertyMock(
|
||||
return_value=qos_consts.VALID_RULE_TYPES)
|
||||
with mock.patch.object(core_plugin, 'supported_qos_rule_types',
|
||||
|
|
|
@ -12,8 +12,9 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants as plugin_constants
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron.tests.unit.plugins.ml2 import test_plugin
|
||||
|
||||
|
||||
|
@ -30,9 +31,8 @@ class ML2TestFramework(test_plugin.Ml2PluginV2TestCase):
|
|||
|
||||
def setUp(self):
|
||||
super(ML2TestFramework, self).setUp()
|
||||
self.core_plugin = manager.NeutronManager.get_instance().get_plugin()
|
||||
self.l3_plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
plugin_constants.L3_ROUTER_NAT)
|
||||
self.core_plugin = directory.get_plugin()
|
||||
self.l3_plugin = directory.get_plugin(constants.L3)
|
||||
|
||||
def _create_router(self, distributed=False, ha=False):
|
||||
return self.l3_plugin.create_router(
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue