Ocata sync

* use neutron_lib.directory for plugin retrieval

* switch to neutron_lib for neutron constants, exceptions,
  extensions

* add neutron.plugins.ml2.ovo_rpc to OUT_OF_PROCESS_NOTIFICATIONS:
  neutron added ovo rpc callback mechanism for ovo objects, and aim
  notification manager needs to recognize those as out of process.
  Since neutron moved away from get_session API to get_reader_session
  and get_writer_session, override for these was added.
  Few bugs were fixed in the delayed notification area as well.

* new engine facade: make use of reader and writer to grab db engine

* remove _update_fip_assoc override (didn't find a reason for the
  override)

* aim driver: a fix in update_subnetpool_precommit - not to assume
  address_scope_id field is returned from neutron update call if it
  was not updated.

* extend_XXX_dict call was switched to receive ovo instead of db
  object. As a result, foreign keys are not part of the object
  anymore, and need to be retrieved from db.

* remove_router_interface - receive port dictinary rather than port
  object

* fix patched neutron functions to receive correct parameter types
  (like patched_get_locked_port_and_binding)

* use add_agent_status_check_worker instead of add_agent_status_check

* advertise_mtu configuration parameter was removed from neutron. It
  is used in aim driver, hence added to aim driver config.

* use of project_id instead of tenant_id where required

* use segments_db module for network segments

* test_aim_mapping_driver: the test used to override uuid generation
  in order to get predictable uuid results. New neutron code makes
  use of python uuid module where overrides are complicated. It was
  easire to remove all uuid-based values from dictionaries under test

* add filters parameter to get_address_scopes calls, otherwise the
  call fails (probably should be fixed in neutron)

* in routing tests, remove the assumption that routes are returned in
  specific order

Change-Id: I1943fd4196ea6199d825ae53f0e9f5b54d54a260
This commit is contained in:
Anna Khmelnitsky 2017-05-17 16:13:01 -07:00 committed by Sumit Naiksatam
parent 40b666359c
commit 8284bf9b3a
46 changed files with 259 additions and 293 deletions

View File

