Cleanup Queens

Remove code no longer needed now that stable/queens is the oldest
supported branch, and enhance compatabilty with newer neutron
branches. Highlights include:

* Use definitions from neutron_lib where appropriate.

* Add gbpservice.neutron.db.api wrapper for definitions in
  neutron_lib.db.api in stable/rocky and newer that aren't moved yet
  in stable/queens, so that most DB code can remain unchanged across
  branches. In particular, this replaces db_api.context_manager.reader
  with db_api.CONTEXT_READER and db_api.context_manager.writer with
  db_api.CONTEXT_WRITER.

* Eliminate some DeprecationWarning messages, such as those due to
  'tenant' being renamed 'project'.

* [AIM] Remove validation tool support for migrating SNAT resources
  from the legacy ACI plugin.

* [AIM] Fix make_port_context to use a CONTEXT_WRITER instead of a
  CONTEXT_READER, since it can call get_network, which uses a
  CONTEXT_WRITER and transactions cannot be upgraded from read-only to
  read-write.

* [AIM] Change UTs to use make_port_context instead of
  get_bound_port_context to prevent trying to bind the port if its not
  already bound.

* [AIM] Remove quota-related monkey-patching that is no longer needed
  due to previous technical debt cleanup.

* [AIM] Use the registry.receives decorator instead of calling
  registry.subscribe.

* [AIM] Fix TypeError in _agent_bind_port.

* [AIM] Simplify _net_2_epg function in test_apic_aim UT module.

Change-Id: I01d57debd6884032267a6b7675883b6d1e61afcc
This commit is contained in:
Robert Kukura 2020-04-06 18:05:22 -04:00
parent dc1f262a6d
commit 7f460160d6
47 changed files with 361 additions and 822 deletions

View File

@ -10,7 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import contextlib
import sys
from neutron_lib import context as n_context
@ -25,18 +24,6 @@ LOG = logging.getLogger(__name__)
cfg.CONF.import_group('keystone_authtoken', 'keystonemiddleware.auth_token')
# REVISIT: Avoid using this in new code, and remove it when no longer
# needed. Neutron and GBP REST API methods should not be called from
# within transactions.
@contextlib.contextmanager
def transaction_guard_disabled(context):
try:
context.GUARD_TRANSACTION = False
yield
finally:
context.GUARD_TRANSACTION = True
def get_function_local_from_stack(function, local):
frame = sys._getframe()
while frame:

View File

@ -18,7 +18,7 @@ from gbpservice.nfp.orchestrator.openstack import openstack_driver
from neutron.common import constants as n_constants
from neutron.common import rpc as n_rpc
from neutron.common import topics as n_topics
from neutron_lib.agent import topics as n_topics
import oslo_messaging as messaging

View File

@ -14,7 +14,6 @@
from neutron.extensions import securitygroup as ext_sg
from neutron.notifiers import nova
from neutron import quota
from neutron_lib import constants as nl_const
from neutron_lib import exceptions as n_exc
from neutron_lib.exceptions import address_scope as as_exc
from neutron_lib.exceptions import l3
@ -47,7 +46,7 @@ class LocalAPI(object):
def _l3_plugin(self):
# REVISIT(rkukura): Need initialization method after all
# plugins are loaded to grab and store plugin.
l3_plugin = directory.get_plugin(nl_const.L3)
l3_plugin = directory.get_plugin(pconst.L3)
if not l3_plugin:
LOG.error("No L3 router service plugin found.")
raise exc.GroupPolicyDeploymentError()

View File

@ -0,0 +1,33 @@
# Copyright (c) 2020 Cisco Systems Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# REVISIT: Eliminate this module as soon as definitions from
# neutron.db.api, which is eliminated in stein, are not longer
# needed. Please DO NOT add any definition to this module that is not
# a direct alias of a definion in the version of neutron_lib.db.api
# corresponding to the newest neutron branch supported by this
# repository.
from neutron.db import api as old_api
from neutron_lib.db import api
get_context_manager = api.get_context_manager
get_reader_session = api.get_reader_session
get_writer_session = api.get_writer_session
is_retriable = old_api.is_retriable
retry_db_errors = old_api.retry_db_errors
retry_if_session_inactive = old_api.retry_if_session_inactive
CONTEXT_READER = get_context_manager().reader
CONTEXT_WRITER = get_context_manager().writer

View File

