Spin off context module
NeutronLibImpact Partially-implements: blueprint neutron-lib Change-Id: I48cf45dc1b07035d952152eac2548a3bd9fc2832
This commit is contained in:
parent
5691f29e8f
commit
ca751a1486
@ -18,6 +18,7 @@ import os
|
||||
|
||||
import eventlet
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions
|
||||
from oslo_concurrency import lockutils
|
||||
from oslo_config import cfg
|
||||
@ -37,7 +38,6 @@ from neutron.common import constants as n_const
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron.common import topics
|
||||
from neutron.common import utils
|
||||
from neutron import context
|
||||
from neutron import manager
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -16,6 +16,7 @@
|
||||
import eventlet
|
||||
import netaddr
|
||||
from neutron_lib import constants as lib_const
|
||||
from neutron_lib import context as n_context
|
||||
from oslo_config import cfg
|
||||
from oslo_context import context as common_context
|
||||
from oslo_log import log as logging
|
||||
@ -53,7 +54,6 @@ from neutron.common import ipv6_utils
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron.common import topics
|
||||
from neutron.common import utils
|
||||
from neutron import context as n_context
|
||||
from neutron import manager
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -17,6 +17,7 @@ import hmac
|
||||
|
||||
import httplib2
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
@ -34,7 +35,6 @@ from neutron.common import constants as n_const
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron.common import topics
|
||||
from neutron.conf.agent.metadata import config
|
||||
from neutron import context
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context as neutron_context
|
||||
from neutron_lib import exceptions
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
@ -23,7 +24,6 @@ import six
|
||||
|
||||
from neutron.common import constants as n_const
|
||||
from neutron.common import utils
|
||||
from neutron import context as neutron_context
|
||||
from neutron.db import api as db_api
|
||||
from neutron.extensions import l3
|
||||
from neutron.extensions import portbindings
|
||||
|
@ -12,6 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib import context
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_middleware import base
|
||||
@ -19,8 +20,6 @@ from oslo_middleware import request_id
|
||||
import webob.dec
|
||||
import webob.exc
|
||||
|
||||
from neutron import context
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -20,11 +20,11 @@ subnets.
|
||||
import sys
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron.common import config
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron import context
|
||||
from neutron import manager
|
||||
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib import context
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import osprofiler.initializer
|
||||
@ -17,7 +18,6 @@ from osprofiler import opts as profiler_opts
|
||||
import osprofiler.web
|
||||
|
||||
from neutron._i18n import _LI
|
||||
from neutron import context
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
@ -18,6 +18,7 @@ import collections
|
||||
import random
|
||||
import time
|
||||
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as lib_exceptions
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
@ -30,7 +31,6 @@ from osprofiler import profiler
|
||||
|
||||
from neutron._i18n import _LE, _LW
|
||||
from neutron.common import exceptions
|
||||
from neutron import context
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -1,175 +0,0 @@
|
||||
# Copyright 2012 OpenStack Foundation.
|
||||
# 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.
|
||||
|
||||
"""Context: context for security/db session."""
|
||||
|
||||
import copy
|
||||
import datetime
|
||||
|
||||
from oslo_context import context as oslo_context
|
||||
from oslo_db.sqlalchemy import enginefacade
|
||||
|
||||
from neutron.db import api as db_api
|
||||
from neutron import policy
|
||||
|
||||
|
||||
class ContextBase(oslo_context.RequestContext):
|
||||
"""Security context and request information.
|
||||
|
||||
Represents the user taking a given action within the system.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, user_id=None, tenant_id=None, is_admin=None,
|
||||
timestamp=None, tenant_name=None, user_name=None,
|
||||
is_advsvc=None, **kwargs):
|
||||
"""Object initialization.
|
||||
|
||||
:param overwrite: Set to False to ensure that the greenthread local
|
||||
copy of the index is not overwritten.
|
||||
"""
|
||||
# NOTE(jamielennox): We maintain these arguments in order for tests
|
||||
# that pass arguments positionally.
|
||||
kwargs.setdefault('user', user_id)
|
||||
kwargs.setdefault('tenant', tenant_id)
|
||||
super(ContextBase, self).__init__(is_admin=is_admin, **kwargs)
|
||||
|
||||
self.user_name = user_name
|
||||
# NOTE(sdague): tenant* is a deprecated set of names from
|
||||
# keystone, and is no longer set in modern keystone middleware
|
||||
# code, as such this is almost always going to be None.
|
||||
self.tenant_name = tenant_name
|
||||
|
||||
if not timestamp:
|
||||
timestamp = datetime.datetime.utcnow()
|
||||
self.timestamp = timestamp
|
||||
self.is_advsvc = is_advsvc
|
||||
if self.is_advsvc is None:
|
||||
self.is_advsvc = self.is_admin or policy.check_is_advsvc(self)
|
||||
if self.is_admin is None:
|
||||
self.is_admin = policy.check_is_admin(self)
|
||||
|
||||
@property
|
||||
def project_id(self):
|
||||
return self.tenant
|
||||
|
||||
@property
|
||||
def tenant_id(self):
|
||||
return self.tenant
|
||||
|
||||
@tenant_id.setter
|
||||
def tenant_id(self, tenant_id):
|
||||
self.tenant = tenant_id
|
||||
|
||||
@property
|
||||
def user_id(self):
|
||||
return self.user
|
||||
|
||||
@user_id.setter
|
||||
def user_id(self, user_id):
|
||||
self.user = user_id
|
||||
|
||||
def to_dict(self):
|
||||
context = super(ContextBase, self).to_dict()
|
||||
context.update({
|
||||
'user_id': self.user_id,
|
||||
'tenant_id': self.tenant_id,
|
||||
'project_id': self.project_id,
|
||||
'timestamp': str(self.timestamp),
|
||||
# prefer project_name, as that's what's going to be set by
|
||||
# keystone. Fall back if for some reason it's blank.
|
||||
'tenant_name': self.project_name or self.tenant_name,
|
||||
'project_name': self.project_name or self.tenant_name,
|
||||
'user_name': self.user_name,
|
||||
})
|
||||
return context
|
||||
|
||||
def to_policy_values(self):
|
||||
values = super(ContextBase, self).to_policy_values()
|
||||
values['tenant_id'] = self.tenant_id
|
||||
values['is_admin'] = self.is_admin
|
||||
|
||||
# NOTE(jamielennox): These are almost certainly unused and non-standard
|
||||
# but kept for backwards compatibility. Remove them in Pike
|
||||
# (oslo.context from Ocata release already issues deprecation warnings
|
||||
# for non-standard keys).
|
||||
values['user'] = self.user
|
||||
values['tenant'] = self.tenant
|
||||
values['domain'] = self.domain
|
||||
values['user_domain'] = self.user_domain
|
||||
values['project_domain'] = self.project_domain
|
||||
# prefer project_name, as that's what's going to be set by
|
||||
# keystone. Fall back if for some reason it's blank.
|
||||
values['tenant_name'] = self.project_name or self.tenant_name
|
||||
values['project_name'] = self.project_name or self.tenant_name
|
||||
values['user_name'] = self.user_name
|
||||
|
||||
return values
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, values):
|
||||
return cls(user_id=values.get('user_id', values.get('user')),
|
||||
tenant_id=values.get('tenant_id', values.get('project_id')),
|
||||
is_admin=values.get('is_admin'),
|
||||
roles=values.get('roles'),
|
||||
timestamp=values.get('timestamp'),
|
||||
request_id=values.get('request_id'),
|
||||
tenant_name=values.get('tenant_name'),
|
||||
user_name=values.get('user_name'),
|
||||
auth_token=values.get('auth_token'))
|
||||
|
||||
def elevated(self):
|
||||
"""Return a version of this context with admin flag set."""
|
||||
context = copy.copy(self)
|
||||
context.is_admin = True
|
||||
|
||||
if 'admin' not in [x.lower() for x in context.roles]:
|
||||
context.roles = context.roles + ["admin"]
|
||||
|
||||
return context
|
||||
|
||||
|
||||
@enginefacade.transaction_context_provider
|
||||
class ContextBaseWithSession(ContextBase):
|
||||
pass
|
||||
|
||||
|
||||
class Context(ContextBaseWithSession):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Context, self).__init__(*args, **kwargs)
|
||||
self._session = None
|
||||
|
||||
@property
|
||||
def session(self):
|
||||
# TODO(akamyshnikova): checking for session attribute won't be needed
|
||||
# when reader and writer will be used
|
||||
if hasattr(super(Context, self), 'session'):
|
||||
return super(Context, self).session
|
||||
if self._session is None:
|
||||
self._session = db_api.get_writer_session()
|
||||
return self._session
|
||||
|
||||
|
||||
def get_admin_context():
|
||||
return Context(user_id=None,
|
||||
tenant_id=None,
|
||||
is_admin=True,
|
||||
overwrite=False)
|
||||
|
||||
|
||||
def get_admin_context_without_session():
|
||||
return ContextBase(user_id=None,
|
||||
tenant_id=None,
|
||||
is_admin=True)
|
@ -19,6 +19,7 @@ import debtcollector
|
||||
from eventlet import greenthread
|
||||
from neutron_lib.api import converters
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
@ -37,7 +38,6 @@ from neutron.callbacks import events
|
||||
from neutron.callbacks import registry
|
||||
from neutron.callbacks import resources
|
||||
from neutron.common import constants as n_const
|
||||
from neutron import context
|
||||
from neutron.db import _utils as db_utils
|
||||
from neutron.db import api as db_api
|
||||
from neutron.db.models import agent as agent_model
|
||||
|
@ -18,6 +18,7 @@ import random
|
||||
import time
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context as ncontext
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
@ -29,7 +30,6 @@ from neutron._i18n import _, _LE, _LI, _LW
|
||||
from neutron.agent.common import utils as agent_utils
|
||||
from neutron.common import constants as n_const
|
||||
from neutron.common import utils
|
||||
from neutron import context as ncontext
|
||||
from neutron.db import agents_db
|
||||
from neutron.db.availability_zone import network as network_az
|
||||
from neutron.db.models import agent as agent_model
|
||||
|
@ -17,11 +17,11 @@ import contextlib
|
||||
import copy
|
||||
|
||||
from debtcollector import removals
|
||||
from neutron_lib.db import api
|
||||
from neutron_lib import exceptions
|
||||
from oslo_config import cfg
|
||||
from oslo_db import api as oslo_db_api
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_db.sqlalchemy import enginefacade
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
from osprofiler import opts as profiler_opts
|
||||
@ -44,9 +44,7 @@ def set_hook(engine):
|
||||
osprofiler.sqlalchemy.add_tracing(sqlalchemy, engine, 'neutron.db')
|
||||
|
||||
|
||||
context_manager = enginefacade.transaction_context()
|
||||
|
||||
context_manager.configure(sqlite_fk=True)
|
||||
context_manager = api.get_context_manager()
|
||||
|
||||
# TODO(ihrachys) the hook assumes options defined by osprofiler, and the only
|
||||
# public function that is provided by osprofiler that will register them is
|
||||
|
@ -18,6 +18,7 @@ import functools
|
||||
import netaddr
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context as ctx
|
||||
from neutron_lib import exceptions as exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
@ -39,7 +40,6 @@ from neutron.common import constants as n_const
|
||||
from neutron.common import exceptions as n_exc
|
||||
from neutron.common import ipv6_utils
|
||||
from neutron.common import utils
|
||||
from neutron import context as ctx
|
||||
from neutron.db import _utils as ndb_utils
|
||||
from neutron.db import api as db_api
|
||||
from neutron.db import db_base_plugin_common
|
||||
|
@ -20,6 +20,7 @@ from debtcollector import removals
|
||||
import netaddr
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context as n_ctx
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_log import log as logging
|
||||
@ -38,7 +39,6 @@ from neutron.common import constants as n_const
|
||||
from neutron.common import ipv6_utils
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron.common import utils
|
||||
from neutron import context as n_ctx
|
||||
from neutron.db import _utils as db_utils
|
||||
from neutron.db import api as db_api
|
||||
from neutron.db import common_db_mixin
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
from keystoneauth1 import loading as ks_loading
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as exc
|
||||
from neutron_lib.plugins import directory
|
||||
from novaclient import api_versions
|
||||
@ -29,7 +30,6 @@ from neutron._i18n import _LE, _LI, _LW
|
||||
from neutron.callbacks import events
|
||||
from neutron.callbacks import registry
|
||||
from neutron.callbacks import resources
|
||||
from neutron import context
|
||||
from neutron.notifiers import batch_notifier
|
||||
|
||||
|
||||
|
@ -20,6 +20,7 @@ import sys
|
||||
import time
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_service import loopingcall
|
||||
@ -39,7 +40,6 @@ from neutron.callbacks import resources as local_resources
|
||||
from neutron.common import config as common_config
|
||||
from neutron.common import constants as n_const
|
||||
from neutron.common import topics
|
||||
from neutron import context
|
||||
from neutron.plugins.ml2.drivers.agent import _agent_manager_base as amb
|
||||
from neutron.plugins.ml2.drivers.agent import capabilities
|
||||
from neutron.plugins.ml2.drivers.agent import config as cagt_config # noqa
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
import random
|
||||
|
||||
from neutron_lib import context as neutron_ctx
|
||||
from neutron_lib.utils import helpers
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as db_exc
|
||||
@ -22,7 +23,6 @@ from oslo_log import log
|
||||
|
||||
from neutron._i18n import _LE
|
||||
from neutron.common import exceptions as exc
|
||||
from neutron import context as neutron_ctx
|
||||
from neutron.plugins.common import utils as p_utils
|
||||
from neutron.plugins.ml2 import driver_api as api
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
from neutron_lib import constants as const
|
||||
from neutron_lib import context as n_context
|
||||
from neutron_lib import exceptions
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
@ -21,7 +22,6 @@ from oslo_log import log as logging
|
||||
|
||||
from neutron._i18n import _, _LW
|
||||
from neutron.conf.plugins.ml2.drivers import l2pop as config
|
||||
from neutron import context as n_context
|
||||
from neutron.db import api as db_api
|
||||
from neutron.db import l3_hamode_db
|
||||
from neutron.plugins.ml2 import driver_api as api
|
||||
|
@ -21,6 +21,7 @@ import sys
|
||||
import time
|
||||
|
||||
from neutron_lib import constants as n_constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib.utils import helpers
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
@ -38,7 +39,6 @@ from neutron.api.rpc.handlers import securitygroups_rpc as sg_rpc
|
||||
from neutron.common import config as common_config
|
||||
from neutron.common import profiler as setup_profiler
|
||||
from neutron.common import topics
|
||||
from neutron import context
|
||||
from neutron.extensions import portbindings
|
||||
from neutron.plugins.ml2.drivers.mech_sriov.agent.common import config
|
||||
from neutron.plugins.ml2.drivers.mech_sriov.agent.common \
|
||||
|
@ -23,6 +23,7 @@ import time
|
||||
|
||||
import netaddr
|
||||
from neutron_lib import constants as n_const
|
||||
from neutron_lib import context
|
||||
from neutron_lib.utils import helpers
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
@ -53,7 +54,6 @@ from neutron.common import config
|
||||
from neutron.common import constants as c_const
|
||||
from neutron.common import topics
|
||||
from neutron.conf.agent import xenapi_conf
|
||||
from neutron import context
|
||||
from neutron.extensions import portbindings
|
||||
from neutron.plugins.common import constants as p_const
|
||||
from neutron.plugins.common import utils as p_utils
|
||||
|
@ -17,6 +17,7 @@ import itertools
|
||||
import operator
|
||||
|
||||
import netaddr
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as exc
|
||||
from oslo_config import cfg
|
||||
from oslo_db import api as oslo_db_api
|
||||
@ -28,7 +29,6 @@ from sqlalchemy import or_
|
||||
|
||||
from neutron._i18n import _, _LI, _LW
|
||||
from neutron.common import topics
|
||||
from neutron import context
|
||||
from neutron.db import api as db_api
|
||||
from neutron.plugins.common import constants as p_const
|
||||
from neutron.plugins.common import utils as plugin_utils
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
import sys
|
||||
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as exc
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
@ -22,7 +23,6 @@ from six import moves
|
||||
|
||||
from neutron._i18n import _, _LE, _LI, _LW
|
||||
from neutron.conf.plugins.ml2.drivers import driver_type
|
||||
from neutron import context
|
||||
from neutron.db import api as db_api
|
||||
from neutron.db.models.plugins.ml2 import vlanallocation as vlan_alloc_model
|
||||
from neutron.plugins.common import constants as p_const
|
||||
|
@ -14,6 +14,7 @@
|
||||
import traceback
|
||||
|
||||
import eventlet
|
||||
from neutron_lib import context as n_ctx
|
||||
from oslo_concurrency import lockutils
|
||||
from oslo_log import log as logging
|
||||
|
||||
@ -23,7 +24,6 @@ from neutron.api.rpc.handlers import resources_rpc
|
||||
from neutron.callbacks import events
|
||||
from neutron.callbacks import registry
|
||||
from neutron.callbacks import resources
|
||||
from neutron import context as n_ctx
|
||||
from neutron.db import api as db_api
|
||||
from neutron.objects import network
|
||||
from neutron.objects import ports
|
||||
|
@ -17,6 +17,7 @@ import collections
|
||||
import re
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
@ -24,7 +25,6 @@ from oslo_db import exception as db_exc
|
||||
from oslo_log import log as logging
|
||||
from oslo_policy import policy
|
||||
from oslo_utils import excutils
|
||||
from oslo_utils import importutils
|
||||
import six
|
||||
|
||||
from neutron._i18n import _, _LE, _LW
|
||||
@ -222,7 +222,6 @@ class OwnerCheck(policy.Check):
|
||||
f = getattr(directory.get_plugin(), 'get_%s' % resource_type)
|
||||
# f *must* exist, if not found it is better to let neutron
|
||||
# explode. Check will be performed with admin context
|
||||
context = importutils.import_module('neutron.context')
|
||||
try:
|
||||
data = f(context.get_admin_context(),
|
||||
resource_id,
|
||||
@ -409,23 +408,3 @@ def enforce(context, action, target, plugin=None, pluralized=None):
|
||||
log_rule_list(rule)
|
||||
LOG.debug("Failed policy check for '%s'", action)
|
||||
return result
|
||||
|
||||
|
||||
def check_is_admin(context):
|
||||
"""Verify context has admin rights according to policy settings."""
|
||||
init()
|
||||
# the target is user-self
|
||||
credentials = context.to_policy_values()
|
||||
if ADMIN_CTX_POLICY not in _ENFORCER.rules:
|
||||
return False
|
||||
return _ENFORCER.enforce(ADMIN_CTX_POLICY, credentials, credentials)
|
||||
|
||||
|
||||
def check_is_advsvc(context):
|
||||
"""Verify context has advsvc rights according to policy settings."""
|
||||
init()
|
||||
# the target is user-self
|
||||
credentials = context.to_policy_values()
|
||||
if ADVSVC_CTX_POLICY not in _ENFORCER.rules:
|
||||
return False
|
||||
return _ENFORCER.enforce(ADVSVC_CTX_POLICY, credentials, credentials)
|
||||
|
@ -17,6 +17,7 @@ import inspect
|
||||
import os
|
||||
import random
|
||||
|
||||
from neutron_lib import context
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_config import cfg
|
||||
@ -35,7 +36,6 @@ from neutron.common import config
|
||||
from neutron.common import profiler
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron.conf import service
|
||||
from neutron import context
|
||||
from neutron.db import api as session
|
||||
from neutron import worker as neutron_worker
|
||||
from neutron import wsgi
|
||||
|
@ -46,7 +46,7 @@ class ExternalDNSService(object):
|
||||
"""Create a record set in the specified zone.
|
||||
|
||||
:param context: neutron api request context
|
||||
:type context: neutron.context.Context
|
||||
:type context: neutron_lib.context.Context
|
||||
:param dns_domain: the dns_domain where the record set will be created
|
||||
:type dns_domain: String
|
||||
:param dns_name: the name associated with the record set
|
||||
|
@ -15,6 +15,7 @@
|
||||
import sys
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
@ -33,7 +34,6 @@ from neutron.common import rpc as n_rpc
|
||||
from neutron.common import topics
|
||||
from neutron.common import utils
|
||||
from neutron.conf.services import metering_agent
|
||||
from neutron import context
|
||||
from neutron import manager
|
||||
from neutron import service as neutron_service
|
||||
|
||||
|
@ -52,7 +52,7 @@ class QoSPlugin(qos.QoSPluginBase):
|
||||
"""Create a QoS policy.
|
||||
|
||||
:param context: neutron api request context
|
||||
:type context: neutron.context.Context
|
||||
:type context: neutron_lib.context.Context
|
||||
:param policy: policy data to be applied
|
||||
:type policy: dict
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
import functools
|
||||
|
||||
import eventlet
|
||||
from neutron_lib import context as n_context
|
||||
from oslo_concurrency import lockutils
|
||||
from oslo_context import context as o_context
|
||||
from oslo_log import log as logging
|
||||
@ -28,7 +29,6 @@ from neutron.api.rpc.handlers import resources_rpc
|
||||
from neutron.callbacks import events
|
||||
from neutron.callbacks import registry
|
||||
from neutron.common import utils as common_utils
|
||||
from neutron import context as n_context
|
||||
from neutron.plugins.ml2.drivers.openvswitch.agent.common \
|
||||
import constants as ovs_agent_constants
|
||||
from neutron.services.trunk import constants
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
import copy
|
||||
|
||||
from neutron_lib import context
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
@ -21,7 +22,6 @@ from neutron.api.v2 import attributes
|
||||
from neutron.callbacks import events
|
||||
from neutron.callbacks import registry
|
||||
from neutron.callbacks import resources
|
||||
from neutron import context
|
||||
from neutron.db import api as db_api
|
||||
from neutron.db import common_db_mixin
|
||||
from neutron.db import db_base_plugin_common
|
||||
|
@ -19,6 +19,7 @@ import os
|
||||
import random
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
import testtools
|
||||
@ -26,7 +27,6 @@ import testtools
|
||||
import neutron
|
||||
from neutron.agent.common import ovs_lib
|
||||
from neutron.common import topics
|
||||
from neutron import context
|
||||
from neutron.db import agents_db
|
||||
from neutron.db import common_db_mixin
|
||||
|
||||
|
@ -15,9 +15,10 @@
|
||||
|
||||
import os.path
|
||||
|
||||
from neutron_lib import context
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron import context
|
||||
from neutron import policy
|
||||
from neutron.tests import base
|
||||
from neutron.tests import tools
|
||||
@ -41,7 +42,6 @@ class APIPolicyTestCase(base.BaseTestCase):
|
||||
self.useFixture(tools.AttributeMapMemento())
|
||||
self.extension_path = os.path.abspath(os.path.join(
|
||||
TEST_PATH, "../../../extensions"))
|
||||
policy.reset()
|
||||
self.addCleanup(policy.reset)
|
||||
|
||||
def _network_definition(self):
|
||||
@ -79,9 +79,11 @@ class APIPolicyTestCase(base.BaseTestCase):
|
||||
populating extensions and extending the resource map results in
|
||||
networks with router:external are visible to regular tenants.
|
||||
"""
|
||||
policy.reset()
|
||||
extension_manager = extensions.ExtensionManager(self.extension_path)
|
||||
extension_manager.extend_resources(self.api_version,
|
||||
attributes.RESOURCE_ATTRIBUTE_MAP)
|
||||
policy.init()
|
||||
admin_context = context.get_admin_context()
|
||||
tenant_context = context.Context('test_user', 'test_tenant_id', False)
|
||||
self.assertTrue(self._check_external_router_policy(admin_context))
|
||||
|
@ -14,12 +14,12 @@
|
||||
# under the License.
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import uuidutils
|
||||
import testtools
|
||||
|
||||
from neutron import context
|
||||
from neutron.db import db_base_plugin_v2 as base_plugin
|
||||
from neutron.db import models_v2
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
@ -14,6 +14,7 @@ import uuid
|
||||
|
||||
import mock
|
||||
from neutron_lib import constants as n_const
|
||||
from neutron_lib import context
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as db_exc
|
||||
@ -23,7 +24,6 @@ import pecan
|
||||
from pecan import request
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron import context
|
||||
from neutron import manager
|
||||
from neutron.pecan_wsgi.controllers import root as controllers
|
||||
from neutron.pecan_wsgi.controllers import utils as controller_utils
|
||||
@ -297,6 +297,8 @@ class TestResourceController(TestRootController):
|
||||
|
||||
def setUp(self):
|
||||
super(TestResourceController, self).setUp()
|
||||
policy.init()
|
||||
self.addCleanup(policy.reset)
|
||||
self._gen_port()
|
||||
|
||||
def _gen_port(self):
|
||||
@ -456,6 +458,8 @@ class TestPaginationAndSorting(test_functional.PecanFunctionalTest):
|
||||
|
||||
def setUp(self):
|
||||
super(TestPaginationAndSorting, self).setUp()
|
||||
policy.init()
|
||||
self.addCleanup(policy.reset)
|
||||
self.plugin = directory.get_plugin()
|
||||
self.ctx = context.get_admin_context()
|
||||
self._create_networks(self.RESOURCE_COUNT)
|
||||
@ -702,6 +706,8 @@ class TestRouterController(TestResourceController):
|
||||
['neutron.services.l3_router.l3_router_plugin.L3RouterPlugin',
|
||||
'neutron.services.flavors.flavors_plugin.FlavorsPlugin'])
|
||||
super(TestRouterController, self).setUp()
|
||||
policy.init()
|
||||
self.addCleanup(policy.reset)
|
||||
plugin = directory.get_plugin()
|
||||
ctx = context.get_admin_context()
|
||||
l3_plugin = directory.get_plugin(n_const.L3)
|
||||
|
@ -17,6 +17,7 @@ import os
|
||||
|
||||
import mock
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from oslo_config import cfg
|
||||
from oslo_middleware import base
|
||||
@ -27,7 +28,6 @@ import webob.dec
|
||||
import webtest
|
||||
|
||||
from neutron.api import extensions as exts
|
||||
from neutron import context
|
||||
from neutron import manager
|
||||
from neutron import tests
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
@ -14,6 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib import context
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_policy import policy as oslo_policy
|
||||
@ -21,7 +22,6 @@ from oslo_serialization import jsonutils
|
||||
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.callbacks import events
|
||||
from neutron import context
|
||||
from neutron.db.quota import driver as quota_driver
|
||||
from neutron import manager
|
||||
from neutron.pecan_wsgi.controllers import resource
|
||||
|
@ -14,8 +14,8 @@
|
||||
# under the License.
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
|
||||
from neutron import context
|
||||
from neutron.db import agents_db
|
||||
from neutron.extensions import portbindings
|
||||
from neutron.tests.common import helpers
|
||||
|
@ -17,10 +17,10 @@ import collections
|
||||
from operator import attrgetter
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
import six
|
||||
import testscenarios
|
||||
|
||||
from neutron import context
|
||||
from neutron.db import agents_db
|
||||
from neutron.db import agentschedulers_db
|
||||
from neutron.db import common_db_mixin
|
||||
|
@ -17,10 +17,10 @@ import collections
|
||||
import random
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from oslo_utils import uuidutils
|
||||
import testscenarios
|
||||
|
||||
from neutron import context
|
||||
from neutron.db.models import external_net as ext_net_models
|
||||
from neutron.scheduler import l3_agent_scheduler
|
||||
from neutron.services.l3_router import l3_router_plugin
|
||||
|
@ -14,13 +14,13 @@
|
||||
|
||||
import mock
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
|
||||
from neutron.api.rpc.handlers import l3_rpc
|
||||
from neutron.callbacks import events
|
||||
from neutron.callbacks import registry
|
||||
from neutron.callbacks import resources
|
||||
from neutron.common import topics
|
||||
from neutron import context
|
||||
from neutron.extensions import external_net
|
||||
from neutron.extensions import l3
|
||||
from neutron.extensions import portbindings
|
||||
|
@ -18,11 +18,11 @@ Neutron API via different methods.
|
||||
import abc
|
||||
|
||||
import fixtures
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
import six
|
||||
|
||||
from neutron import context
|
||||
from neutron import manager
|
||||
from neutron.tests import base
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
@ -13,12 +13,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib import context
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from six.moves import http_client as httplib
|
||||
from webob import exc
|
||||
|
||||
from neutron import context
|
||||
from neutron.extensions import portbindings
|
||||
from neutron.tests.unit.db import test_db_base_plugin_v2
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
@ -23,7 +24,6 @@ from neutron.api.rpc.callbacks.consumer import registry
|
||||
from neutron.api.rpc.callbacks import events
|
||||
from neutron.api.rpc.callbacks import resources
|
||||
from neutron.api.rpc.handlers import resources_rpc
|
||||
from neutron import context
|
||||
from neutron.objects.qos import policy
|
||||
from neutron.objects.qos import rule
|
||||
from neutron.plugins.ml2.drivers.openvswitch.agent import (
|
||||
|
@ -18,6 +18,7 @@ import contextlib
|
||||
|
||||
import mock
|
||||
from neutron_lib import constants as const
|
||||
from neutron_lib import context
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
import oslo_messaging
|
||||
@ -30,7 +31,6 @@ from neutron.agent.linux import iptables_manager
|
||||
from neutron.agent import securitygroups_rpc as sg_rpc
|
||||
from neutron.api.rpc.handlers import securitygroups_rpc
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron import context
|
||||
from neutron.db import securitygroups_rpc_base as sg_db_rpc
|
||||
from neutron.extensions import allowedaddresspairs as addr_pair
|
||||
from neutron.extensions import securitygroup as ext_sg
|
||||
|
@ -14,11 +14,11 @@
|
||||
# limitations under the License.
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
|
||||
from neutron.api.rpc.handlers import l3_rpc
|
||||
from neutron import context
|
||||
from neutron.tests.unit.db import test_db_base_plugin_v2
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib import context
|
||||
from oslo_utils import uuidutils
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
from oslo_versionedobjects import fixture
|
||||
@ -23,7 +24,6 @@ from neutron.api.rpc.callbacks import resources
|
||||
from neutron.api.rpc.callbacks import version_manager
|
||||
from neutron.api.rpc.handlers import resources_rpc
|
||||
from neutron.common import topics
|
||||
from neutron import context
|
||||
from neutron.objects import base as objects_base
|
||||
from neutron.objects import common_types
|
||||
from neutron.tests import base
|
||||
|
@ -15,12 +15,12 @@
|
||||
|
||||
from neutron_lib.api import converters
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from oslo_utils import uuidutils
|
||||
import webob.exc
|
||||
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron import context
|
||||
from neutron.tests import base
|
||||
|
||||
|
||||
|
@ -18,6 +18,7 @@ import os
|
||||
import mock
|
||||
from neutron_lib.api import converters
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
@ -36,7 +37,6 @@ from neutron.api.v2 import attributes
|
||||
from neutron.api.v2 import base as v2_base
|
||||
from neutron.api.v2 import router
|
||||
from neutron.callbacks import registry
|
||||
from neutron import context
|
||||
from neutron import policy
|
||||
from neutron import quota
|
||||
from neutron.quota import resource_registry
|
||||
|
@ -14,6 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as n_exc
|
||||
import oslo_i18n
|
||||
from webob import exc
|
||||
@ -22,7 +23,6 @@ import webtest
|
||||
from neutron._i18n import _
|
||||
from neutron.api.v2 import resource as wsgi_resource
|
||||
from neutron.common import utils
|
||||
from neutron import context
|
||||
from neutron.tests import base
|
||||
from neutron import wsgi
|
||||
|
||||
|
@ -234,46 +234,41 @@ class TestRequestContextSerializer(base.DietTestCase):
|
||||
|
||||
context.to_dict.assert_called_once_with()
|
||||
|
||||
@mock.patch('neutron.policy.check_is_advsvc', return_val=False)
|
||||
@mock.patch('neutron.policy.check_is_admin', return_val=False)
|
||||
def test_deserialize_context(self, m, n):
|
||||
def test_deserialize_context(self):
|
||||
context_dict = {'foo': 'bar',
|
||||
'user_id': 1,
|
||||
'tenant_id': 1}
|
||||
'tenant_id': 1,
|
||||
'is_admin': True}
|
||||
|
||||
c = self.ser.deserialize_context(context_dict)
|
||||
|
||||
self.assertEqual(1, c.user_id)
|
||||
self.assertEqual(1, c.project_id)
|
||||
|
||||
@mock.patch('neutron.policy.check_is_advsvc', return_val=False)
|
||||
@mock.patch('neutron.policy.check_is_admin', return_val=False)
|
||||
def test_deserialize_context_no_user_id(self, m, n):
|
||||
def test_deserialize_context_no_user_id(self):
|
||||
context_dict = {'foo': 'bar',
|
||||
'user': 1,
|
||||
'tenant_id': 1}
|
||||
'tenant_id': 1,
|
||||
'is_admin': True}
|
||||
|
||||
c = self.ser.deserialize_context(context_dict)
|
||||
|
||||
self.assertEqual(1, c.user_id)
|
||||
self.assertEqual(1, c.project_id)
|
||||
|
||||
@mock.patch('neutron.policy.check_is_advsvc', return_val=False)
|
||||
@mock.patch('neutron.policy.check_is_admin', return_val=False)
|
||||
def test_deserialize_context_no_tenant_id(self, m, n):
|
||||
def test_deserialize_context_no_tenant_id(self):
|
||||
context_dict = {'foo': 'bar',
|
||||
'user_id': 1,
|
||||
'project_id': 1}
|
||||
'project_id': 1,
|
||||
'is_admin': True}
|
||||
|
||||
c = self.ser.deserialize_context(context_dict)
|
||||
|
||||
self.assertEqual(1, c.user_id)
|
||||
self.assertEqual(1, c.project_id)
|
||||
|
||||
@mock.patch('neutron.policy.check_is_advsvc', return_val=False)
|
||||
@mock.patch('neutron.policy.check_is_admin', return_val=False)
|
||||
def test_deserialize_context_no_ids(self, m, n):
|
||||
context_dict = {'foo': 'bar'}
|
||||
def test_deserialize_context_no_ids(self):
|
||||
context_dict = {'foo': 'bar', 'is_admin': True}
|
||||
|
||||
c = self.ser.deserialize_context(context_dict)
|
||||
|
||||
|
@ -14,9 +14,9 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib import context
|
||||
|
||||
from neutron.common import exceptions as n_exc
|
||||
from neutron import context
|
||||
from neutron.core_extensions import base as base_core
|
||||
from neutron.core_extensions import qos as qos_core
|
||||
from neutron.plugins.common import constants as plugin_constants
|
||||
|
@ -15,13 +15,13 @@
|
||||
import contextlib
|
||||
|
||||
from neutron_lib import constants as n_consts
|
||||
from neutron_lib import context
|
||||
from neutron_lib.db import constants as db_const
|
||||
from oslo_utils import uuidutils
|
||||
import webob.exc
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron.common import config
|
||||
from neutron import context
|
||||
import neutron.extensions
|
||||
from neutron.extensions import metering
|
||||
from neutron.plugins.common import constants
|
||||
|
@ -15,8 +15,8 @@
|
||||
import datetime
|
||||
|
||||
import mock
|
||||
from neutron_lib import context
|
||||
|
||||
from neutron import context
|
||||
from neutron.db.quota import api as quota_api
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
||||
|
@ -13,10 +13,10 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as lib_exc
|
||||
|
||||
from neutron.common import exceptions
|
||||
from neutron import context
|
||||
from neutron.db import db_base_plugin_v2 as base_plugin
|
||||
from neutron.db.quota import driver
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
@ -19,13 +19,13 @@ import datetime
|
||||
import mock
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as exc
|
||||
from oslo_utils import timeutils
|
||||
import testscenarios
|
||||
|
||||
from neutron import context
|
||||
from neutron.db import agents_db
|
||||
from neutron.db import db_base_plugin_v2 as base_plugin
|
||||
from neutron.db.models import agent as agent_model
|
||||
|
@ -17,6 +17,7 @@ import datetime
|
||||
|
||||
import mock
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as db_exc
|
||||
@ -30,7 +31,6 @@ from neutron.api.rpc.handlers import dhcp_rpc
|
||||
from neutron.api.rpc.handlers import l3_rpc
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.common import constants as n_const
|
||||
from neutron import context
|
||||
from neutron.db import agents_db
|
||||
from neutron.db import agentschedulers_db
|
||||
from neutron.db.models import agent as agent_model
|
||||
@ -706,7 +706,7 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
|
||||
self._take_down_agent_and_run_reschedule(L3_HOSTA) # Exception
|
||||
|
||||
def test_router_rescheduler_catches_exceptions_on_fetching_bindings(self):
|
||||
with mock.patch('neutron.context.get_admin_context') as get_ctx:
|
||||
with mock.patch('neutron_lib.context.get_admin_context') as get_ctx:
|
||||
mock_ctx = mock.Mock()
|
||||
get_ctx.return_value = mock_ctx
|
||||
mock_ctx.session.query.side_effect = db_exc.DBError()
|
||||
|
@ -14,8 +14,8 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib import context
|
||||
|
||||
from neutron import context
|
||||
from neutron.db import _utils as db_utils
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
||||
|
@ -22,6 +22,7 @@ import eventlet
|
||||
import mock
|
||||
import netaddr
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as lib_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from neutron_lib.utils import helpers
|
||||
@ -47,7 +48,6 @@ from neutron.common import exceptions as n_exc
|
||||
from neutron.common import ipv6_utils
|
||||
from neutron.common import test_lib
|
||||
from neutron.common import utils
|
||||
from neutron import context
|
||||
from neutron.db import api as db_api
|
||||
from neutron.db import db_base_plugin_common
|
||||
from neutron.db import ipam_backend_mixin
|
||||
|
@ -15,12 +15,12 @@
|
||||
|
||||
import mock
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron.callbacks import events
|
||||
from neutron.callbacks import registry
|
||||
from neutron.callbacks import resources
|
||||
from neutron import context
|
||||
from neutron.db import api as db_api
|
||||
from neutron.db import dvr_mac_db
|
||||
from neutron.db.models import dvr as dvr_models
|
||||
|
@ -14,8 +14,8 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib import context
|
||||
|
||||
from neutron import context
|
||||
from neutron.db import common_db_mixin
|
||||
from neutron.db import extraroute_db
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
import mock
|
||||
from neutron_lib import constants as const
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_utils import uuidutils
|
||||
@ -23,7 +24,6 @@ from neutron.callbacks import events
|
||||
from neutron.callbacks import registry
|
||||
from neutron.callbacks import resources
|
||||
from neutron.common import constants as n_const
|
||||
from neutron import context
|
||||
from neutron.db import agents_db
|
||||
from neutron.db import common_db_mixin
|
||||
from neutron.db import l3_agentschedulers_db
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
import mock
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
@ -30,7 +31,6 @@ from neutron.callbacks import exceptions as c_exc
|
||||
from neutron.callbacks import registry
|
||||
from neutron.callbacks import resources
|
||||
from neutron.common import constants as n_const
|
||||
from neutron import context
|
||||
from neutron.db import agents_db
|
||||
from neutron.db import common_db_mixin
|
||||
from neutron.db import l3_agentschedulers_db
|
||||
|
@ -13,11 +13,11 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib import context as n_ctx
|
||||
import testtools
|
||||
|
||||
from neutron.callbacks import registry
|
||||
from neutron.callbacks import resources
|
||||
from neutron import context as n_ctx
|
||||
from neutron.db import models_v2
|
||||
from neutron.db import provisioning_blocks as pb
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
import mock
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
import sqlalchemy
|
||||
import testtools
|
||||
|
||||
@ -20,7 +21,6 @@ from neutron.callbacks import events
|
||||
from neutron.callbacks import exceptions
|
||||
from neutron.callbacks import registry
|
||||
from neutron.callbacks import resources
|
||||
from neutron import context
|
||||
from neutron.db import common_db_mixin
|
||||
from neutron.db import securitygroups_db
|
||||
from neutron.extensions import securitygroup
|
||||
|
@ -13,6 +13,7 @@
|
||||
import abc
|
||||
import netaddr
|
||||
|
||||
from neutron_lib import context
|
||||
from oslo_db import exception
|
||||
from oslo_db.tests.sqlalchemy import base as test_base
|
||||
from oslo_utils import timeutils
|
||||
@ -20,7 +21,6 @@ from oslo_utils import uuidutils
|
||||
import six
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron import context
|
||||
from neutron.db import sqlalchemytypes
|
||||
from neutron.tests import tools
|
||||
|
||||
|
@ -14,10 +14,10 @@
|
||||
|
||||
import gc
|
||||
|
||||
from neutron_lib import context
|
||||
from sqlalchemy.ext import declarative
|
||||
import testtools
|
||||
|
||||
from neutron import context
|
||||
from neutron.db import standard_attr
|
||||
from neutron.tests import base
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
@ -17,13 +17,13 @@ import contextlib
|
||||
import mock
|
||||
import netaddr
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
import webob.exc
|
||||
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.callbacks import events
|
||||
from neutron.callbacks import registry
|
||||
from neutron.callbacks import resources
|
||||
from neutron import context
|
||||
from neutron.db import address_scope_db
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.extensions import address_scope as ext_address_scope
|
||||
|
@ -18,12 +18,12 @@ from datetime import datetime
|
||||
import time
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import uuidutils
|
||||
from webob import exc
|
||||
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron import context
|
||||
from neutron.db import agents_db
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.extensions import agent
|
||||
|
@ -11,7 +11,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron import context
|
||||
from neutron_lib import context
|
||||
|
||||
from neutron.db import agents_db
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.extensions import agent
|
||||
|
@ -16,11 +16,11 @@ import math
|
||||
|
||||
import netaddr
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
|
||||
from neutron.common import utils
|
||||
from neutron import context
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.extensions import dns
|
||||
from neutron.plugins.ml2 import config
|
||||
|
@ -15,12 +15,12 @@
|
||||
|
||||
import mock
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_utils import uuidutils
|
||||
import testtools
|
||||
from webob import exc
|
||||
|
||||
from neutron import context
|
||||
from neutron.db import models_v2
|
||||
from neutron.extensions import external_net as external_net
|
||||
from neutron.tests.unit.api.v2 import test_base
|
||||
|
@ -14,12 +14,12 @@
|
||||
# under the License.
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib.utils import helpers
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import uuidutils
|
||||
from webob import exc
|
||||
|
||||
from neutron import context
|
||||
from neutron.db import extraroute_db
|
||||
from neutron.extensions import extraroute
|
||||
from neutron.extensions import l3
|
||||
|
@ -17,12 +17,12 @@ import copy
|
||||
import fixtures
|
||||
import mock
|
||||
|
||||
from neutron_lib import context
|
||||
from neutron_lib.db import constants as db_const
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import uuidutils
|
||||
from webob import exc
|
||||
|
||||
from neutron import context
|
||||
from neutron.db import api as dbapi
|
||||
from neutron.db.models import l3 as l3_models
|
||||
from neutron.db import servicetype_db
|
||||
|
@ -20,6 +20,7 @@ import copy
|
||||
import mock
|
||||
import netaddr
|
||||
from neutron_lib import constants as lib_constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
@ -36,7 +37,6 @@ from neutron.callbacks import events
|
||||
from neutron.callbacks import exceptions
|
||||
from neutron.callbacks import registry
|
||||
from neutron.callbacks import resources
|
||||
from neutron import context
|
||||
from neutron.db import common_db_mixin
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.db import dns_db
|
||||
|
@ -17,6 +17,7 @@
|
||||
import mock
|
||||
import netaddr
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context as nctx
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as db_exc
|
||||
@ -26,7 +27,6 @@ import testscenarios
|
||||
from webob import exc
|
||||
|
||||
from neutron.common import utils
|
||||
from neutron import context as nctx
|
||||
from neutron.db import api as db_api
|
||||
from neutron.db import l3_db
|
||||
from neutron.db import l3_gwmode_db
|
||||
@ -121,7 +121,7 @@ class TestL3GwModeMixin(testlib_api.SqlTestCase):
|
||||
self.setup_coreplugin(plugin)
|
||||
self.target_object = TestDbIntPlugin()
|
||||
# Patch the context
|
||||
ctx_patcher = mock.patch('neutron.context', autospec=True)
|
||||
ctx_patcher = mock.patch('neutron_lib.context', autospec=True)
|
||||
mock_context = ctx_patcher.start()
|
||||
self.context = mock_context.get_admin_context()
|
||||
# This ensure also calls to elevated work in unit tests
|
||||
|
@ -14,10 +14,10 @@
|
||||
# limitations under the License.
|
||||
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import context
|
||||
from neutron_lib.plugins import directory
|
||||
from webob import exc
|
||||
|
||||
from neutron import context
|
||||
from neutron.db import _utils as db_utils
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.db import portsecurity_db
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
import mock
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import uuidutils
|
||||
@ -23,7 +24,6 @@ import webtest
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron.api.v2 import router
|
||||
from neutron import context
|
||||
from neutron.extensions import providernet as pnet
|
||||
from neutron import quota
|
||||
from neutron.tests import tools
|
||||
|
@ -16,6 +16,7 @@
|
||||
import sys
|
||||
|
||||
import mock
|
||||
from neutron_lib import context
|
||||
from oslo_config import cfg
|
||||
import testtools
|
||||
from webob import exc
|
||||
@ -26,7 +27,6 @@ from neutron.api.v2 import router
|
||||
from neutron.common import config
|
||||
from neutron.common import constants
|
||||
from neutron.common import exceptions
|
||||
from neutron import context
|
||||
from neutron.db.quota import driver
|
||||
from neutron import quota
|
||||
from neutron.quota import resource_registry
|
||||
|
@ -18,6 +18,7 @@ import contextlib
|
||||
import mock
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import constants as const
|
||||
from neutron_lib import context
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
import oslo_db.exception as exc
|
||||
@ -27,7 +28,6 @@ import webob.exc
|
||||
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.common import exceptions as n_exc
|
||||
from neutron import context
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.db import securitygroups_db
|
||||
from neutron.extensions import securitygroup as ext_sg
|
||||
|
@ -18,6 +18,7 @@ from keystoneauth1 import exceptions as ks_exc
|
||||
import mock
|
||||
import netaddr
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from novaclient import exceptions as nova_exc
|
||||
@ -32,7 +33,6 @@ from neutron.callbacks import registry
|
||||
from neutron.callbacks import resources
|
||||
from neutron.common import exceptions as neutron_exc
|
||||
from neutron.conf.plugins.ml2.drivers import driver_type
|
||||
from neutron import context
|
||||
from neutron.db import agents_db
|
||||
from neutron.db import agentschedulers_db
|
||||
from neutron.db import db_base_plugin_v2
|
||||
|
@ -14,6 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import uuidutils
|
||||
@ -21,7 +22,6 @@ import webob.exc as webexc
|
||||
import webtest
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron import context
|
||||
from neutron.db.models import servicetype as st_model
|
||||
from neutron.db import servicetype_db as st_db
|
||||
from neutron.extensions import servicetype
|
||||
|
@ -16,10 +16,10 @@ import datetime
|
||||
import six
|
||||
|
||||
import mock
|
||||
from neutron_lib import context
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from neutron import context
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.db.models import tag as tag_model
|
||||
from neutron.db import models_v2
|
||||
|
@ -13,9 +13,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib import context
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from neutron import context
|
||||
from neutron.ipam.drivers.neutrondb_ipam import db_api
|
||||
from neutron.objects import ipam as ipam_obj
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
@ -16,12 +16,12 @@
|
||||
import mock
|
||||
import netaddr
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from neutron.common import constants as n_const
|
||||
from neutron import context
|
||||
from neutron.ipam.drivers.neutrondb_ipam import driver
|
||||
from neutron.ipam import exceptions as ipam_exc
|
||||
from neutron.ipam import requests as ipam_req
|
||||
|
@ -13,11 +13,11 @@
|
||||
import mock
|
||||
import netaddr
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import netutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from neutron import context
|
||||
from neutron.ipam import driver
|
||||
from neutron.ipam import exceptions as ipam_exc
|
||||
from neutron.ipam import requests as ipam_req
|
||||
|
@ -16,13 +16,13 @@
|
||||
import mock
|
||||
import netaddr
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from neutron.common import exceptions as n_exc
|
||||
from neutron import context
|
||||
from neutron.ipam import requests as ipam_req
|
||||
from neutron.ipam import subnet_alloc
|
||||
from neutron.tests.unit.db import test_db_base_plugin_v2
|
||||
|
@ -11,10 +11,10 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron import context
|
||||
from neutron.db import models_v2
|
||||
from neutron.objects import base
|
||||
from neutron.objects.db import api
|
||||
|
@ -10,7 +10,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron import context
|
||||
from neutron_lib import context
|
||||
|
||||
from neutron.objects.port.extensions import allowedaddresspairs
|
||||
from neutron.tests.unit.objects import test_base as obj_test_base
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
@ -18,6 +18,7 @@ import random
|
||||
|
||||
import mock
|
||||
import netaddr
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.utils import helpers
|
||||
from oslo_db import exception as obj_exc
|
||||
@ -30,7 +31,6 @@ import testtools
|
||||
|
||||
from neutron.common import constants
|
||||
from neutron.common import utils
|
||||
from neutron import context
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.db.models import external_net as ext_net_model
|
||||
from neutron.db.models import l3 as l3_model
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
import mock
|
||||
|
||||
from neutron_lib import context as n_context
|
||||
from neutron_lib.db import model_base
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from oslo_versionedobjects import base as obj_base
|
||||
@ -19,7 +20,6 @@ from oslo_versionedobjects import fields as obj_fields
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.callbacks import events
|
||||
from neutron import context as n_context
|
||||
from neutron.db import rbac_db_models
|
||||
from neutron.extensions import rbac as ext_rbac
|
||||
from neutron.objects import common_types
|
||||
|
@ -10,9 +10,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib import context
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from neutron import context
|
||||
from neutron.db import rbac_db_models
|
||||
from neutron.objects import base as obj_base
|
||||
from neutron.objects.db import api as obj_db_api
|
||||
|
@ -14,12 +14,12 @@
|
||||
# limitations under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as exc
|
||||
from six import moves
|
||||
import testtools
|
||||
from testtools import matchers
|
||||
|
||||
from neutron import context
|
||||
from neutron.plugins.common import constants as p_const
|
||||
from neutron.plugins.ml2 import config
|
||||
from neutron.plugins.ml2 import driver_api as api
|
||||
|
@ -13,11 +13,11 @@
|
||||
# under the License.
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from neutron.common import constants as n_const
|
||||
from neutron.common import utils
|
||||
from neutron import context
|
||||
from neutron.db.models import l3 as l3_models
|
||||
from neutron.db.models import l3_attrs
|
||||
from neutron.db.models import l3ha as l3ha_model
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
import mock
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_serialization import jsonutils
|
||||
@ -23,7 +24,6 @@ import testtools
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.common import constants as n_const
|
||||
from neutron.common import topics
|
||||
from neutron import context
|
||||
from neutron.db import agents_db
|
||||
from neutron.db import common_db_mixin
|
||||
from neutron.db import l3_agentschedulers_db
|
||||
|
@ -14,10 +14,10 @@
|
||||
# limitations under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib import context
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from neutron.common import constants
|
||||
from neutron import context
|
||||
from neutron.objects.qos import policy
|
||||
from neutron.objects.qos import rule
|
||||
from neutron.plugins.ml2.drivers.mech_sriov.agent.common import exceptions
|
||||
|
@ -13,9 +13,9 @@
|
||||
import copy
|
||||
|
||||
import mock
|
||||
from neutron_lib import context
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from neutron import context
|
||||
from neutron.objects.qos import policy
|
||||
from neutron.objects.qos import rule
|
||||
from neutron.plugins.ml2.drivers.openvswitch.agent import (
|
||||
|
@ -14,10 +14,10 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib import context
|
||||
from oslo_db import exception as exc
|
||||
from sqlalchemy.orm import query
|
||||
|
||||
from neutron import context
|
||||
from neutron.plugins.ml2.drivers import type_vlan
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
||||
|
@ -13,10 +13,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as exc
|
||||
|
||||
from neutron.common import exceptions as n_exc
|
||||
from neutron import context
|
||||
from neutron.objects.plugins.ml2 import flatallocation as flat_obj
|
||||
from neutron.plugins.common import constants as p_const
|
||||
from neutron.plugins.ml2 import config
|
||||
|
@ -14,10 +14,10 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as exc
|
||||
from testtools import matchers
|
||||
|
||||
from neutron import context
|
||||
from neutron.db.models.plugins.ml2 import vlanallocation as vlan_alloc_model
|
||||
from neutron.plugins.common import constants as p_const
|
||||
from neutron.plugins.common import utils as plugin_utils
|
||||
|
@ -20,10 +20,10 @@ from keystoneauth1 import session
|
||||
import mock
|
||||
import netaddr
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib.plugins import directory
|
||||
import testtools
|
||||
|
||||
from neutron import context
|
||||
from neutron.extensions import dns
|
||||
from neutron.extensions import providernet as pnet
|
||||
from neutron.objects import ports as port_obj
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user