@ -18,8 +18,8 @@ from gbpservice.nfp.core import log as nfp_logging
from neutron.common import rpc as n_rpc
from neutron.db import agents_db
from neutron.db import agentschedulers_db
from neutron import manager
from neutron_lib import exceptions
from neutron_lib.plugins import directory
from neutron_vpnaas.db.vpn import vpn_validator
from neutron_vpnaas.services.vpn.plugin import VPNDriverPlugin
from neutron_vpnaas.services.vpn.plugin import VPNPlugin
@ -93,7 +93,7 @@ class NFPIPsecVpnAgentApi(base_ipsec.IPsecVpnAgentApi):
def _get_agent_hosting_vpnservice(self, admin_context, vpnservice_id):
filters = {'agent_type': [AGENT_TYPE_VPN]}
agents = manager.NeutronManager.get_plugin().get_agents(
agents = directory.get_plugin().get_agents(
admin_context, filters=filters)
try:

View File

@ -15,11 +15,12 @@ from neutron.callbacks import registry
from neutron.extensions import address_scope
from neutron.extensions import l3
from neutron.extensions import securitygroup as ext_sg
from neutron import manager
from neutron.notifiers import nova
from neutron.plugins.common import constants as pconst
from neutron import quota
from neutron_lib import constants as nl_const
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
@ -58,7 +59,8 @@ REGISTRY_TRIGGER = 'registry_trigger'
# These module names/prefixes are mutually exclusive from the
# notifiers/notifications that are handled in process.
OUT_OF_PROCESS_NOTIFICATIONS = ['neutron.api.rpc.agentnotifiers',
'neutron.notifiers.nova', 'opflexagent.rpc']
'neutron.notifiers.nova', 'opflexagent.rpc',
'neutron.plugins.ml2.ovo_rpc']
def _enqueue(session, transaction_key, entry):
@ -163,27 +165,31 @@ def send_or_queue_registry_notification(
# invoked in this case, no queueing of the notification
# is required.
send = True
if not session or not transaction_key:
# We can't queue notifications without session or transaction key
send = True
if not send:
# Build a list of all in-process registered callbacks
# for this resource
in_process_callbacks = _get_in_process_callbacks(callbacks)
send = True if in_process_callbacks else False
callbacks = in_process_callbacks if send else callbacks
# If there are notifiers registered which are not in-process,
# we need to queue up this notification
queue = (in_process_callbacks != callbacks)
if in_process_callbacks:
send = True
callbacks = in_process_callbacks
if not session or not transaction_key or send:
if callbacks:
# Note: For the following to work, the _notify_loop()
# function implemented in neutron.callbacks.manager
# needs to be patched to handle the callbacks argument
# like its being done in:
# gbpservice/neutron/plugins/ml2plus/patch_neutron.py
kwargs['callbacks'] = callbacks
_registry_notify(resource, event, trigger, **kwargs)
if send and callbacks:
# Note: For the following to work, the _notify_loop()
# function implemented in neutron.callbacks.manager
# needs to be patched to handle the callbacks argument
# like its being done in:
# gbpservice/neutron/plugins/ml2plus/patch_neutron.py
kwargs['callbacks'] = callbacks
_registry_notify(resource, event, trigger, **kwargs)
if queue and session:
if queue and session and transaction_key:
_queue_registry_notification(session, transaction_key, resource,
event, trigger, **kwargs)
@ -223,14 +229,13 @@ class LocalAPI(object):
def _core_plugin(self):
# REVISIT(rkukura): Need initialization method after all
# plugins are loaded to grab and store plugin.
return manager.NeutronManager.get_plugin()
return directory.get_plugin()
@property
def _l3_plugin(self):
# REVISIT(rkukura): Need initialization method after all
# plugins are loaded to grab and store plugin.
plugins = manager.NeutronManager.get_service_plugins()
l3_plugin = plugins.get(pconst.L3_ROUTER_NAT)
l3_plugin = directory.get_plugin(nl_const.L3)
if not l3_plugin:
LOG.error(_LE("No L3 router service plugin found."))
raise exc.GroupPolicyDeploymentError()
@ -241,8 +246,7 @@ class LocalAPI(object):
# Probably as well:
# REVISIT(rkukura): Need initialization method after all
# plugins are loaded to grab and store plugin.
plugins = manager.NeutronManager.get_service_plugins()
qos_plugin = plugins.get(pconst.QOS)
qos_plugin = directory.get_plugin(pconst.QOS)
if not qos_plugin:
LOG.error(_LE("No QoS service plugin found."))
raise exc.GroupPolicyDeploymentError()
@ -252,8 +256,7 @@ class LocalAPI(object):
def _group_policy_plugin(self):
# REVISIT(rkukura): Need initialization method after all
# plugins are loaded to grab and store plugin.
plugins = manager.NeutronManager.get_service_plugins()
group_policy_plugin = plugins.get(pconst.GROUP_POLICY)
group_policy_plugin = directory.get_plugin(pconst.GROUP_POLICY)
if not group_policy_plugin:
LOG.error(_LE("No GroupPolicy service plugin found."))
raise exc.GroupPolicyDeploymentError()
@ -263,8 +266,7 @@ class LocalAPI(object):
def _servicechain_plugin(self):
# REVISIT(rkukura): Need initialization method after all
# plugins are loaded to grab and store plugin.
plugins = manager.NeutronManager.get_service_plugins()
servicechain_plugin = plugins.get(pconst.SERVICECHAIN)
servicechain_plugin = directory.get_plugin(pconst.SERVICECHAIN)
if not servicechain_plugin:
LOG.error(_LE("No Servicechain service plugin found."))
raise exc.GroupPolicyDeploymentError()

View File

@ -13,10 +13,10 @@
import ast
from neutron.db import common_db_mixin
from neutron import manager
from neutron.plugins.common import constants as pconst
from neutron_lib.db import model_base
from neutron_lib import exceptions as n_exc
from neutron_lib.plugins import directory
from oslo_log import helpers as log
from oslo_log import log as logging
from oslo_serialization import jsonutils
@ -151,8 +151,7 @@ class ServiceChainDbPlugin(schain.ServiceChainPluginBase,
def _grouppolicy_plugin(self):
# REVISIT(Magesh): Need initialization method after all
# plugins are loaded to grab and store plugin.
plugins = manager.NeutronManager.get_service_plugins()
grouppolicy_plugin = plugins.get(pconst.GROUP_POLICY)
grouppolicy_plugin = directory.get_plugin(pconst.GROUP_POLICY)
if not grouppolicy_plugin:
LOG.error(_LE("No Grouppolicy service plugin found."))
raise s_exc.ServiceChainDeploymentError()

View File

@ -10,8 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.api import extensions
from neutron_lib.api import converters
from neutron_lib.api import extensions
from gbpservice.neutron.extensions import group_policy as gp

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.api import extensions
from neutron_lib.api import extensions
from gbpservice.neutron.extensions import group_policy as gp

View File

@ -10,8 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.api import extensions
from neutron_lib.api import converters
from neutron_lib.api import extensions
from gbpservice.neutron.extensions import group_policy as gp

View File

@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.api import extensions
from neutron.api.v2 import attributes
from neutron.extensions import address_scope
from neutron_lib.api import converters as conv
from neutron_lib.api import extensions
ALIAS = 'cisco-apic'

View File

@ -10,8 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.api import extensions
from neutron_lib.api import converters as conv
from neutron_lib.api import extensions
from gbpservice.neutron.extensions import cisco_apic
from gbpservice.neutron.extensions import group_policy as gp

View File

@ -13,9 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.api import extensions
from neutron.extensions import l3
from neutron_lib.api import converters
from neutron_lib.api import extensions
from gbpservice.neutron.extensions import cisco_apic

View File

@ -10,8 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.api import extensions
from neutron_lib.api import converters as conv
from neutron_lib.api import extensions
from neutron_lib import constants as nlib_const
from neutron_lib import exceptions as nexc
from oslo_config import cfg

View File

@ -13,12 +13,13 @@
import abc
import re
from neutron.api import extensions
from neutron.api import extensions as neutron_extensions
from neutron.api.v2 import attributes as attr
from neutron.api.v2 import resource_helper
from neutron.plugins.common import constants
from neutron.services import service_base
from neutron_lib.api import converters as conv
from neutron_lib.api import extensions
from neutron_lib.api import validators as valid
from neutron_lib import constants as nlib_const
from neutron_lib import exceptions as nexc
@ -36,7 +37,7 @@ from gbpservice.neutron.services.grouppolicy.common import (
# The code below is a monkey patch of key Neutron's modules. This is needed for
# the GBP service to be loaded correctly. GBP extensions' path is added
# to Neutron's so that it's found at extension scanning time.
extensions.append_api_extensions_path(gbp_extensions.__path__)
neutron_extensions.append_api_extensions_path(gbp_extensions.__path__)
LOG = logging.getLogger(__name__)

View File

@ -10,8 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.api import extensions
from neutron_lib.api import converters as conv
from neutron_lib.api import extensions
from neutron_lib import constants as nlib_const
from gbpservice.neutron.extensions import group_policy as gp

View File

@ -10,9 +10,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.api import extensions
from neutron.api.v2 import attributes
from neutron_lib.api import converters as conv
from neutron_lib.api import extensions
from neutron_lib import constants

View File

@ -10,10 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import netaddr
from neutron.callbacks import events
from neutron.callbacks import registry
from neutron.callbacks import resources
from neutron.db import api as db_api
from neutron.db import common_db_mixin
from neutron.db import l3_db
@ -21,7 +17,6 @@ from neutron.db import models_v2
from neutron.db import securitygroups_db
from neutron.plugins.ml2 import db as ml2_db
from neutron_lib.api import validators
from neutron_lib import constants
from neutron_lib import exceptions as n_exc
from oslo_log import log
from sqlalchemy import event
@ -51,43 +46,6 @@ def _get_assoc_data(self, context, fip, floatingip_db):
l3_db.L3_NAT_dbonly_mixin._get_assoc_data = _get_assoc_data
def _update_fip_assoc(self, context, fip, floatingip_db, external_port):
previous_router_id = floatingip_db.router_id
port_id, internal_ip_address, router_id = (
self._check_and_get_fip_assoc(context, fip, floatingip_db))
update = {'fixed_ip_address': internal_ip_address,
'fixed_port_id': port_id,
'router_id': router_id,
'last_known_router_id': previous_router_id}
if 'description' in fip:
update['description'] = fip['description']
floatingip_db.update(update)
next_hop = None
if router_id:
router = self._get_router(context.elevated(), router_id)
gw_port = router.gw_port
if gw_port:
for fixed_ip in gw_port.fixed_ips:
addr = netaddr.IPAddress(fixed_ip.ip_address)
if addr.version == constants.IP_VERSION_4:
next_hop = fixed_ip.ip_address
break
args = {'fixed_ip_address': internal_ip_address,
'fixed_port_id': port_id,
'router_id': router_id,
'last_known_router_id': previous_router_id,
'floating_ip_address': floatingip_db.floating_ip_address,
'floating_network_id': floatingip_db.floating_network_id,
'next_hop': next_hop,
'context': context}
registry.notify(resources.FLOATING_IP,
events.AFTER_UPDATE,
self._update_fip_assoc,
**args)
l3_db.L3_NAT_dbonly_mixin._update_fip_assoc = _update_fip_assoc
# REVISIT(ivar): Neutron adds a tenant filter on SG lookup for a given port,
# this breaks our service chain plumbing model so for now we should monkey
# patch the specific method. A follow up with the Neutron team is needed to
@ -134,48 +92,68 @@ PUSH_NOTIFICATIONS_METHOD = None
DISCARD_NOTIFICATIONS_METHOD = None
def get_session(autocommit=True, expire_on_commit=False, use_slave=False):
def gbp_after_transaction(session, transaction):
if transaction and not transaction._parent and (
not transaction.is_active and not transaction.nested):
if transaction in session.notification_queue:
# push the queued notifications only when the
# outermost transaction completes
PUSH_NOTIFICATIONS_METHOD(session, transaction)
def gbp_after_rollback(session):
# We discard all queued notifiactions if the transaction fails.
DISCARD_NOTIFICATIONS_METHOD(session)
def pre_session():
from gbpservice.network.neutronv2 import local_api
# The folowing are declared as global so that they can
# used in the inner functions that follow.
global PUSH_NOTIFICATIONS_METHOD
global DISCARD_NOTIFICATIONS_METHOD
from gbpservice.network.neutronv2 import local_api
PUSH_NOTIFICATIONS_METHOD = (
local_api.post_notifications_from_queue)
DISCARD_NOTIFICATIONS_METHOD = (
local_api.discard_notifications_after_rollback)
# The following two lines are copied from the original
# implementation of db_api.get_session() and should be updated
# if the original implementation changes.
new_session = db_api.context_manager.get_legacy_facade().get_session(
autocommit=autocommit, expire_on_commit=expire_on_commit,
use_slave=use_slave)
def post_session(new_session):
from gbpservice.network.neutronv2 import local_api
new_session.notification_queue = {}
def gbp_after_transaction(session, transaction):
if transaction and not transaction._parent and (
not transaction.is_active and not transaction.nested):
if transaction in session.notification_queue:
# push the queued notifications only when the
# outermost transaction completes
PUSH_NOTIFICATIONS_METHOD(session, transaction)
def gbp_after_rollback(session):
# We discard all queued notifiactions if the transaction fails.
DISCARD_NOTIFICATIONS_METHOD(session)
if local_api.QUEUE_OUT_OF_PROCESS_NOTIFICATIONS:
event.listen(new_session, "after_transaction_end",
gbp_after_transaction)
event.listen(new_session, "after_rollback",
gbp_after_rollback)
def get_session(autocommit=True, expire_on_commit=False, use_slave=False):
pre_session()
# The following two lines are copied from the original
# implementation of db_api.get_session() and should be updated
# if the original implementation changes.
new_session = db_api.context_manager.get_legacy_facade().get_session(
autocommit=autocommit, expire_on_commit=expire_on_commit,
use_slave=use_slave)
post_session(new_session)
return new_session
def get_writer_session():
pre_session()
new_session = db_api.context_manager.writer.get_sessionmaker()()
post_session(new_session)
return new_session
db_api.get_session = get_session
db_api.get_writer_session = get_writer_session
# REVISIT: This is temporary, the correct fix is to use

View File

@ -12,12 +12,13 @@
import abc
from neutron.api import extensions
from neutron.api import extensions as neutron_extensions
from neutron.api.v2 import attributes as attr
from neutron.api.v2 import resource_helper
from neutron.plugins.common import constants
from neutron.services import service_base
from neutron_lib.api import converters as conv
from neutron_lib.api import extensions
from neutron_lib.api import validators as valid
from neutron_lib import exceptions as nexc
from oslo_config import cfg
@ -32,7 +33,7 @@ from gbpservice.neutron.services.servicechain.common import constants as scc
# The code below is a monkey patch of key Neutron's modules. This is needed for
# the GBP service to be loaded correctly. GBP extensions' path is added
# to Neutron's so that it's found at extension scanning time.
extensions.append_api_extensions_path(gbp_extensions.__path__)
neutron_extensions.append_api_extensions_path(gbp_extensions.__path__)
LOG = logging.getLogger(__name__)

View File

@ -17,8 +17,8 @@ from aim.api import resource as aim_res
from aim import exceptions as aim_exc
from neutron.api import extensions
from neutron.db import api as db_api
from neutron import manager as n_manager
from neutron_lib import exceptions as n_exc
from neutron_lib.plugins import directory
from oslo_log import log
from oslo_utils import excutils
@ -51,7 +51,7 @@ class ApicExtensionDriver(api_plus.ExtensionDriver,
# REVISIT(rkukura): It might be safer to search the MDs by
# class rather than index by name, or to use a class
# variable to find the instance.
plugin = n_manager.NeutronManager.get_plugin()
plugin = directory.get_plugin()
mech_mgr = plugin.mechanism_manager
self._mechanism_driver = mech_mgr.mech_drivers['apic_aim'].obj
return self._mechanism_driver

View File

@ -35,12 +35,12 @@ from neutron.db import models_v2
from neutron.db import rbac_db_models
from neutron.db import segments_db
from neutron.extensions import portbindings
from neutron import manager
from neutron.plugins.common import constants as pconst
from neutron.plugins.ml2 import driver_api as api
from neutron.plugins.ml2 import models
from neutron_lib import constants as n_constants
from neutron_lib import exceptions as n_exceptions
from neutron_lib.plugins import directory
from opflexagent import constants as ofcst
from opflexagent import rpc as ofrpc
from oslo_config import cfg
@ -501,6 +501,11 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
original = context.original
LOG.debug("APIC AIM MD updating subnetpool: %s", current)
if 'address_scope_id' not in current:
# address_scope_id may not be returned with update,
# when "Fields" parameter is specified
# TODO(annak): verify this
return
session = context._plugin_context.session
current_scope_id = current['address_scope_id']
@ -584,7 +589,7 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
self.aim.delete(aim_ctx, vrf)
session.delete(mapping)
def extend_address_scope_dict(self, session, scope_db, result):
def extend_address_scope_dict(self, session, scope, result):
LOG.debug("APIC AIM MD extending dict for address scope: %s", result)
# REVISIT: Consider moving to ApicExtensionDriver.
@ -593,7 +598,7 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
dist_names = {}
aim_ctx = aim_context.AimContext(session)
mapping = scope_db.aim_mapping
mapping = self._get_address_scope_mapping(session, scope.id)
if mapping:
vrf = self._get_address_scope_vrf(mapping)
dist_names[cisco_apic.VRF] = vrf.dn
@ -1034,15 +1039,15 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
if ports_to_notify:
self._notify_port_update_bulk(context, ports_to_notify)
def remove_router_interface(self, context, router_id, port_db, subnets):
def remove_router_interface(self, context, router_id, port, subnets):
LOG.debug("APIC AIM MD removing subnets %(subnets)s from router "
"%(router)s as interface port %(port)s",
{'subnets': subnets, 'router': router_id, 'port': port_db})
{'subnets': subnets, 'router': router_id, 'port': port})
session = context.session
aim_ctx = aim_context.AimContext(session)
network_id = port_db.network_id
network_id = port['network_id']
network_db = self.plugin._get_network(context, network_id)
# Find the address_scope(s) for the old interface.
@ -1062,7 +1067,7 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
# Remove AIM Subnet(s) for each removed Neutron subnet.
for subnet in subnets:
gw_ip = self._ip_for_subnet(subnet, port_db.fixed_ips)
gw_ip = self._ip_for_subnet(subnet, port['fixed_ips'])
sn = self._map_subnet(subnet, gw_ip, bd)
self.aim.delete(aim_ctx, sn)
@ -1393,21 +1398,19 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
@property
def plugin(self):
if not self._core_plugin:
self._core_plugin = manager.NeutronManager.get_plugin()
self._core_plugin = directory.get_plugin()
return self._core_plugin
@property
def l3_plugin(self):
if not self._l3_plugin:
plugins = manager.NeutronManager.get_service_plugins()
self._l3_plugin = plugins[pconst.L3_ROUTER_NAT]
self._l3_plugin = directory.get_plugin(n_constants.L3)
return self._l3_plugin
@property
def gbp_plugin(self):
if not self._gbp_plugin:
self._gbp_plugin = (manager.NeutronManager.get_service_plugins()
.get("GROUP_POLICY"))
self._gbp_plugin = directory.get_plugin("GROUP_POLICY")
return self._gbp_plugin
@property

View File

@ -201,15 +201,15 @@ from sqlalchemy.orm import exc
# REVISIT: This method gets decorated in Pike for removal in Queens. So this
# patching might need to be changed in Pike and removed in Queens.
def patched_get_locked_port_and_binding(session, port_id):
def patched_get_locked_port_and_binding(context, port_id):
"""Get port and port binding records for update within transaction."""
LOG.debug("Using patched_get_locked_port_and_binding")
try:
port = (session.query(models_v2.Port).
port = (context.session.query(models_v2.Port).
enable_eagerloads(False).
filter_by(id=port_id).
one())
binding = (session.query(models.PortBinding).
binding = (context.session.query(models.PortBinding).
enable_eagerloads(False).
filter_by(port_id=port_id).
one())

View File

@ -177,7 +177,7 @@ class Ml2PlusPlugin(ml2_plugin.Ml2Plugin,
"subnet_after_delete events"))
self._setup_dhcp()
self._start_rpc_notifiers()
self.add_agent_status_check(self.agent_health_check)
self.add_agent_status_check_worker(self.agent_health_check)
self._verify_service_plugins_requirements()
self.refresh_network_db_obj = cfg.CONF.ml2plus.refresh_network_db_obj
self.refresh_port_db_obj = cfg.CONF.ml2plus.refresh_port_db_obj
@ -229,13 +229,13 @@ class Ml2PlusPlugin(ml2_plugin.Ml2Plugin,
self.extension_manager.extend_subnetpool_dict(
session, subnetpooldb, result)
def _ml2_md_extend_address_scope_dict(self, result, address_scopedb):
def _ml2_md_extend_address_scope_dict(self, result, address_scope):
session = patch_neutron.get_current_session()
with session.begin(subtransactions=True):
if self.refresh_address_scope_db_obj:
session.refresh(address_scopedb)
session.refresh(address_scope)
self.extension_manager.extend_address_scope_dict(
session, address_scopedb, result)
session, address_scope, result)
# Base version does not call _apply_dict_extend_functions()
def _make_address_scope_dict(self, address_scope, fields=None):

View File

@ -20,7 +20,7 @@ from neutron.db import dns_db
from neutron.db import extraroute_db
from neutron.db import l3_gwmode_db
from neutron.extensions import l3
from neutron.plugins.common import constants
from neutron_lib import constants
from neutron_lib import exceptions
from oslo_log import log as logging
from oslo_utils import excutils
@ -47,7 +47,7 @@ class ApicL3Plugin(common_db_mixin.CommonDbMixin,
@staticmethod
def get_plugin_type():
return constants.L3_ROUTER_NAT
return constants.L3
@staticmethod
def get_plugin_description():

View File

@ -114,6 +114,11 @@ opts = [
"False to avoid recreating the implicit contracts "
"on subsequent Neutron server restarts. This "
"option will be removed in the O release")),
cfg.BoolOpt('advertise_mtu',
default=True,
help=_('If True, advertise network MTU values if core plugin '
'calculates them. MTU is advertised to running '
'instances via DHCP and RA MTU options.')),
]
cfg.CONF.register_opts(opts, "aim_mapping")
@ -182,7 +187,7 @@ class AIMMappingDriver(nrd.CommonNeutronBase, aim_rpc.AIMMappingRPCMixin):
self.create_per_l3p_implicit_contracts = (
cfg.CONF.aim_mapping.create_per_l3p_implicit_contracts)
self.setup_opflex_rpc_listeners()
self.advertise_mtu = cfg.CONF.advertise_mtu
self.advertise_mtu = cfg.CONF.aim_mapping.advertise_mtu
local_api.QUEUE_OUT_OF_PROCESS_NOTIFICATIONS = True
if self.create_per_l3p_implicit_contracts:
LOG.info(_LI('Implicit AIM contracts will be created '

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron import manager as n_manager
from neutron_lib.plugins import directory
from oslo_log import log as logging
from gbpservice._i18n import _LI
@ -40,8 +40,7 @@ class AIMExtensionDriver(api.ExtensionDriver,
@property
def _pd(self):
if not self._policy_driver:
gbp_plugin = (n_manager.NeutronManager.get_service_plugins()
.get("GROUP_POLICY"))
gbp_plugin = directory.get_plugin("GROUP_POLICY")
policy_mgr = gbp_plugin.policy_driver_manager
self._policy_driver = policy_mgr.policy_drivers['aim_mapping'].obj
return self._policy_driver

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron import manager
from neutron_lib.plugins import directory
from oslo_log import helpers as log
from gbpservice.network.neutronv2 import local_api
@ -40,8 +40,7 @@ class CommonNeutronBase(ipd.ImplicitPolicyBase, rmd.OwnedResourcesOperations,
@property
def gbp_plugin(self):
if not self._gbp_plugin:
self._gbp_plugin = (manager.NeutronManager.get_service_plugins()
.get("GROUP_POLICY"))
self._gbp_plugin = directory.get_plugin("GROUP_POLICY")
return self._gbp_plugin
@log.log_method_call

View File

@ -3112,7 +3112,7 @@ class ResourceMappingDriver(api.PolicyDriver, ImplicitResourceOperations,
attrs = {
'name': 'gbp_' + context.current['name'],
'description': 'Group-Based Policy QoS policy',
'tenant_id': context.current['tenant_id']}
'project_id': context.current['tenant_id']}
qos_policy = self._create_qos_policy(context._plugin_context, attrs)
qos_policy_id = qos_policy['id']
return qos_policy_id

View File

@ -16,10 +16,10 @@ import six
from neutron import context as n_ctx
from neutron.db import api as db_api
from neutron.extensions import portbindings
from neutron import manager as n_manager
from neutron.plugins.common import constants as pconst
from neutron.quota import resource_registry
from neutron_lib import constants
from neutron_lib.plugins import directory
from oslo_log import helpers as log
from oslo_log import log as logging
from oslo_utils import excutils
@ -73,8 +73,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
def servicechain_plugin(self):
# REVISIT(rkukura): Need initialization method after all
# plugins are loaded to grab and store plugin.
plugins = n_manager.NeutronManager.get_service_plugins()
servicechain_plugin = plugins.get(pconst.SERVICECHAIN)
servicechain_plugin = directory.get_plugin(pconst.SERVICECHAIN)
if not servicechain_plugin:
LOG.error(_LE("No Servicechain service plugin found."))
raise gp_exc.GroupPolicyDeploymentError()
@ -287,7 +286,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
# Verify segment CIDR doesn't overlap with L3P's
cidr = es['cidr']
if es['subnet_id']:
core_plugin = n_manager.NeutronManager.get_plugin()
core_plugin = directory.get_plugin()
cidr = core_plugin.get_subnet(context,
es['subnet_id'])['cidr']
if l3p_ipset & netaddr.IPSet([cidr]):
@ -1750,7 +1749,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
not_bound = [portbindings.VIF_TYPE_UNBOUND,
portbindings.VIF_TYPE_BINDING_FAILED]
context = n_ctx.get_admin_context()
port = n_manager.NeutronManager.get_plugin().get_port(context, port_id)
port = directory.get_plugin().get_port(context, port_id)
return (port.get('binding:vif_type') not in not_bound) and port.get(
'binding:host_id') and (port['device_owner'] or port['device_id'])

View File

@ -10,8 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron import manager
from neutron.plugins.common import constants as pconst
from neutron_lib import constants
from neutron_lib.plugins import directory
from gbpservice.common import utils
from gbpservice.neutron.services.grouppolicy.drivers import resource_mapping
@ -19,7 +19,7 @@ from gbpservice.neutron.services.servicechain.plugins.ncp import model
def get_gbp_plugin():
return manager.NeutronManager.get_service_plugins().get("GROUP_POLICY")
return directory.get_plugin("GROUP_POLICY")
def get_node_driver_context(sc_plugin, context, sc_instance,
@ -127,9 +127,8 @@ class NodeDriverContext(object):
self._classifier = classifier
self._is_consumer_external = is_consumer_external
self._relevant_specs = None
self._core_plugin = manager.NeutronManager.get_plugin()
self._l3_plugin = manager.NeutronManager.get_service_plugins().get(
pconst.L3_ROUTER_NAT)
self._core_plugin = directory.get_plugin()
self._l3_plugin = directory.get_plugin(constants.L3)
self._position = position
@property

View File

@ -10,8 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron import manager
from neutron_lib import constants
from neutron_lib.plugins import directory
from oslo_config import cfg
from oslo_log import log as logging
@ -54,15 +54,13 @@ class TrafficStitchingPlumber(plumber_base.NodePlumberBase):
@property
def gbp_plugin(self):
if not self._gbp_plugin:
self._gbp_plugin = (manager.NeutronManager.get_service_plugins()
.get("GROUP_POLICY"))
self._gbp_plugin = directory.get_plugin("GROUP_POLICY")
return self._gbp_plugin
@property
def sc_plugin(self):
if not self._sc_plugin:
self._sc_plugin = (manager.NeutronManager.get_service_plugins()
.get("SERVICECHAIN"))
self._sc_plugin = directory.get_plugin("SERVICECHAIN")
return self._sc_plugin
def plug_services(self, context, deployment):

View File

@ -10,8 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron import manager as n_manager
from neutron.plugins.common import constants as pconst
from neutron_lib.plugins import directory
from oslo_log import log as logging
from gbpservice._i18n import _LE
@ -40,8 +40,7 @@ class SharingMixin(object):
def gbp_plugin(self):
# REVISIT(rkukura): Need initialization method after all
# plugins are loaded to grab and store plugin.
plugins = n_manager.NeutronManager.get_service_plugins()
gbp_plugin = plugins.get(pconst.GROUP_POLICY)
gbp_plugin = directory.get_plugin(pconst.GROUP_POLICY)
if not gbp_plugin:
LOG.error(_LE("No group policy service plugin found."))
raise gp_exc.GroupPolicyDeploymentError()

View File

@ -21,12 +21,13 @@ from neutron.api import extensions
from neutron.api.rpc.callbacks.producer import registry
from neutron import context
from neutron.db import api as db_api
from neutron import manager
from neutron.plugins.common import constants
from neutron import policy
from neutron.tests.unit.api import test_extensions
from neutron.tests.unit.db import test_db_base_plugin_v2
from neutron_lib import constants as nl_constants
from neutron_lib.db import model_base
from neutron_lib.plugins import directory
from oslo_utils import importutils
from oslo_utils import uuidutils
@ -175,7 +176,7 @@ class ApiManagerMixin(object):
return self.deserialize(self.fmt, res)
def _bind_port_to_host(self, port_id, host, data=None):
plugin = manager.NeutronManager.get_plugin()
plugin = directory.get_plugin()
ctx = context.get_admin_context()
agent = {'host': host}
agent.update(self.agent_conf)
@ -365,13 +366,13 @@ class GroupPolicyDbTestCase(GroupPolicyDBTestBase,
if not ext_mgr:
ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
self.ext_api = test_extensions.setup_extensions_middleware(ext_mgr)
engine = db_api.get_engine()
engine = db_api.context_manager.writer.get_engine()
model_base.BASEV2.metadata.create_all(engine)
plugins = manager.NeutronManager.get_service_plugins()
plugins = directory.get_plugins()
self._gbp_plugin = plugins.get(constants.GROUP_POLICY)
self._sc_plugin = plugins.get(constants.SERVICECHAIN)
self._l3_plugin = plugins.get(constants.L3_ROUTER_NAT)
self._l3_plugin = plugins.get(nl_constants.L3)
self._set_notification_mocks()
def tearDown(self):

View File

@ -59,7 +59,7 @@ class GroupPolicyMappingDbTestCase(tgpdb.GroupPolicyDbTestCase,
core_plugin=core_plugin, gp_plugin=gp_plugin,
service_plugins=service_plugins
)
engine = db_api.get_engine()
engine = db_api.context_manager.writer.get_engine()
model_base.BASEV2.metadata.create_all(engine)

View File

@ -33,7 +33,7 @@ class SqlFixture(fixtures.Fixture):
def _setUp(self):
# Register all data models
engine = db_api.get_engine()
engine = db_api.context_manager.writer.get_engine()
if not SqlFixture._TABLES_ESTABLISHED:
nfp_db_model.BASE.metadata.create_all(engine)
SqlFixture._TABLES_ESTABLISHED = True

View File

@ -16,6 +16,7 @@
from neutron.api import extensions
from neutron.db.models import address_scope as as_db
from neutron.db import models_v2
from neutron.objects import address_scope as as_object
from neutron_lib.api import validators
from neutron_lib.db import model_base
import oslo_db.sqlalchemy.session
@ -95,9 +96,9 @@ class TestExtensionDriver(TestExtensionDriverBase):
result['address_scope_extension'] = (self.address_scope_extension +
'_update')
def extend_address_scope_dict(self, session, address_scope_db, result):
self._check_extend(session, result, address_scope_db,
as_db.AddressScope)
def extend_address_scope_dict(self, session, address_scope, result):
self._check_extend(session, result, address_scope,
as_object.AddressScope)
result['address_scope_extension'] = (self.address_scope_extension +
'_extend')
@ -149,9 +150,9 @@ class TestDBExtensionDriver(TestExtensionDriverBase):
result['subnetpool_extension'] = record.value
def extend_subnetpool_dict(self, session, subnetpool_db, result):
value = (subnetpool_db.extension.value
if subnetpool_db.extension else '')
result['subnetpool_extension'] = value
record = (session.query(TestSubnetPoolExtension).
filter_by(subnetpool_id=result['id']).one_or_none())
result['subnetpool_extension'] = record.value if record else ''
def process_create_address_scope(self, plugin_context, data, result):
session = plugin_context.session
@ -170,7 +171,7 @@ class TestDBExtensionDriver(TestExtensionDriverBase):
record.value = value
result['address_scope_extension'] = record.value
def extend_address_scope_dict(self, session, address_scope_db, result):
value = (address_scope_db.extension.value
if address_scope_db.extension else '')
result['address_scope_extension'] = value
def extend_address_scope_dict(self, session, address_scope, result):
record = (session.query(TestAddressScopeExtension).
filter_by(address_scope_id=result['id']).one_or_none())
result['address_scope_extension'] = record.value if record else ''

View File

@ -13,9 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.api import extensions
from neutron.api.v2 import attributes as attr
from neutron.extensions import address_scope as as_ext
from neutron_lib.api import extensions
from neutron_lib import constants
from gbpservice._i18n import _

View File

@ -32,15 +32,14 @@ from neutron.api import extensions
from neutron.callbacks import registry
from neutron import context as n_context
from neutron.db import api as db_api
from neutron import manager
from neutron.plugins.common import constants as service_constants
from neutron.db import segments_db
from neutron.plugins.ml2 import config
from neutron.plugins.ml2 import db as ml2_db
from neutron.tests.unit.api import test_extensions
from neutron.tests.unit.db import test_db_base_plugin_v2 as test_plugin
from neutron.tests.unit.extensions import test_address_scope
from neutron.tests.unit.extensions import test_l3
from neutron_lib import constants as n_constants
from neutron_lib.plugins import directory
from opflexagent import constants as ofcst
import webob.exc
@ -181,7 +180,7 @@ class ApicAimTestCase(test_address_scope.AddressScopeTestCase,
super(ApicAimTestCase, self).setUp(PLUGIN_NAME,
service_plugins=service_plugins)
engine = db_api.get_engine()
engine = db_api.context_manager.writer.get_engine()
aim_model_base.Base.metadata.create_all(engine)
self.db_session = db_api.get_session()
self.initialize_db_config(self.db_session)
@ -192,12 +191,11 @@ class ApicAimTestCase(test_address_scope.AddressScopeTestCase,
self.saved_keystone_client = ksc_client.Client
ksc_client.Client = FakeKeystoneClient
self.plugin = manager.NeutronManager.get_plugin()
self.plugin = directory.get_plugin()
self.plugin.start_rpc_listeners()
self.driver = self.plugin.mechanism_manager.mech_drivers[
'apic_aim'].obj
self.l3_plugin = manager.NeutronManager.get_service_plugins()[
service_constants.L3_ROUTER_NAT]
self.l3_plugin = directory.get_plugin(n_constants.L3)
self.aim_mgr = aim_manager.AimManager()
self._app_profile_name = self.driver.ap_name
self.extension_attributes = ('router:external', DN,
@ -212,7 +210,7 @@ class ApicAimTestCase(test_address_scope.AddressScopeTestCase,
self.t1_aname)
def tearDown(self):
engine = db_api.get_engine()
engine = db_api.context_manager.writer.get_engine()
with engine.begin() as conn:
for table in reversed(
aim_model_base.Base.metadata.sorted_tables):
@ -4613,8 +4611,8 @@ class TestPortVlanNetwork(ApicAimTestCase):
return port_context.bottom_bound_segment['segmentation_id']
def _check_no_dynamic_segment(self, network_id):
dyn_segments = ml2_db.get_network_segments(
n_context.get_admin_context().session, network_id,
dyn_segments = segments_db.get_network_segments(
n_context.get_admin_context(), network_id,
filter_dynamic=True)
self.assertEqual(0, len(dyn_segments))

View File

@ -14,12 +14,11 @@
# under the License.
import mock
import unittest2
import uuid
from neutron import context
from neutron import manager
from neutron.plugins.ml2 import config
from neutron_lib.plugins import directory
from gbpservice.neutron.tests.unit.plugins.ml2plus.drivers import (
extension_test as ext_test)
@ -35,7 +34,7 @@ class ExtensionDriverTestCase(test_plugin.Ml2PlusPluginV2TestCase):
self._extension_drivers,
group='ml2')
super(ExtensionDriverTestCase, self).setUp()
self._plugin = manager.NeutronManager.get_plugin()
self._plugin = directory.get_plugin()
self._ctxt = context.get_admin_context()
def _verify_subnetpool_create(self, code, exc_reason):
@ -92,12 +91,6 @@ class ExtensionDriverTestCase(test_plugin.Ml2PlusPluginV2TestCase):
self._verify_subnetpool_update(subnetpool, 400,
'ExtensionDriverError')
# REVISIT: Neutron detaches objects from the session, hence the following
# test does not work. This has to be fixed as is done in the following
# commit:
# https://github.com/openstack/neutron/commit/
# 7e822960425326f26806bbfb650b8a844f38557d
@unittest2.skip('skipping')
def test_subnetpool_attr(self):
with self.subnetpool(['10.0.0.0/8'], name='sp1',
tenant_id='t1') as subnetpool:
@ -168,7 +161,7 @@ class ExtensionDriverTestCase(test_plugin.Ml2PlusPluginV2TestCase):
address_scope, tenant_id = self._verify_address_scope_create(
500, 'HTTPInternalServerError')
# Verify the operation is rolled back
query_params = "tenant_id=%s" % tenant_id
query_params = "project_id=%s" % tenant_id
address_scopes = self._list('address-scopes',
query_params=query_params)
self.assertFalse(address_scopes['address_scopes'])
@ -233,15 +226,9 @@ class DBExtensionDriverTestCase(test_plugin.Ml2PlusPluginV2TestCase):
self._extension_drivers,
group='ml2')
super(DBExtensionDriverTestCase, self).setUp()
self._plugin = manager.NeutronManager.get_plugin()
self._plugin = directory.get_plugin()
self._ctxt = context.get_admin_context()
# REVISIT: Neutron detaches objects from the session, hence the following
# test does not work. This has to be fixed as is done in the following
# commit:
# https://github.com/openstack/neutron/commit/
# 7e822960425326f26806bbfb650b8a844f38557d
@unittest2.skip('skipping')
def test_subnetpool_attr(self):
with self.subnetpool(['10.0.0.0/8'], name='sp1',
tenant_id='t1') as subnetpool:

View File

@ -16,11 +16,11 @@
import mock
from neutron.api import extensions
from neutron import manager
from neutron.plugins.ml2 import config
from neutron.tests.unit.api import test_extensions
from neutron.tests.unit.db import test_db_base_plugin_v2 as test_plugin
from neutron.tests.unit.extensions import test_address_scope
from neutron_lib.plugins import directory
from gbpservice.neutron.db import implicitsubnetpool_db # noqa
import gbpservice.neutron.extensions
@ -52,7 +52,7 @@ class Ml2PlusPluginV2TestCase(test_address_scope.AddressScopeTestCase):
ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
self.ext_api = test_extensions.setup_extensions_middleware(ext_mgr)
self.port_create_status = 'DOWN'
self.plugin = manager.NeutronManager.get_plugin()
self.plugin = directory.get_plugin()
self.plugin.start_rpc_listeners()
def exist_checker(self, getter):

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.api import extensions
from neutron_lib.api import extensions
from neutron_lib import constants
from gbpservice.neutron.extensions import group_policy as gp

View File

@ -29,15 +29,13 @@ from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
from neutron.callbacks import registry
from neutron import context as nctx
from neutron.db import api as db_api
from neutron import manager
from neutron.notifiers import nova
from neutron.plugins.common import constants as service_constants
from neutron.tests.unit.db import test_db_base_plugin_v2 as test_plugin
from neutron.tests.unit.extensions import test_address_scope
from neutron_lib import constants as n_constants
from neutron_lib.plugins import directory
from opflexagent import constants as ocst
from oslo_config import cfg
from oslo_utils import uuidutils
import webob.exc
from gbpservice.network.neutronv2 import local_api
@ -134,8 +132,7 @@ class AIMBaseTestCase(test_nr_base.CommonNeutronBaseTestCase,
aim_model_base.Base.metadata.create_all(self.engine)
self.db_session = db_api.get_session()
self.initialize_db_config(self.db_session)
self.l3_plugin = manager.NeutronManager.get_service_plugins()[
service_constants.L3_ROUTER_NAT]
self.l3_plugin = directory.get_plugin(n_constants.L3)
config.cfg.CONF.set_override('network_vlan_ranges',
['physnet1:1000:1099'],
group='ml2_type_vlan')
@ -183,7 +180,7 @@ class AIMBaseTestCase(test_nr_base.CommonNeutronBaseTestCase,
self._dn_t1_l1_n1 = ('uni/tn-%s/out-l1/instP-n1' % self._t1_aname)
def tearDown(self):
engine = db_api.get_engine()
engine = db_api.context_manager.writer.get_engine()
with engine.begin() as conn:
for table in reversed(
aim_model_base.Base.metadata.sorted_tables):
@ -1543,7 +1540,8 @@ class TestL3PolicyRollback(AIMBaseTestCase):
self.dummy.create_l3_policy_precommit = mock.Mock(
side_effect=Exception)
self.create_l3_policy(name="l3p1", expected_res_status=500)
self.assertEqual([], self._plugin.get_address_scopes(self._context))
self.assertEqual([], self._plugin.get_address_scopes(self._context,
filters={}))
self.assertEqual([], self._plugin.get_subnetpools(self._context,
filters={}))
self.assertEqual([], self._l3_plugin.get_routers(self._context))
@ -1574,7 +1572,8 @@ class TestL3PolicyRollback(AIMBaseTestCase):
self.delete_l3_policy(l3p_id, expected_res_status=500)
self.show_l3_policy(l3p_id, expected_res_status=200)
self.assertEqual(
1, len(self._plugin.get_address_scopes(self._context)))
1, len(self._plugin.get_address_scopes(self._context,
filters={})))
self.assertEqual(1, len(self._plugin.get_subnetpools(self._context,
filters={})))
self.assertEqual(1, len(self._l3_plugin.get_routers(self._context)))
@ -1852,7 +1851,8 @@ class TestL2PolicyWithAutoPTG(TestL2PolicyBase):
expected_res_status=200)['l2_policy']
l3p = self.show_l3_policy(l2p['l3_policy_id'],
expected_res_status=200)['l3_policy']
ascopes = self._plugin.get_address_scopes(self._context)
ascopes = self._plugin.get_address_scopes(self._context,
filters={})
self.assertEqual(l3p['address_scope_v4_id'], ascopes[0]['id'])
subpools = self._plugin.get_subnetpools(self._context, filters={})
self.assertEqual(l3p['subnetpools_v4'], [subpools[0]['id']])
@ -1920,7 +1920,8 @@ class TestL2PolicyWithAutoPTG(TestL2PolicyBase):
self.assertEqual([], self._plugin.get_ports(self._context))
self.assertEqual([], self._plugin.get_subnets(self._context))
self.assertEqual([], self._plugin.get_networks(self._context))
self.assertEqual([], self._plugin.get_address_scopes(self._context))
self.assertEqual([], self._plugin.get_address_scopes(self._context,
filters={}))
self.assertEqual([], self._plugin.get_subnetpools(self._context,
filters={}))
self.assertEqual([], self._l3_plugin.get_routers(self._context))
@ -2582,7 +2583,7 @@ class TestPolicyTarget(AIMBaseTestCase):
super(TestPolicyTarget, self).setUp(*args, **kwargs)
cfg.CONF.set_override('path_mtu', 1000, group='ml2')
cfg.CONF.set_override('global_physnet_mtu', 1000, None)
cfg.CONF.set_override('advertise_mtu', True, None)
cfg.CONF.set_override('advertise_mtu', True, group='aim_mapping')
def test_policy_target_lifecycle_implicit_port(self):
ptg = self.create_policy_target_group(
@ -3560,41 +3561,15 @@ class NotificationTest(AIMBaseTestCase):
def setUp(self, policy_drivers=None, core_plugin=None, ml2_options=None,
l3_plugin=None, sc_plugin=None, **kwargs):
self.fake_uuid = 0
self.mac_prefix = '12:34:56:78:5d:'
self.queue_notification_call_count = 0
self.max_notification_queue_length = 0
self.notification_queue = None
self.post_notifications_from_queue_call_count = 0
self.orig_generate_uuid = uuidutils.generate_uuid
self.orig_is_uuid_like = uuidutils.is_uuid_like
# The following three functions are patched so that
# the same worflow can be run more than once in a single
# test and will result in objects created that are
# identical in all their attribute values.
# The workflow is exercised once with batching turned
# OFF, and once with batching turned ON.
def generate_uuid():
self.fake_uuid += 1
return str(self.fake_uuid)
def is_uuid_like(val):
return True
def _generate_mac():
lsb = 10 + self.fake_uuid
return self.mac_prefix + str(lsb)
uuidutils.generate_uuid = generate_uuid
uuidutils.is_uuid_like = is_uuid_like
super(NotificationTest, self).setUp(
policy_drivers=policy_drivers, core_plugin=core_plugin,
ml2_options=ml2_options, l3_plugin=l3_plugin,
sc_plugin=sc_plugin, **kwargs)
self.orig_generate_mac = self._plugin._generate_mac
self._plugin._generate_mac = _generate_mac
self.orig_enqueue = local_api._enqueue
@ -3631,7 +3606,8 @@ class NotificationTest(AIMBaseTestCase):
session, transaction_key, resource, event, trigger, **kwargs):
self.orig_send_or_queue_registry_notification(session,
transaction_key, resource, event, trigger, **kwargs)
self.notification_queue = session.notification_queue
if session:
self.notification_queue = session.notification_queue
local_api.send_or_queue_registry_notification = (
send_or_queue_registry_notification)
@ -3659,9 +3635,6 @@ class NotificationTest(AIMBaseTestCase):
def tearDown(self):
super(NotificationTest, self).tearDown()
self._plugin._generate_mac = self.orig_generate_mac
uuidutils.generate_uuid = self.orig_generate_uuid
uuidutils.is_uuid_like = self.orig_is_uuid_like
local_api.QUEUE_OUT_OF_PROCESS_NOTIFICATIONS = False
local_api._enqueue = self.orig_enqueue
local_api.send_or_queue_notification = (
@ -3712,13 +3685,41 @@ class NotificationTest(AIMBaseTestCase):
# test that no notifications have been left out
self.assertEqual({}, self.notification_queue)
def _deep_replace_in_value(self, d, str1, str2):
for k, v in d.items():
if isinstance(v, str) and str1 in v:
d[k] = v.replace(str1, str2)
if isinstance(v, dict):
self._deep_replace_in_value(v, str1, str2)
def _deep_replace_by_key(self, d, key, str2):
if not isinstance(d, dict):
return
if key in d:
d[key] = str2
for k, v in d.items():
if isinstance(v, dict):
self._deep_replace_by_key(v, key, str2)
if isinstance(v, list):
for i in v:
self._deep_replace_by_key(i, key, str2)
def _test_notifications(self, no_batch, with_batch):
for n1, n2 in zip(no_batch, with_batch):
# temporary workaround
if 'port' in n1[0][1]:
# ip address assignment is random, hence do not compare
n1[0][1]['port']['fixed_ips'][0]['ip_address'] = ''
n2[0][1]['port']['fixed_ips'][0]['ip_address'] = ''
# replace ids from resource dicts since its random
# id can appear in inner dictionaries: we use deep replace
for n in [n1, n2]:
for resource, dct in n[0][1].items():
if 'id' in dct:
self._deep_replace_in_value(dct, dct['id'], 'XXX')
for random_key in ('subnetpool_id', 'network_id',
'mac_address', 'subnet_id',
'ip_address', 'device_id',
'security_groups', 'id'):
self._deep_replace_by_key(dct, random_key, 'XXX')
# test the resource objects are identical with and without batch
self.assertEqual(n1[0][1], n2[0][1])
# test that all the same events are pushed with and without batch
@ -3742,6 +3743,7 @@ class NotificationTest(AIMBaseTestCase):
self.assertLess(0, self.queue_notification_call_count)
self.assertLess(0, self.max_notification_queue_length)
# There are 4 transactions - one for create PTG,
# one for create PT, one for delete PT, and one for
# delete PTG. Delete PT notification is sent without queueing,

View File

@ -30,7 +30,7 @@ class ImplicitPolicyTestCase(
cfg.CONF.set_override('policy_drivers', ['implicit_policy'],
group='group_policy')
super(ImplicitPolicyTestCase, self).setUp()
engine = db_api.get_engine()
engine = db_api.context_manager.writer.get_engine()
model_base.BASEV2.metadata.create_all(engine)

View File

@ -14,9 +14,10 @@
import mock
from neutron import context as nctx
from neutron.db import api as db_api
from neutron import manager
from neutron.plugins.common import constants as pconst
from neutron_lib import constants
from neutron_lib.db import model_base
from neutron_lib.plugins import directory
import webob.exc
from gbpservice.neutron.services.grouppolicy import config
@ -51,18 +52,17 @@ class CommonNeutronBaseTestCase(test_plugin.GroupPolicyPluginTestBase):
ml2_options=ml2_options,
sc_plugin=sc_plugin,
qos_plugin=qos_plugin)
engine = db_api.get_engine()
engine = db_api.context_manager.writer.get_engine()
model_base.BASEV2.metadata.create_all(engine)
res = mock.patch('neutron.db.l3_db.L3_NAT_dbonly_mixin.'
'_check_router_needs_rescheduling').start()
res.return_value = None
self._plugin = manager.NeutronManager.get_plugin()
self._plugin = directory.get_plugin()
self._plugin.remove_networks_from_down_agents = mock.Mock()
self._plugin.is_agent_down = mock.Mock(return_value=False)
self._context = nctx.get_admin_context()
plugins = manager.NeutronManager.get_service_plugins()
self._gbp_plugin = plugins.get(pconst.GROUP_POLICY)
self._l3_plugin = plugins.get(pconst.L3_ROUTER_NAT)
self._gbp_plugin = directory.get_plugin(pconst.GROUP_POLICY)
self._l3_plugin = directory.get_plugin(constants.L3)
config.cfg.CONF.set_override('debug', True)
def get_plugin_context(self):
@ -110,8 +110,8 @@ class TestL2PolicyRollback(CommonNeutronBaseTestCase):
core_plugin=core_plugin,
ml2_options=ml2_options,
sc_plugin=sc_plugin)
self.dummy_driver = manager.NeutronManager.get_service_plugins()[
'GROUP_POLICY'].policy_driver_manager.policy_drivers['dummy'].obj
self.dummy_driver = directory.get_plugin(
'GROUP_POLICY').policy_driver_manager.policy_drivers['dummy'].obj
def test_l2_policy_create_fail(self):
orig_func = self.dummy_driver.create_l2_policy_precommit

View File

@ -23,13 +23,13 @@ from neutron.db import api as db_api
from neutron.db.qos import models as qos_models
from neutron.extensions import external_net as external_net
from neutron.extensions import securitygroup as ext_sg
from neutron import manager
from neutron.plugins.common import constants as pconst
from neutron.tests.unit.extensions import test_l3
from neutron.tests.unit.extensions import test_securitygroup
from neutron.tests.unit.plugins.ml2 import test_plugin as n_test_plugin
from neutron_lib import constants as cst
from neutron_lib.db import model_base
from neutron_lib.plugins import directory
from oslo_utils import uuidutils
import unittest2
import webob.exc
@ -97,18 +97,17 @@ class ResourceMappingTestCase(test_plugin.GroupPolicyPluginTestCase):
sc_plugin=sc_plugin,
qos_plugin=qos_plugin)
engine = db_api.get_engine()
engine = db_api.context_manager.writer.get_engine()
model_base.BASEV2.metadata.create_all(engine)
res = mock.patch('neutron.db.l3_db.L3_NAT_dbonly_mixin.'
'_check_router_needs_rescheduling').start()
res.return_value = None
self._plugin = manager.NeutronManager.get_plugin()
self._plugin = directory.get_plugin()
self._plugin.remove_networks_from_down_agents = mock.Mock()
self._plugin.is_agent_down = mock.Mock(return_value=False)
self._context = nctx.get_admin_context()
plugins = manager.NeutronManager.get_service_plugins()
self._gbp_plugin = plugins.get(pconst.GROUP_POLICY)
self._l3_plugin = plugins.get(pconst.L3_ROUTER_NAT)
self._gbp_plugin = directory.get_plugin(pconst.GROUP_POLICY)
self._l3_plugin = directory.get_plugin(cst.L3)
self.saved_keystone_client = resource_mapping.k_client.Client
resource_mapping.k_client.Client = mock.Mock()
local_api.QUEUE_OUT_OF_PROCESS_NOTIFICATIONS = False
@ -208,7 +207,7 @@ class ResourceMappingTestCase(test_plugin.GroupPolicyPluginTestCase):
return self.deserialize(self.fmt, req.get_response(self.api))
def _get_sg_rule(self, **filters):
plugin = manager.NeutronManager.get_plugin()
plugin = directory.get_plugin()
context = nctx.get_admin_context()
return plugin.get_security_group_rules(
context, filters)
@ -1887,7 +1886,8 @@ class TestL3Policy(ResourceMappingTestCase):
fmt=self.fmt)
res = self.deserialize(self.fmt,
req.get_response(self.ext_api))
self.assertEqual(routes1, res['router']['routes'])
self.assertEqual(routes1.sort(),
res['router']['routes'].sort())
es_dict = {es2['id']: []}
self.update_l3_policy(l3p['id'],
external_segments=es_dict,
@ -1897,7 +1897,8 @@ class TestL3Policy(ResourceMappingTestCase):
fmt=self.fmt)
res = self.deserialize(self.fmt,
req.get_response(self.ext_api))
self.assertEqual(routes2, res['router']['routes'])
self.assertEqual(routes2.sort(),
res['router']['routes'].sort())
def test_create_l3p_using_different_tenant_router_rejected(self):
with self.router() as router1:

View File

@ -17,10 +17,10 @@ import mock
from neutron.common import config # noqa
from neutron import context as n_context
from neutron.db import api as db_api
from neutron import manager
from neutron.plugins.common import constants as pconst
from neutron_lib.db import model_base
from neutron_lib import exceptions as n_exc
from neutron_lib.plugins import directory
from oslo_config import cfg
from oslo_serialization import jsonutils
@ -65,9 +65,7 @@ class NodeCompositionPluginTestMixin(object):
@property
def sc_plugin(self):
plugins = manager.NeutronManager.get_service_plugins()
servicechain_plugin = plugins.get(pconst.SERVICECHAIN)
return servicechain_plugin
return directory.get_plugin(pconst.SERVICECHAIN)
def _create_service_profile(self, **kwargs):
"""Create service profile wrapper that can be used by drivers."""
@ -145,7 +143,7 @@ class NodeCompositionPluginTestCase(
core_plugin=core_plugin or CORE_PLUGIN,
gp_plugin=gp_plugin or GP_PLUGIN_KLASS,
sc_plugin=SC_PLUGIN_KLASS)
engine = db_api.get_engine()
engine = db_api.context_manager.writer.get_engine()
model_base.BASEV2.metadata.create_all(engine)
self.driver = self.sc_plugin.driver_manager.ordered_drivers[0].obj
@ -809,9 +807,7 @@ class TestQuotasForServiceChain(test_base.ServiceChainPluginTestCase):
@property
def sc_plugin(self):
plugins = manager.NeutronManager.get_service_plugins()
servicechain_plugin = plugins.get(pconst.SERVICECHAIN)
return servicechain_plugin
return directory.get_plugin(pconst.SERVICECHAIN)
def setUp(self, core_plugin=None, gp_plugin=None, node_drivers=None,
node_plumber=None):
@ -828,7 +824,7 @@ class TestQuotasForServiceChain(test_base.ServiceChainPluginTestCase):
core_plugin=core_plugin or CORE_PLUGIN,
gp_plugin=gp_plugin or GP_PLUGIN_KLASS,
sc_plugin=SC_PLUGIN_KLASS)
engine = db_api.get_engine()
engine = db_api.context_manager.writer.get_engine()
model_base.BASEV2.metadata.create_all(engine)
self.driver = self.sc_plugin.driver_manager.ordered_drivers[0].obj
cfg.CONF.set_override('quota_servicechain_node', 1,

View File

@ -193,7 +193,7 @@ class NFPNodeDriverTestCase(
core_plugin=CORE_PLUGIN,
gp_plugin=GP_PLUGIN_KLASS,
sc_plugin=SC_PLUGIN_KLASS)
engine = db_api.get_engine()
engine = db_api.context_manager.writer.get_engine()
model_base.BASEV2.metadata.create_all(engine)
def test_manager_initialized(self):

View File

@ -13,7 +13,7 @@
import mock
from neutron.common import config # noqa
from neutron import context as n_context
from neutron import manager
from neutron_lib.plugins import directory
from oslo_config import cfg
from gbpservice.neutron.services.grouppolicy import (
@ -73,9 +73,7 @@ class ResourceMappingStitchingPlumberGBPTestCase(
@property
def sc_plugin(self):
plugins = manager.NeutronManager.get_service_plugins()
servicechain_plugin = plugins.get('SERVICECHAIN')
return servicechain_plugin
return directory.get_plugin('SERVICECHAIN')
class TestPolicyRuleSet(ResourceMappingStitchingPlumberGBPTestCase,

View File

@ -2,26 +2,26 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
-e git+https://git.openstack.org/openstack/neutron.git@stable/newton#egg=neutron
-e git+https://git.openstack.org/openstack/neutron.git@stable/ocata#egg=neutron
-e git+https://github.com/noironetworks/apicapi.git@master#egg=apicapi
-e git+https://github.com/noironetworks/apicapi.git@sumit/ocata#egg=apicapi
-e git+https://github.com/noironetworks/python-opflex-agent.git@master#egg=python-opflexagent-agent
-e git+https://github.com/noironetworks/apic-ml2-driver.git@master#egg=apic_ml2
-e git+https://github.com/noironetworks/python-opflex-agent.git@sumit/stable/ocata#egg=python-opflexagent-agent
-e git+https://github.com/noironetworks/apic-ml2-driver.git@sumit/ocata#egg=apic_ml2
-e git+https://git.openstack.org/openstack/python-group-based-policy-client@master#egg=gbpclient
-e git+https://git.openstack.org/openstack/neutron-vpnaas@stable/newton#egg=neutron-vpnaas
-e git+https://git.openstack.org/openstack/neutron-lbaas@stable/newton#egg=neutron-lbaas
-e git+https://git.openstack.org/openstack/neutron-fwaas@stable/newton#egg=neutron-fwaas
-e git+https://git.openstack.org/openstack/neutron-vpnaas@stable/ocata#egg=neutron-vpnaas
-e git+https://git.openstack.org/openstack/neutron-lbaas@stable/ocata#egg=neutron-lbaas
-e git+https://git.openstack.org/openstack/neutron-fwaas@stable/ocata#egg=neutron-fwaas
hacking<0.12,>=0.11.0 # Apache-2.0
cliff>=1.15.0 # Apache-2.0
coverage>=3.6 # Apache-2.0
cliff>=2.3.0 # Apache-2.0
coverage>=4.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD
httplib2>=0.7.5
mock>=2.0 # BSD
python-subunit>=0.0.18 # Apache-2.0/BSD
requests-mock>=1.0 # Apache-2.0
requests-mock>=1.1 # Apache-2.0
sphinx!=1.3b1,<1.3,>=1.2.1 # BSD
ordereddict
testrepository>=0.0.18 # Apache-2.0/BSD
@ -30,11 +30,11 @@ testresources>=0.2.4 # Apache-2.0/BSD
testscenarios>=0.4 # Apache-2.0/BSD
WebTest>=2.0 # MIT
oslotest>=1.10.0 # Apache-2.0
os-testr>=0.7.0 # Apache-2.0
os-testr>=0.8.0 # Apache-2.0
ddt>=1.0.1 # MIT
pylint==1.4.5 # GNU GPL v2
reno>=1.8.0 # Apache2
pyOpenSSL>=0.13.0,<=0.15.1
pyOpenSSL>=0.14.0,<=0.15.1
# Since version numbers for these are specified in
# https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt,
@ -45,4 +45,4 @@ python-keystoneclient
# REVISIT: Until co-gating and/or stable branches are implemented for the
# aci-integration-module repo, it may be necessary to pin to a working
# commit.
-e git+https://github.com/noironetworks/aci-integration-module.git@master#egg=aci-integration-module
-e git+https://github.com/noironetworks/aci-integration-module.git@sumit/ocata#egg=aci-integration-module

View File

@ -9,7 +9,7 @@ setenv = VIRTUAL_ENV={envdir}
passenv = TRACE_FAILONLY GENERATE_HASHES http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
usedevelop = True
install_command =
pip install -U -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/newton} {opts} {packages}
pip install -U -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/ocata} {opts} {packages}
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
whitelist_externals = sh