@ -12,7 +12,6 @@
import netaddr
from neutron.db import api as db_api
from neutron.db import common_db_mixin
from neutron_lib.api import validators
from neutron_lib import constants
@ -24,6 +23,7 @@ import sqlalchemy as sa
from sqlalchemy import orm
from sqlalchemy.orm import exc
from gbpservice.neutron.db import api as db_api
from gbpservice.neutron.extensions import group_policy as gpolicy
from gbpservice.neutron.services.grouppolicy.common import (
constants as gp_constants)
@ -1099,7 +1099,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
def create_policy_target(self, context, policy_target):
pt = policy_target['policy_target']
tenant_id = self._get_tenant_id_for_create(context, pt)
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
pt_db = PolicyTarget(
id=uuidutils.generate_uuid(), tenant_id=tenant_id,
name=pt['name'], description=pt['description'],
@ -1113,14 +1113,14 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
@log.log_method_call
def update_policy_target(self, context, policy_target_id, policy_target):
pt = policy_target['policy_target']
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
pt_db = self._get_policy_target(context, policy_target_id)
pt_db.update(pt)
return self._make_policy_target_dict(pt_db)
@log.log_method_call
def delete_policy_target(self, context, policy_target_id):
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
pt_db = self._get_policy_target(context, policy_target_id)
context.session.delete(pt_db)
@ -1151,7 +1151,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
def create_policy_target_group(self, context, policy_target_group):
ptg = policy_target_group['policy_target_group']
tenant_id = self._get_tenant_id_for_create(context, ptg)
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
if ptg['service_management']:
self._validate_service_management_ptg(context, tenant_id)
ptg_db = PolicyTargetGroup(
@ -1173,7 +1173,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
def update_policy_target_group(self, context, policy_target_group_id,
policy_target_group):
ptg = policy_target_group['policy_target_group']
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
ptg_db = self._get_policy_target_group(
context, policy_target_group_id)
ptg = self._process_policy_rule_sets_for_ptg(context, ptg_db, ptg)
@ -1182,7 +1182,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
@log.log_method_call
def delete_policy_target_group(self, context, policy_target_group_id):
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
ptg_db = self._get_policy_target_group(
context, policy_target_group_id)
# REVISIT(rkukura): An exception should be raised here if
@ -1227,7 +1227,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
application_policy_group):
apg = application_policy_group['application_policy_group']
tenant_id = self._get_tenant_id_for_create(context, apg)
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
apg_db = ApplicationPolicyGroup(
id=uuidutils.generate_uuid(), tenant_id=tenant_id,
name=apg['name'], description=apg['description'],
@ -1242,7 +1242,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
application_policy_group_id,
application_policy_group):
apg = application_policy_group['application_policy_group']
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
apg_db = self._get_application_policy_group(
context, application_policy_group_id)
apg_db.update(apg)
@ -1251,7 +1251,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
@log.log_method_call
def delete_application_policy_group(self, context,
application_policy_group_id):
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
apg_db = self._get_application_policy_group(
context, application_policy_group_id)
context.session.delete(apg_db)
@ -1285,7 +1285,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
def create_l2_policy(self, context, l2_policy):
l2p = l2_policy['l2_policy']
tenant_id = self._get_tenant_id_for_create(context, l2p)
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
l2p_db = L2Policy(id=uuidutils.generate_uuid(),
tenant_id=tenant_id, name=l2p['name'],
description=l2p['description'],
@ -1301,14 +1301,14 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
@log.log_method_call
def update_l2_policy(self, context, l2_policy_id, l2_policy):
l2p = l2_policy['l2_policy']
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
l2p_db = self._get_l2_policy(context, l2_policy_id)
l2p_db.update(l2p)
return self._make_l2_policy_dict(l2p_db)
@log.log_method_call
def delete_l2_policy(self, context, l2_policy_id):
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
l2p_db = self._get_l2_policy(context, l2_policy_id)
# When delete_l2_policy is called implicitly (as a
# side effect of the last PTG deletion), the L2P's
@ -1351,7 +1351,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
self.validate_subnet_prefix_length(
l3p['ip_version'], l3p['subnet_prefix_length'],
l3p.get('ip_pool', None))
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
l3p_db = L3Policy(
id=uuidutils.generate_uuid(),
tenant_id=tenant_id, name=l3p['name'],
@ -1371,7 +1371,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
@log.log_method_call
def update_l3_policy(self, context, l3_policy_id, l3_policy):
l3p = l3_policy['l3_policy']
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
l3p_db = self._get_l3_policy(context, l3_policy_id)
if 'subnet_prefix_length' in l3p:
self.validate_subnet_prefix_length(
@ -1386,7 +1386,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
@log.log_method_call
def delete_l3_policy(self, context, l3_policy_id):
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
l3p_db = self._get_l3_policy(context, l3_policy_id)
if l3p_db.l2_policies:
raise gpolicy.L3PolicyInUse(l3_policy_id=l3_policy_id)
@ -1419,7 +1419,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
def create_network_service_policy(self, context, network_service_policy):
nsp = network_service_policy['network_service_policy']
tenant_id = self._get_tenant_id_for_create(context, nsp)
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
nsp_db = NetworkServicePolicy(id=uuidutils.generate_uuid(),
tenant_id=tenant_id,
name=nsp['name'],
@ -1437,7 +1437,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
def update_network_service_policy(
self, context, network_service_policy_id, network_service_policy):
nsp = network_service_policy['network_service_policy']
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
nsp_db = self._get_network_service_policy(
context, network_service_policy_id)
if 'network_service_params' in network_service_policy:
@ -1449,7 +1449,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
@log.log_method_call
def delete_network_service_policy(
self, context, network_service_policy_id):
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
nsp_db = self._get_network_service_policy(
context, network_service_policy_id)
if nsp_db.policy_target_groups:
@ -1488,7 +1488,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
tenant_id = self._get_tenant_id_for_create(context, pc)
port_min, port_max = GroupPolicyDbPlugin._get_min_max_ports_from_range(
pc['port_range'])
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
pc_db = PolicyClassifier(id=uuidutils.generate_uuid(),
tenant_id=tenant_id,
name=pc['name'],
@ -1508,7 +1508,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
def update_policy_classifier(self, context, policy_classifier_id,
policy_classifier):
pc = policy_classifier['policy_classifier']
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
pc_db = self._get_policy_classifier(context, policy_classifier_id)
if 'port_range' in pc:
port_min, port_max = (GroupPolicyDbPlugin.
@ -1522,7 +1522,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
@log.log_method_call
def delete_policy_classifier(self, context, policy_classifier_id):
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
pc_db = self._get_policy_classifier(context, policy_classifier_id)
pc_ids = self._get_policy_classifier_rules(context,
policy_classifier_id)
@ -1559,7 +1559,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
def create_policy_action(self, context, policy_action):
pa = policy_action['policy_action']
tenant_id = self._get_tenant_id_for_create(context, pa)
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
pa_db = PolicyAction(id=uuidutils.generate_uuid(),
tenant_id=tenant_id,
name=pa['name'],
@ -1576,14 +1576,14 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
@log.log_method_call
def update_policy_action(self, context, policy_action_id, policy_action):
pa = policy_action['policy_action']
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
pa_db = self._get_policy_action(context, policy_action_id)
pa_db.update(pa)
return self._make_policy_action_dict(pa_db)
@log.log_method_call
def delete_policy_action(self, context, policy_action_id):
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
pa_db = self._get_policy_action(context, policy_action_id)
pa_ids = self._get_policy_action_rules(context, policy_action_id)
if pa_ids:
@ -1618,7 +1618,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
def create_policy_rule(self, context, policy_rule):
pr = policy_rule['policy_rule']
tenant_id = self._get_tenant_id_for_create(context, pr)
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
pr_db = PolicyRule(id=uuidutils.generate_uuid(),
tenant_id=tenant_id, name=pr['name'],
description=pr['description'],
@ -1635,7 +1635,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
@log.log_method_call
def update_policy_rule(self, context, policy_rule_id, policy_rule):
pr = policy_rule['policy_rule']
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
pr_db = self._get_policy_rule(context, policy_rule_id)
if 'policy_actions' in pr:
self._set_actions_for_rule(context, pr_db,
@ -1646,7 +1646,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
@log.log_method_call
def delete_policy_rule(self, context, policy_rule_id):
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
pr_db = self._get_policy_rule(context, policy_rule_id)
prs_ids = self._get_policy_rule_policy_rule_sets(context,
policy_rule_id)
@ -1681,7 +1681,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
def create_policy_rule_set(self, context, policy_rule_set):
prs = policy_rule_set['policy_rule_set']
tenant_id = self._get_tenant_id_for_create(context, prs)
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
prs_db = PolicyRuleSet(id=uuidutils.generate_uuid(),
tenant_id=tenant_id,
name=prs['name'],
@ -1700,7 +1700,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
def update_policy_rule_set(self, context, policy_rule_set_id,
policy_rule_set):
prs = policy_rule_set['policy_rule_set']
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
prs_db = self._get_policy_rule_set(context, policy_rule_set_id)
if 'policy_rules' in prs:
self._set_rules_for_policy_rule_set(
@ -1715,7 +1715,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
@log.log_method_call
def delete_policy_rule_set(self, context, policy_rule_set_id):
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
prs_db = self._get_policy_rule_set(context, policy_rule_set_id)
prs_ids = (
self._get_ptgs_for_providing_policy_rule_set(
@ -1759,7 +1759,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
def create_external_policy(self, context, external_policy):
ep = external_policy['external_policy']
tenant_id = self._get_tenant_id_for_create(context, ep)
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
ep_db = ExternalPolicy(
id=uuidutils.generate_uuid(), tenant_id=tenant_id,
name=ep['name'], description=ep['description'],
@ -1777,7 +1777,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
def update_external_policy(self, context, external_policy_id,
external_policy):
ep = external_policy['external_policy']
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
ep_db = self._get_external_policy(
context, external_policy_id)
if 'external_segments' in ep:
@ -1814,7 +1814,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
@log.log_method_call
def delete_external_policy(self, context, external_policy_id):
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
ep_db = self._get_external_policy(
context, external_policy_id)
context.session.delete(ep_db)
@ -1823,7 +1823,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
def create_external_segment(self, context, external_segment):
es = external_segment['external_segment']
tenant_id = self._get_tenant_id_for_create(context, es)
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
es_db = ExternalSegment(
id=uuidutils.generate_uuid(), tenant_id=tenant_id,
name=es['name'], description=es['description'],
@ -1841,7 +1841,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
def update_external_segment(self, context, external_segment_id,
external_segment):
es = external_segment['external_segment']
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
es_db = self._get_external_segment(
context, external_segment_id)
if 'external_routes' in es:
@ -1876,7 +1876,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
@log.log_method_call
def delete_external_segment(self, context, external_segment_id):
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
es_db = self._get_external_segment(
context, external_segment_id)
context.session.delete(es_db)
@ -1885,7 +1885,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
def create_nat_pool(self, context, nat_pool):
np = nat_pool['nat_pool']
tenant_id = self._get_tenant_id_for_create(context, np)
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
np_db = NATPool(
id=uuidutils.generate_uuid(), tenant_id=tenant_id,
name=np['name'], description=np['description'],
@ -1900,7 +1900,7 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
@log.log_method_call
def update_nat_pool(self, context, nat_pool_id, nat_pool):
np = nat_pool['nat_pool']
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
np_db = self._get_nat_pool(
context, nat_pool_id)
np_db.update(np)
@ -1930,6 +1930,6 @@ class GroupPolicyDbPlugin(gpolicy.GroupPolicyPluginBase,
@log.log_method_call
def delete_nat_pool(self, context, nat_pool_id):
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
np_db = self._get_nat_pool(context, nat_pool_id)
context.session.delete(np_db)

View File

@ -10,7 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.db import api as db_api
from neutron.db import models_v2
from neutron_lib.db import model_base
from neutron_lib import exceptions as nexc
@ -21,6 +20,7 @@ from sqlalchemy import orm
from gbpservice._i18n import _
from gbpservice.common import utils as gbp_utils
from gbpservice.neutron.db import api as db_api
from gbpservice.neutron.db.grouppolicy import group_policy_db as gpdb
from gbpservice.neutron.extensions import group_policy as gpolicy
from gbpservice.neutron.services.grouppolicy.common import exceptions
@ -429,7 +429,7 @@ class GroupPolicyMappingDbPlugin(gpdb.GroupPolicyDbPlugin):
def create_policy_target(self, context, policy_target):
pt = policy_target['policy_target']
tenant_id = self._get_tenant_id_for_create(context, pt)
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
self._validate_pt_port_exta_attributes(context, pt)
pt_db = PolicyTargetMapping(id=uuidutils.generate_uuid(),
tenant_id=tenant_id,
@ -465,7 +465,7 @@ class GroupPolicyMappingDbPlugin(gpdb.GroupPolicyDbPlugin):
def create_policy_target_group(self, context, policy_target_group):
ptg = policy_target_group['policy_target_group']
tenant_id = self._get_tenant_id_for_create(context, ptg)
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
if ptg['service_management']:
self._validate_service_management_ptg(context, tenant_id)
uuid = ptg.get('id')
@ -495,7 +495,7 @@ class GroupPolicyMappingDbPlugin(gpdb.GroupPolicyDbPlugin):
def update_policy_target_group(self, context, policy_target_group_id,
policy_target_group):
ptg = policy_target_group['policy_target_group']
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
ptg_db = self._get_policy_target_group(
context, policy_target_group_id)
self._process_policy_rule_sets_for_ptg(context, ptg_db, ptg)
@ -550,7 +550,7 @@ class GroupPolicyMappingDbPlugin(gpdb.GroupPolicyDbPlugin):
def create_l2_policy(self, context, l2_policy):
l2p = l2_policy['l2_policy']
tenant_id = self._get_tenant_id_for_create(context, l2p)
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
l2p_db = L2PolicyMapping(id=uuidutils.generate_uuid(),
tenant_id=tenant_id,
name=l2p['name'],
@ -591,7 +591,7 @@ class GroupPolicyMappingDbPlugin(gpdb.GroupPolicyDbPlugin):
self.validate_subnet_prefix_length(l3p['ip_version'],
l3p['subnet_prefix_length'],
l3p.get('ip_pool', None))
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
l3p_db = L3PolicyMapping(id=uuidutils.generate_uuid(),
tenant_id=tenant_id,
name=l3p['name'],
@ -633,7 +633,7 @@ class GroupPolicyMappingDbPlugin(gpdb.GroupPolicyDbPlugin):
if 'address_scope_v4_id' in l3p or 'address_scope_v6_id' in l3p:
raise AddressScopeUpdateForL3PNotSupported()
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
l3p_db = self._get_l3_policy(context, l3_policy_id)
self._update_subnetpools_for_l3_policy(context, l3_policy_id,
@ -679,7 +679,7 @@ class GroupPolicyMappingDbPlugin(gpdb.GroupPolicyDbPlugin):
def create_external_segment(self, context, external_segment):
es = external_segment['external_segment']
tenant_id = self._get_tenant_id_for_create(context, es)
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
es_db = ExternalSegmentMapping(
id=uuidutils.generate_uuid(), tenant_id=tenant_id,
name=es['name'], description=es['description'],
@ -713,7 +713,7 @@ class GroupPolicyMappingDbPlugin(gpdb.GroupPolicyDbPlugin):
def create_nat_pool(self, context, nat_pool):
np = nat_pool['nat_pool']
tenant_id = self._get_tenant_id_for_create(context, np)
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
np_db = NATPoolMapping(
id=uuidutils.generate_uuid(), tenant_id=tenant_id,
name=np['name'], description=np['description'],

View File

@ -12,7 +12,6 @@
import ast
from neutron.db import api as db_api
from neutron.db import common_db_mixin
from neutron_lib.db import model_base
from neutron_lib import exceptions as n_exc
@ -27,6 +26,7 @@ from sqlalchemy.ext.orderinglist import ordering_list
from sqlalchemy import orm
from sqlalchemy.orm import exc
from gbpservice.neutron.db import api as db_api
from gbpservice.neutron.extensions import servicechain as schain
from gbpservice.neutron.services.servicechain.common import exceptions as s_exc
@ -259,7 +259,7 @@ class ServiceChainDbPlugin(schain.ServiceChainPluginBase,
def create_servicechain_node(self, context, servicechain_node):
node = servicechain_node['servicechain_node']
tenant_id = self._get_tenant_id_for_create(context, node)
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
node_db = ServiceChainNode(
id=uuidutils.generate_uuid(), tenant_id=tenant_id,
name=node['name'], description=node['description'],
@ -275,7 +275,7 @@ class ServiceChainDbPlugin(schain.ServiceChainPluginBase,
def update_servicechain_node(self, context, servicechain_node_id,
servicechain_node, set_params=False):
node = servicechain_node['servicechain_node']
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
node_db = self._get_servicechain_node(context,
servicechain_node_id)
node_db.update(node)
@ -291,7 +291,7 @@ class ServiceChainDbPlugin(schain.ServiceChainPluginBase,
@log.log_method_call
def delete_servicechain_node(self, context, servicechain_node_id):
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
node_db = self._get_servicechain_node(context,
servicechain_node_id)
if node_db.specs:
@ -426,7 +426,7 @@ class ServiceChainDbPlugin(schain.ServiceChainPluginBase,
set_params=True):
spec = servicechain_spec['servicechain_spec']
tenant_id = self._get_tenant_id_for_create(context, spec)
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
spec_db = ServiceChainSpec(id=uuidutils.generate_uuid(),
tenant_id=tenant_id,
name=spec['name'],
@ -444,7 +444,7 @@ class ServiceChainDbPlugin(schain.ServiceChainPluginBase,
def update_servicechain_spec(self, context, spec_id,
servicechain_spec, set_params=True):
spec = servicechain_spec['servicechain_spec']
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
spec_db = self._get_servicechain_spec(context,
spec_id)
spec = self._process_nodes_for_spec(context, spec_db, spec,
@ -458,7 +458,7 @@ class ServiceChainDbPlugin(schain.ServiceChainPluginBase,
context, filters={"action_value": [spec_id]})
if policy_actions:
raise schain.ServiceChainSpecInUse(spec_id=spec_id)
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
spec_db = self._get_servicechain_spec(context,
spec_id)
if spec_db.instances:
@ -493,7 +493,7 @@ class ServiceChainDbPlugin(schain.ServiceChainPluginBase,
def create_servicechain_instance(self, context, servicechain_instance):
instance = servicechain_instance['servicechain_instance']
tenant_id = self._get_tenant_id_for_create(context, instance)
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
if not instance.get('management_ptg_id'):
management_groups = (
self._grouppolicy_plugin.get_policy_target_groups(
@ -525,7 +525,7 @@ class ServiceChainDbPlugin(schain.ServiceChainPluginBase,
def update_servicechain_instance(self, context, servicechain_instance_id,
servicechain_instance):
instance = servicechain_instance['servicechain_instance']
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
instance_db = self._get_servicechain_instance(
context, servicechain_instance_id)
instance = self._process_specs_for_instance(context, instance_db,
@ -535,7 +535,7 @@ class ServiceChainDbPlugin(schain.ServiceChainPluginBase,
@log.log_method_call
def delete_servicechain_instance(self, context, servicechain_instance_id):
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
instance_db = self._get_servicechain_instance(
context, servicechain_instance_id)
context.session.delete(instance_db)
@ -572,7 +572,7 @@ class ServiceChainDbPlugin(schain.ServiceChainPluginBase,
def create_service_profile(self, context, service_profile):
profile = service_profile['service_profile']
tenant_id = self._get_tenant_id_for_create(context, profile)
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
profile_db = ServiceProfile(
id=uuidutils.generate_uuid(), tenant_id=tenant_id,
name=profile['name'], description=profile['description'],
@ -590,7 +590,7 @@ class ServiceChainDbPlugin(schain.ServiceChainPluginBase,
def update_service_profile(self, context, service_profile_id,
service_profile):
profile = service_profile['service_profile']
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
profile_db = self._get_service_profile(context,
service_profile_id)
profile_db.update(profile)
@ -598,7 +598,7 @@ class ServiceChainDbPlugin(schain.ServiceChainPluginBase,
@log.log_method_call
def delete_service_profile(self, context, service_profile_id):
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
profile_db = self._get_service_profile(context,
service_profile_id)
if profile_db.nodes:

View File

@ -14,7 +14,6 @@ import abc
import re
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_lib.api import converters as conv
from neutron_lib.api import extensions
@ -496,10 +495,11 @@ RESOURCE_ATTRIBUTE_MAP = {
'network_service_policy_id': {'allow_post': True, 'allow_put': True,
'validate': {'type:uuid_or_none': None},
'default': None, 'is_visible': True},
attr.SHARED: {'allow_post': True, 'allow_put': True,
'default': False, 'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
nlib_const.SHARED: {'allow_post': True, 'allow_put': True,
'default': False,
'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
'service_management': {'allow_post': True, 'allow_put': True,
'default': False,
'convert_to': conv.convert_to_boolean,
@ -527,10 +527,11 @@ RESOURCE_ATTRIBUTE_MAP = {
'validate': {'type:uuid_list': None},
'convert_to': conv.convert_none_to_empty_list,
'default': None, 'is_visible': True},
attr.SHARED: {'allow_post': True, 'allow_put': True,
'default': False, 'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
nlib_const.SHARED: {'allow_post': True, 'allow_put': True,
'default': False,
'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
},
L2_POLICIES: {
'id': {'allow_post': False, 'allow_put': False,
@ -561,10 +562,11 @@ RESOURCE_ATTRIBUTE_MAP = {
'default': True, 'is_visible': True,
'convert_to': conv.convert_to_boolean,
'required': False},
attr.SHARED: {'allow_post': True, 'allow_put': True,
'default': False, 'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
nlib_const.SHARED: {'allow_post': True, 'allow_put': True,
'default': False,
'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
# TODO(Sumit): uncomment when supported in data path
# 'allow_broadcast': {'allow_post': True, 'allow_put': True,
# 'default': True, 'is_visible': True,
@ -608,10 +610,11 @@ RESOURCE_ATTRIBUTE_MAP = {
'validate': {'type:uuid_list': None},
'convert_to': conv.convert_none_to_empty_list,
'default': None, 'is_visible': True},
attr.SHARED: {'allow_post': True, 'allow_put': True,
'default': False, 'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
nlib_const.SHARED: {'allow_post': True, 'allow_put': True,
'default': False,
'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
'external_segments': {
'allow_post': True, 'allow_put': True, 'default': None,
'validate': {'type:external_dict': None},
@ -646,10 +649,11 @@ RESOURCE_ATTRIBUTE_MAP = {
'validate': {'type:values': gp_supported_directions},
'default': gp_constants.GP_DIRECTION_BI,
'is_visible': True},
attr.SHARED: {'allow_post': True, 'allow_put': True,
'default': False, 'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
nlib_const.SHARED: {'allow_post': True, 'allow_put': True,
'default': False,
'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
},
POLICY_ACTIONS: {
'id': {'allow_post': False, 'allow_put': False,
@ -677,7 +681,7 @@ RESOURCE_ATTRIBUTE_MAP = {
'action_value': {'allow_post': True, 'allow_put': True,
'validate': {'type:uuid_or_none': None},
'default': None, 'is_visible': True},
attr.SHARED: {'allow_post': True, 'allow_put': True,
nlib_const.SHARED: {'allow_post': True, 'allow_put': True,
'default': False, 'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
@ -709,7 +713,7 @@ RESOURCE_ATTRIBUTE_MAP = {
'default': None, 'is_visible': True,
'validate': {'type:uuid_list': None},
'convert_to': conv.convert_none_to_empty_list},
attr.SHARED: {'allow_post': True, 'allow_put': True,
nlib_const.SHARED: {'allow_post': True, 'allow_put': True,
'default': False, 'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
@ -758,7 +762,7 @@ RESOURCE_ATTRIBUTE_MAP = {
'providing_external_policies': {
'allow_post': False, 'allow_put': False, 'default': None,
'is_visible': True},
attr.SHARED: {'allow_post': True, 'allow_put': True,
nlib_const.SHARED: {'allow_post': True, 'allow_put': True,
'default': False, 'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
@ -788,7 +792,7 @@ RESOURCE_ATTRIBUTE_MAP = {
'validate':
{'type:network_service_params': None},
'default': None, 'is_visible': True},
attr.SHARED: {'allow_post': True, 'allow_put': True,
nlib_const.SHARED: {'allow_post': True, 'allow_put': True,
'default': False, 'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
@ -824,7 +828,7 @@ RESOURCE_ATTRIBUTE_MAP = {
'convert_to':
conv.convert_none_to_empty_dict,
'default': None, 'is_visible': True},
attr.SHARED: {'allow_post': True, 'allow_put': True,
nlib_const.SHARED: {'allow_post': True, 'allow_put': True,
'default': False, 'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
@ -876,7 +880,7 @@ RESOURCE_ATTRIBUTE_MAP = {
'validate': {'type:uuid_list': None},
'default': [],
'is_visible': True},
attr.SHARED: {'allow_post': True, 'allow_put': True,
nlib_const.SHARED: {'allow_post': True, 'allow_put': True,
'default': False, 'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
@ -908,7 +912,7 @@ RESOURCE_ATTRIBUTE_MAP = {
'external_segment_id': {'allow_post': True, 'allow_put': True,
'validate': {'type:uuid_or_none': None},
'is_visible': True, 'required': True},
attr.SHARED: {'allow_post': True, 'allow_put': True,
nlib_const.SHARED: {'allow_post': True, 'allow_put': True,
'default': False, 'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},

View File

@ -14,24 +14,21 @@ import copy
from neutron.api import extensions
from neutron.api.v2 import resource as neutron_resource
from neutron.db import address_scope_db
from neutron.db import api as db_api
from neutron.db import common_db_mixin
from neutron.db import l3_db
from neutron.db import models_v2
from neutron.db import securitygroups_db
from neutron.objects import subnetpool as subnetpool_obj
from neutron.plugins.ml2 import db as ml2_db
from neutron.quota import resource as quota_resource
from neutron_lib.api import attributes
from neutron_lib.api import validators
from neutron_lib import exceptions
from neutron_lib.exceptions import address_scope as as_exc
from neutron_lib.plugins import directory
from oslo_log import log
from oslo_utils import excutils
from gbpservice.common import utils as gbp_utils
from gbpservice.neutron.db import api as db_api
LOG = log.getLogger(__name__)
@ -149,25 +146,6 @@ common_db_mixin.CommonDbMixin._get_tenant_id_for_create = (
_get_tenant_id_for_create)
# REVISIT: In ocata, the switch to new engine facade in neutron is partial.
# This can result in different facades being mixed up within same transaction,
# and inconsistent behavior. Specifically, when L3 policy is deleted,
# subnetpool is deleted (old facade), and address scope (new facade) fails to
# be deleted since the dependent subnetpool deletion is in different session
# that is not yet commited. The workaround is to switch address scope to old
# engine facade. This workaround should be removed in Pike.
def _delete_address_scope(self, context, id):
with context.session.begin(subtransactions=True):
if subnetpool_obj.SubnetPool.get_objects(context,
address_scope_id=id):
raise as_exc.AddressScopeInUse(address_scope_id=id)
address_scope = self._get_address_scope(context, id)
address_scope.delete()
address_scope_db.AddressScopeDbMixin.delete_address_scope = (
_delete_address_scope)
def extend_resources(self, version, attr_map):
"""Extend resources with additional resources or attributes.
@ -362,7 +340,7 @@ try:
self._check_ip_prefix_valid(destination_ip_prefix, ethertype)
logical_source_port = fc['logical_source_port']
logical_destination_port = fc['logical_destination_port']
with db_api.context_manager.writer.using(context):
with db_api.CONTEXT_WRITER.using(context):
if logical_source_port is not None:
self._get_port(context, logical_source_port)
if logical_destination_port is not None:

View File

@ -13,11 +13,11 @@
import abc
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_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
from neutron_lib.plugins import constants
from neutron_lib.services import base as service_base
@ -134,10 +134,11 @@ RESOURCE_ATTRIBUTE_MAP = {
'config': {'allow_post': True, 'allow_put': True,
'validate': {'type:string': None},
'required': True, 'is_visible': True},
attr.SHARED: {'allow_post': True, 'allow_put': True,
'default': False, 'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
nlib_const.SHARED: {'allow_post': True, 'allow_put': True,
'default': False,
'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
},
SERVICECHAIN_SPECS: {
'id': {'allow_post': False, 'allow_put': False,
@ -164,10 +165,11 @@ RESOURCE_ATTRIBUTE_MAP = {
'config_param_names': {'allow_post': False, 'allow_put': False,
'validate': {'type:string_list': None},
'default': [], 'is_visible': True},
attr.SHARED: {'allow_post': True, 'allow_put': True,
'default': False, 'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
nlib_const.SHARED: {'allow_post': True, 'allow_put': True,
'default': False,
'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
},
SERVICECHAIN_INSTANCES: {
'id': {'allow_post': False, 'allow_put': False,
@ -228,10 +230,11 @@ RESOURCE_ATTRIBUTE_MAP = {
'is_visible': True},
'status_details': {'allow_post': False, 'allow_put': False,
'is_visible': True},
attr.SHARED: {'allow_post': True, 'allow_put': True,
'default': False, 'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
nlib_const.SHARED: {'allow_post': True, 'allow_put': True,
'default': False,
'convert_to': conv.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
'vendor': {'allow_post': True, 'allow_put': True,
'validate': {'type:string': None},
'is_visible': True, 'default': ''},

View File

@ -40,15 +40,8 @@ class ProjectDetailsCache(object):
self.project_details = {}
self.keystone = None
self.gbp = None
# This is needed for the legacy GBP plugin, which also
# uses the cache. This can be reverted once newton support
# is dropped
if hasattr(cfg.CONF, 'ml2_apic_aim'):
ml2_cfg = cfg.CONF.ml2_apic_aim
self.enable_neutronclient_internal_ep_interface = (
ml2_cfg.enable_neutronclient_internal_ep_interface)
else:
self.enable_neutronclient_internal_ep_interface = False
self.enable_neutronclient_internal_ep_interface = (
cfg.CONF.ml2_apic_aim.enable_neutronclient_internal_ep_interface)
def _get_keystone_client(self):
# REVISIT: It seems load_from_conf_options() and

View File

@ -56,7 +56,7 @@ apic_opts = [
help=("The pool of IPs where we allocate the APIC "
"router ID from while creating the SVI interface.")),
cfg.DictOpt('migrate_ext_net_dns', default={},
help="DNs for external networks being migrated from legacy "
help="DNs for external networks being migrated from other "
"plugin, formatted as a dictionary mapping Neutron external "
"network IDs (UUIDs) to ACI external network distinguished "
"names."),

View File

@ -14,7 +14,6 @@
# under the License.
from aim.api import resource as aim_resource
from neutron.db import api as db_api
from neutron.db.models import address_scope as as_db
from neutron.db import models_v2
from neutron_lib import context as n_context
@ -25,6 +24,8 @@ import sqlalchemy as sa
from sqlalchemy.ext import baked
from sqlalchemy import orm
from gbpservice.neutron.db import api as db_api
VM_UPDATE_PURPOSE = 'VmUpdate'
LOG = log.getLogger(__name__)

View File

@ -16,12 +16,12 @@
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_lib import exceptions as n_exc
from neutron_lib.plugins import directory
from oslo_log import log
from oslo_utils import excutils
from gbpservice.neutron.db import api as db_api
from gbpservice.neutron import extensions as extensions_pkg
from gbpservice.neutron.extensions import cisco_apic
from gbpservice.neutron.plugins.ml2plus import driver_api as api_plus

View File

@ -35,9 +35,7 @@ from aim import exceptions as aim_exceptions
from aim import utils as aim_utils
from neutron.agent import securitygroups_rpc
from neutron.common import rpc as n_rpc
from neutron.common import topics as n_topics
from neutron.common import utils as n_utils
from neutron.db import api as db_api
from neutron.db.models import address_scope as as_db
from neutron.db.models import allowed_address_pair as n_addr_pair_db
from neutron.db.models import l3 as l3_db
@ -54,6 +52,7 @@ from neutron.plugins.ml2.drivers.openvswitch.agent.common import (
from neutron.plugins.ml2 import models
from neutron.services.trunk import constants as trunk_consts
from neutron.services.trunk import exceptions as trunk_exc
from neutron_lib.agent import topics as n_topics
from neutron_lib.api.definitions import external_net
from neutron_lib.api.definitions import portbindings
from neutron_lib.api.definitions import trunk
@ -64,6 +63,7 @@ from neutron_lib.callbacks import resources
from neutron_lib import constants as n_constants
from neutron_lib import context as nctx
from neutron_lib import exceptions as n_exceptions
from neutron_lib.plugins import constants as pconst
from neutron_lib.plugins import directory
from neutron_lib.plugins.ml2 import api
from neutron_lib.utils import net
@ -77,6 +77,7 @@ from oslo_service import loopingcall
from oslo_utils import importutils
from gbpservice.common import utils as gbp_utils
from gbpservice.neutron.db import api as db_api
from gbpservice.neutron.extensions import cisco_apic
from gbpservice.neutron.extensions import cisco_apic_l3 as a_l3
from gbpservice.neutron.plugins.ml2plus import driver_api as api_plus
@ -130,10 +131,6 @@ NO_ADDR_SCOPE = object()
DVS_AGENT_KLASS = 'networking_vsphere.common.dvs_agent_rpc_api.DVSClientAPI'
DEFAULT_HOST_DOMAIN = '*'
LEGACY_SNAT_NET_NAME_PREFIX = 'host-snat-network-for-internal-use-'
LEGACY_SNAT_SUBNET_NAME = 'host-snat-pool-for-internal-use'
LEGACY_SNAT_PORT_NAME = 'host-snat-pool-port-for-internal-use'
LEGACY_SNAT_PORT_DEVICE_OWNER = 'host-snat-pool-port-device-owner-internal-use'
LL_INFO = 'local_link_information'
# TODO(kentwu): Move this to AIM utils maybe to avoid adding too much
@ -294,7 +291,7 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
def _update_nova_vm_name_cache(self):
current_time = datetime.now()
context = nctx.get_admin_context()
with db_api.context_manager.reader.using(context) as session:
with db_api.CONTEXT_READER.using(context) as session: