Browse Source

Spin off context module

NeutronLibImpact

Partially-implements: blueprint neutron-lib

Change-Id: I48cf45dc1b07035d952152eac2548a3bd9fc2832
tags/11.0.0.0b1
Armando Migliaccio 2 years ago
parent
commit
ca751a1486
100 changed files with 122 additions and 316 deletions
  1. 1
    1
      neutron/agent/dhcp/agent.py
  2. 1
    1
      neutron/agent/l3/agent.py
  3. 1
    1
      neutron/agent/metadata/agent.py
  4. 1
    1
      neutron/api/rpc/handlers/l3_rpc.py
  5. 1
    2
      neutron/auth.py
  6. 1
    1
      neutron/cmd/eventlet/usage_audit.py
  7. 1
    1
      neutron/common/profiler.py
  8. 1
    1
      neutron/common/rpc.py
  9. 0
    175
      neutron/context.py
  10. 1
    1
      neutron/db/agents_db.py
  11. 1
    1
      neutron/db/agentschedulers_db.py
  12. 2
    4
      neutron/db/api.py
  13. 1
    1
      neutron/db/db_base_plugin_v2.py
  14. 1
    1
      neutron/db/l3_db.py
  15. 1
    1
      neutron/notifiers/nova.py
  16. 1
    1
      neutron/plugins/ml2/drivers/agent/_common_agent.py
  17. 1
    1
      neutron/plugins/ml2/drivers/helpers.py
  18. 1
    1
      neutron/plugins/ml2/drivers/l2pop/mech_driver.py
  19. 1
    1
      neutron/plugins/ml2/drivers/mech_sriov/agent/sriov_nic_agent.py
  20. 1
    1
      neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py
  21. 1
    1
      neutron/plugins/ml2/drivers/type_tunnel.py
  22. 1
    1
      neutron/plugins/ml2/drivers/type_vlan.py
  23. 1
    1
      neutron/plugins/ml2/ovo_rpc.py
  24. 1
    22
      neutron/policy.py
  25. 1
    1
      neutron/service.py
  26. 1
    1
      neutron/services/externaldns/driver.py
  27. 1
    1
      neutron/services/metering/agents/metering_agent.py
  28. 1
    1
      neutron/services/qos/qos_plugin.py
  29. 1
    1
      neutron/services/trunk/drivers/openvswitch/agent/ovsdb_handler.py
  30. 1
    1
      neutron/services/trunk/plugin.py
  31. 1
    1
      neutron/tests/common/helpers.py
  32. 4
    2
      neutron/tests/functional/api/test_policies.py
  33. 1
    1
      neutron/tests/functional/db/test_ipam.py
  34. 7
    1
      neutron/tests/functional/pecan_wsgi/test_controllers.py
  35. 1
    1
      neutron/tests/functional/pecan_wsgi/test_functional.py
  36. 1
    1
      neutron/tests/functional/pecan_wsgi/test_hooks.py
  37. 1
    1
      neutron/tests/functional/plugins/ml2/test_plugin.py
  38. 1
    1
      neutron/tests/functional/scheduler/test_dhcp_agent_scheduler.py
  39. 1
    1
      neutron/tests/functional/scheduler/test_l3_agent_scheduler.py
  40. 1
    1
      neutron/tests/functional/services/l3_router/test_l3_dvr_router_plugin.py
  41. 1
    1
      neutron/tests/retargetable/client_fixtures.py
  42. 1
    1
      neutron/tests/unit/_test_extension_portbindings.py
  43. 1
    1
      neutron/tests/unit/agent/l2/extensions/test_qos.py
  44. 1
    1
      neutron/tests/unit/agent/test_securitygroups_rpc.py
  45. 1
    1
      neutron/tests/unit/api/rpc/handlers/test_l3_rpc.py
  46. 1
    1
      neutron/tests/unit/api/rpc/handlers/test_resources_rpc.py
  47. 1
    1
      neutron/tests/unit/api/v2/test_attributes.py
  48. 1
    1
      neutron/tests/unit/api/v2/test_base.py
  49. 1
    1
      neutron/tests/unit/api/v2/test_resource.py
  50. 11
    16
      neutron/tests/unit/common/test_rpc.py
  51. 1
    1
      neutron/tests/unit/core_extensions/test_qos.py
  52. 1
    1
      neutron/tests/unit/db/metering/test_metering_db.py
  53. 1
    1
      neutron/tests/unit/db/quota/test_api.py
  54. 1
    1
      neutron/tests/unit/db/quota/test_driver.py
  55. 1
    1
      neutron/tests/unit/db/test_agents_db.py
  56. 2
    2
      neutron/tests/unit/db/test_agentschedulers_db.py
  57. 1
    1
      neutron/tests/unit/db/test_common_db_mixin.py
  58. 1
    1
      neutron/tests/unit/db/test_db_base_plugin_v2.py
  59. 1
    1
      neutron/tests/unit/db/test_dvr_mac_db.py
  60. 1
    1
      neutron/tests/unit/db/test_extraroute_db.py
  61. 1
    1
      neutron/tests/unit/db/test_l3_dvr_db.py
  62. 1
    1
      neutron/tests/unit/db/test_l3_hamode_db.py
  63. 1
    1
      neutron/tests/unit/db/test_provisioning_blocks.py
  64. 1
    1
      neutron/tests/unit/db/test_securitygroups_db.py
  65. 1
    1
      neutron/tests/unit/db/test_sqlalchemytypes.py
  66. 1
    1
      neutron/tests/unit/db/test_standard_attr.py
  67. 1
    1
      neutron/tests/unit/extensions/test_address_scope.py
  68. 1
    1
      neutron/tests/unit/extensions/test_agent.py
  69. 2
    1
      neutron/tests/unit/extensions/test_availability_zone.py
  70. 1
    1
      neutron/tests/unit/extensions/test_dns.py
  71. 1
    1
      neutron/tests/unit/extensions/test_external_net.py
  72. 1
    1
      neutron/tests/unit/extensions/test_extraroute.py
  73. 1
    1
      neutron/tests/unit/extensions/test_flavors.py
  74. 1
    1
      neutron/tests/unit/extensions/test_l3.py
  75. 2
    2
      neutron/tests/unit/extensions/test_l3_ext_gw_mode.py
  76. 1
    1
      neutron/tests/unit/extensions/test_portsecurity.py
  77. 1
    1
      neutron/tests/unit/extensions/test_providernet.py
  78. 1
    1
      neutron/tests/unit/extensions/test_quotasv2.py
  79. 1
    1
      neutron/tests/unit/extensions/test_securitygroup.py
  80. 1
    1
      neutron/tests/unit/extensions/test_segment.py
  81. 1
    1
      neutron/tests/unit/extensions/test_servicetype.py
  82. 1
    1
      neutron/tests/unit/extensions/test_timestamp.py
  83. 1
    1
      neutron/tests/unit/ipam/drivers/neutrondb_ipam/test_db_api.py
  84. 1
    1
      neutron/tests/unit/ipam/drivers/neutrondb_ipam/test_driver.py
  85. 1
    1
      neutron/tests/unit/ipam/test_requests.py
  86. 1
    1
      neutron/tests/unit/ipam/test_subnet_alloc.py
  87. 1
    1
      neutron/tests/unit/objects/db/test_api.py
  88. 2
    1
      neutron/tests/unit/objects/port/extensions/test_allowedaddresspairs.py
  89. 1
    1
      neutron/tests/unit/objects/test_base.py
  90. 1
    1
      neutron/tests/unit/objects/test_rbac_db.py
  91. 1
    1
      neutron/tests/unit/objects/test_subnet.py
  92. 1
    1
      neutron/tests/unit/plugins/ml2/drivers/base_type_tunnel.py
  93. 1
    1
      neutron/tests/unit/plugins/ml2/drivers/l2pop/test_db.py
  94. 1
    1
      neutron/tests/unit/plugins/ml2/drivers/l2pop/test_mech_driver.py
  95. 1
    1
      neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/extension_drivers/test_qos_driver.py
  96. 1
    1
      neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/extension_drivers/test_qos_driver.py
  97. 1
    1
      neutron/tests/unit/plugins/ml2/drivers/test_helpers.py
  98. 1
    1
      neutron/tests/unit/plugins/ml2/drivers/test_type_flat.py
  99. 1
    1
      neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py
  100. 0
    0
      neutron/tests/unit/plugins/ml2/extensions/test_dns_integration.py

+ 1
- 1
neutron/agent/dhcp/agent.py View File

@@ -18,6 +18,7 @@ import os
18 18
 
19 19
 import eventlet
20 20
 from neutron_lib import constants
21
+from neutron_lib import context
21 22
 from neutron_lib import exceptions
22 23
 from oslo_concurrency import lockutils
23 24
 from oslo_config import cfg
@@ -37,7 +38,6 @@ from neutron.common import constants as n_const
37 38
 from neutron.common import rpc as n_rpc
38 39
 from neutron.common import topics
39 40
 from neutron.common import utils
40
-from neutron import context
41 41
 from neutron import manager
42 42
 
43 43
 LOG = logging.getLogger(__name__)

+ 1
- 1
neutron/agent/l3/agent.py View File

@@ -16,6 +16,7 @@
16 16
 import eventlet
17 17
 import netaddr
18 18
 from neutron_lib import constants as lib_const
19
+from neutron_lib import context as n_context
19 20
 from oslo_config import cfg
20 21
 from oslo_context import context as common_context
21 22
 from oslo_log import log as logging
@@ -53,7 +54,6 @@ from neutron.common import ipv6_utils
53 54
 from neutron.common import rpc as n_rpc
54 55
 from neutron.common import topics
55 56
 from neutron.common import utils
56
-from neutron import context as n_context
57 57
 from neutron import manager
58 58
 
59 59
 LOG = logging.getLogger(__name__)

+ 1
- 1
neutron/agent/metadata/agent.py View File

@@ -17,6 +17,7 @@ import hmac
17 17
 
18 18
 import httplib2
19 19
 from neutron_lib import constants
20
+from neutron_lib import context
20 21
 from oslo_config import cfg
21 22
 from oslo_log import log as logging
22 23
 import oslo_messaging
@@ -34,7 +35,6 @@ from neutron.common import constants as n_const
34 35
 from neutron.common import rpc as n_rpc
35 36
 from neutron.common import topics
36 37
 from neutron.conf.agent.metadata import config
37
-from neutron import context
38 38
 
39 39
 LOG = logging.getLogger(__name__)
40 40
 

+ 1
- 1
neutron/api/rpc/handlers/l3_rpc.py View File

@@ -14,6 +14,7 @@
14 14
 # limitations under the License.
15 15
 
16 16
 from neutron_lib import constants
17
+from neutron_lib import context as neutron_context
17 18
 from neutron_lib import exceptions
18 19
 from neutron_lib.plugins import directory
19 20
 from oslo_config import cfg
@@ -23,7 +24,6 @@ import six
23 24
 
24 25
 from neutron.common import constants as n_const
25 26
 from neutron.common import utils
26
-from neutron import context as neutron_context
27 27
 from neutron.db import api as db_api
28 28
 from neutron.extensions import l3
29 29
 from neutron.extensions import portbindings

+ 1
- 2
neutron/auth.py View File

@@ -12,6 +12,7 @@
12 12
 #    License for the specific language governing permissions and limitations
13 13
 #    under the License.
14 14
 
15
+from neutron_lib import context
15 16
 from oslo_config import cfg
16 17
 from oslo_log import log as logging
17 18
 from oslo_middleware import base
@@ -19,8 +20,6 @@ from oslo_middleware import request_id
19 20
 import webob.dec
20 21
 import webob.exc
21 22
 
22
-from neutron import context
23
-
24 23
 LOG = logging.getLogger(__name__)
25 24
 
26 25
 

+ 1
- 1
neutron/cmd/eventlet/usage_audit.py View File

@@ -20,11 +20,11 @@ subnets.
20 20
 import sys
21 21
 
22 22
 from neutron_lib import constants
23
+from neutron_lib import context
23 24
 from neutron_lib.plugins import directory
24 25
 
25 26
 from neutron.common import config
26 27
 from neutron.common import rpc as n_rpc
27
-from neutron import context
28 28
 from neutron import manager
29 29
 
30 30
 

+ 1
- 1
neutron/common/profiler.py View File

@@ -10,6 +10,7 @@
10 10
 #    License for the specific language governing permissions and limitations
11 11
 #    under the License.
12 12
 
13
+from neutron_lib import context
13 14
 from oslo_config import cfg
14 15
 from oslo_log import log as logging
15 16
 import osprofiler.initializer
@@ -17,7 +18,6 @@ from osprofiler import opts as profiler_opts
17 18
 import osprofiler.web
18 19
 
19 20
 from neutron._i18n import _LI
20
-from neutron import context
21 21
 
22 22
 
23 23
 CONF = cfg.CONF

+ 1
- 1
neutron/common/rpc.py View File

@@ -18,6 +18,7 @@ import collections
18 18
 import random
19 19
 import time
20 20
 
21
+from neutron_lib import context
21 22
 from neutron_lib import exceptions as lib_exceptions
22 23
 from oslo_config import cfg
23 24
 from oslo_log import log as logging
@@ -30,7 +31,6 @@ from osprofiler import profiler
30 31
 
31 32
 from neutron._i18n import _LE, _LW
32 33
 from neutron.common import exceptions
33
-from neutron import context
34 34
 
35 35
 
36 36
 LOG = logging.getLogger(__name__)

+ 0
- 175
neutron/context.py View File

@@ -1,175 +0,0 @@
1
-# Copyright 2012 OpenStack Foundation.
2
-# All Rights Reserved.
3
-#
4
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
-#    not use this file except in compliance with the License. You may obtain
6
-#    a copy of the License at
7
-#
8
-#         http://www.apache.org/licenses/LICENSE-2.0
9
-#
10
-#    Unless required by applicable law or agreed to in writing, software
11
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
-#    License for the specific language governing permissions and limitations
14
-#    under the License.
15
-
16
-"""Context: context for security/db session."""
17
-
18
-import copy
19
-import datetime
20
-
21
-from oslo_context import context as oslo_context
22
-from oslo_db.sqlalchemy import enginefacade
23
-
24
-from neutron.db import api as db_api
25
-from neutron import policy
26
-
27
-
28
-class ContextBase(oslo_context.RequestContext):
29
-    """Security context and request information.
30
-
31
-    Represents the user taking a given action within the system.
32
-
33
-    """
34
-
35
-    def __init__(self, user_id=None, tenant_id=None, is_admin=None,
36
-                 timestamp=None, tenant_name=None, user_name=None,
37
-                 is_advsvc=None, **kwargs):
38
-        """Object initialization.
39
-
40
-        :param overwrite: Set to False to ensure that the greenthread local
41
-            copy of the index is not overwritten.
42
-        """
43
-        # NOTE(jamielennox): We maintain these arguments in order for tests
44
-        # that pass arguments positionally.
45
-        kwargs.setdefault('user', user_id)
46
-        kwargs.setdefault('tenant', tenant_id)
47
-        super(ContextBase, self).__init__(is_admin=is_admin, **kwargs)
48
-
49
-        self.user_name = user_name
50
-        # NOTE(sdague): tenant* is a deprecated set of names from
51
-        # keystone, and is no longer set in modern keystone middleware
52
-        # code, as such this is almost always going to be None.
53
-        self.tenant_name = tenant_name
54
-
55
-        if not timestamp:
56
-            timestamp = datetime.datetime.utcnow()
57
-        self.timestamp = timestamp
58
-        self.is_advsvc = is_advsvc
59
-        if self.is_advsvc is None:
60
-            self.is_advsvc = self.is_admin or policy.check_is_advsvc(self)
61
-        if self.is_admin is None:
62
-            self.is_admin = policy.check_is_admin(self)
63
-
64
-    @property
65
-    def project_id(self):
66
-        return self.tenant
67
-
68
-    @property
69
-    def tenant_id(self):
70
-        return self.tenant
71
-
72
-    @tenant_id.setter
73
-    def tenant_id(self, tenant_id):
74
-        self.tenant = tenant_id
75
-
76
-    @property
77
-    def user_id(self):
78
-        return self.user
79
-
80
-    @user_id.setter
81
-    def user_id(self, user_id):
82
-        self.user = user_id
83
-
84
-    def to_dict(self):
85
-        context = super(ContextBase, self).to_dict()
86
-        context.update({
87
-            'user_id': self.user_id,
88
-            'tenant_id': self.tenant_id,
89
-            'project_id': self.project_id,
90
-            'timestamp': str(self.timestamp),
91
-            # prefer project_name, as that's what's going to be set by
92
-            # keystone. Fall back if for some reason it's blank.
93
-            'tenant_name': self.project_name or self.tenant_name,
94
-            'project_name': self.project_name or self.tenant_name,
95
-            'user_name': self.user_name,
96
-        })
97
-        return context
98
-
99
-    def to_policy_values(self):
100
-        values = super(ContextBase, self).to_policy_values()
101
-        values['tenant_id'] = self.tenant_id
102
-        values['is_admin'] = self.is_admin
103
-
104
-        # NOTE(jamielennox): These are almost certainly unused and non-standard
105
-        # but kept for backwards compatibility. Remove them in Pike
106
-        # (oslo.context from Ocata release already issues deprecation warnings
107
-        # for non-standard keys).
108
-        values['user'] = self.user
109
-        values['tenant'] = self.tenant
110
-        values['domain'] = self.domain
111
-        values['user_domain'] = self.user_domain
112
-        values['project_domain'] = self.project_domain
113
-        # prefer project_name, as that's what's going to be set by
114
-        # keystone. Fall back if for some reason it's blank.
115
-        values['tenant_name'] = self.project_name or self.tenant_name
116
-        values['project_name'] = self.project_name or self.tenant_name
117
-        values['user_name'] = self.user_name
118
-
119
-        return values
120
-
121
-    @classmethod
122
-    def from_dict(cls, values):
123
-        return cls(user_id=values.get('user_id', values.get('user')),
124
-                   tenant_id=values.get('tenant_id', values.get('project_id')),
125
-                   is_admin=values.get('is_admin'),
126
-                   roles=values.get('roles'),
127
-                   timestamp=values.get('timestamp'),
128
-                   request_id=values.get('request_id'),
129
-                   tenant_name=values.get('tenant_name'),
130
-                   user_name=values.get('user_name'),
131
-                   auth_token=values.get('auth_token'))
132
-
133
-    def elevated(self):
134
-        """Return a version of this context with admin flag set."""
135
-        context = copy.copy(self)
136
-        context.is_admin = True
137
-
138
-        if 'admin' not in [x.lower() for x in context.roles]:
139
-            context.roles = context.roles + ["admin"]
140
-
141
-        return context
142
-
143
-
144
-@enginefacade.transaction_context_provider
145
-class ContextBaseWithSession(ContextBase):
146
-    pass
147
-
148
-
149
-class Context(ContextBaseWithSession):
150
-    def __init__(self, *args, **kwargs):
151
-        super(Context, self).__init__(*args, **kwargs)
152
-        self._session = None
153
-
154
-    @property
155
-    def session(self):
156
-        # TODO(akamyshnikova): checking for session attribute won't be needed
157
-        # when reader and writer will be used
158
-        if hasattr(super(Context, self), 'session'):
159
-            return super(Context, self).session
160
-        if self._session is None:
161
-            self._session = db_api.get_writer_session()
162
-        return self._session
163
-
164
-
165
-def get_admin_context():
166
-    return Context(user_id=None,
167
-                   tenant_id=None,
168
-                   is_admin=True,
169
-                   overwrite=False)
170
-
171
-
172
-def get_admin_context_without_session():
173
-    return ContextBase(user_id=None,
174
-                       tenant_id=None,
175
-                       is_admin=True)

+ 1
- 1
neutron/db/agents_db.py View File

@@ -19,6 +19,7 @@ import debtcollector
19 19
 from eventlet import greenthread
20 20
 from neutron_lib.api import converters
21 21
 from neutron_lib import constants
22
+from neutron_lib import context
22 23
 from neutron_lib.plugins import directory
23 24
 from oslo_config import cfg
24 25
 from oslo_log import log as logging
@@ -37,7 +38,6 @@ from neutron.callbacks import events
37 38
 from neutron.callbacks import registry
38 39
 from neutron.callbacks import resources
39 40
 from neutron.common import constants as n_const
40
-from neutron import context
41 41
 from neutron.db import _utils as db_utils
42 42
 from neutron.db import api as db_api
43 43
 from neutron.db.models import agent as agent_model

+ 1
- 1
neutron/db/agentschedulers_db.py View File

@@ -18,6 +18,7 @@ import random
18 18
 import time
19 19
 
20 20
 from neutron_lib import constants
21
+from neutron_lib import context as ncontext
21 22
 from oslo_config import cfg
22 23
 from oslo_log import log as logging
23 24
 import oslo_messaging
@@ -29,7 +30,6 @@ from neutron._i18n import _, _LE, _LI, _LW
29 30
 from neutron.agent.common import utils as agent_utils
30 31
 from neutron.common import constants as n_const
31 32
 from neutron.common import utils
32
-from neutron import context as ncontext
33 33
 from neutron.db import agents_db
34 34
 from neutron.db.availability_zone import network as network_az
35 35
 from neutron.db.models import agent as agent_model

+ 2
- 4
neutron/db/api.py View File

@@ -17,11 +17,11 @@ import contextlib
17 17
 import copy
18 18
 
19 19
 from debtcollector import removals
20
+from neutron_lib.db import api
20 21
 from neutron_lib import exceptions
21 22
 from oslo_config import cfg
22 23
 from oslo_db import api as oslo_db_api
23 24
 from oslo_db import exception as db_exc
24
-from oslo_db.sqlalchemy import enginefacade
25 25
 from oslo_log import log as logging
26 26
 from oslo_utils import excutils
27 27
 from osprofiler import opts as profiler_opts
@@ -44,9 +44,7 @@ def set_hook(engine):
44 44
         osprofiler.sqlalchemy.add_tracing(sqlalchemy, engine, 'neutron.db')
45 45
 
46 46
 
47
-context_manager = enginefacade.transaction_context()
48
-
49
-context_manager.configure(sqlite_fk=True)
47
+context_manager = api.get_context_manager()
50 48
 
51 49
 # TODO(ihrachys) the hook assumes options defined by osprofiler, and the only
52 50
 # public function that is provided by osprofiler that will register them is

+ 1
- 1
neutron/db/db_base_plugin_v2.py View File

@@ -18,6 +18,7 @@ import functools
18 18
 import netaddr
19 19
 from neutron_lib.api import validators
20 20
 from neutron_lib import constants
21
+from neutron_lib import context as ctx
21 22
 from neutron_lib import exceptions as exc
22 23
 from neutron_lib.plugins import directory
23 24
 from oslo_config import cfg
@@ -39,7 +40,6 @@ from neutron.common import constants as n_const
39 40
 from neutron.common import exceptions as n_exc
40 41
 from neutron.common import ipv6_utils
41 42
 from neutron.common import utils
42
-from neutron import context as ctx
43 43
 from neutron.db import _utils as ndb_utils
44 44
 from neutron.db import api as db_api
45 45
 from neutron.db import db_base_plugin_common

+ 1
- 1
neutron/db/l3_db.py View File

@@ -20,6 +20,7 @@ from debtcollector import removals
20 20
 import netaddr
21 21
 from neutron_lib.api import validators
22 22
 from neutron_lib import constants
23
+from neutron_lib import context as n_ctx
23 24
 from neutron_lib import exceptions as n_exc
24 25
 from neutron_lib.plugins import directory
25 26
 from oslo_log import log as logging
@@ -38,7 +39,6 @@ from neutron.common import constants as n_const
38 39
 from neutron.common import ipv6_utils
39 40
 from neutron.common import rpc as n_rpc
40 41
 from neutron.common import utils
41
-from neutron import context as n_ctx
42 42
 from neutron.db import _utils as db_utils
43 43
 from neutron.db import api as db_api
44 44
 from neutron.db import common_db_mixin

+ 1
- 1
neutron/notifiers/nova.py View File

@@ -15,6 +15,7 @@
15 15
 
16 16
 from keystoneauth1 import loading as ks_loading
17 17
 from neutron_lib import constants
18
+from neutron_lib import context
18 19
 from neutron_lib import exceptions as exc
19 20
 from neutron_lib.plugins import directory
20 21
 from novaclient import api_versions
@@ -29,7 +30,6 @@ from neutron._i18n import _LE, _LI, _LW
29 30
 from neutron.callbacks import events
30 31
 from neutron.callbacks import registry
31 32
 from neutron.callbacks import resources
32
-from neutron import context
33 33
 from neutron.notifiers import batch_notifier
34 34
 
35 35
 

+ 1
- 1
neutron/plugins/ml2/drivers/agent/_common_agent.py View File

@@ -20,6 +20,7 @@ import sys
20 20
 import time
21 21
 
22 22
 from neutron_lib import constants
23
+from neutron_lib import context
23 24
 from oslo_config import cfg
24 25
 from oslo_log import log as logging
25 26
 from oslo_service import loopingcall
@@ -39,7 +40,6 @@ from neutron.callbacks import resources as local_resources
39 40
 from neutron.common import config as common_config
40 41
 from neutron.common import constants as n_const
41 42
 from neutron.common import topics
42
-from neutron import context
43 43
 from neutron.plugins.ml2.drivers.agent import _agent_manager_base as amb
44 44
 from neutron.plugins.ml2.drivers.agent import capabilities
45 45
 from neutron.plugins.ml2.drivers.agent import config as cagt_config  # noqa

+ 1
- 1
neutron/plugins/ml2/drivers/helpers.py View File

@@ -15,6 +15,7 @@
15 15
 
16 16
 import random
17 17
 
18
+from neutron_lib import context as neutron_ctx
18 19
 from neutron_lib.utils import helpers
19 20
 from oslo_config import cfg
20 21
 from oslo_db import exception as db_exc
@@ -22,7 +23,6 @@ from oslo_log import log
22 23
 
23 24
 from neutron._i18n import _LE
24 25
 from neutron.common import exceptions as exc
25
-from neutron import context as neutron_ctx
26 26
 from neutron.plugins.common import utils as p_utils
27 27
 from neutron.plugins.ml2 import driver_api as api
28 28
 

+ 1
- 1
neutron/plugins/ml2/drivers/l2pop/mech_driver.py View File

@@ -14,6 +14,7 @@
14 14
 #    under the License.
15 15
 
16 16
 from neutron_lib import constants as const
17
+from neutron_lib import context as n_context
17 18
 from neutron_lib import exceptions
18 19
 from neutron_lib.plugins import directory
19 20
 from oslo_config import cfg
@@ -21,7 +22,6 @@ from oslo_log import log as logging
21 22
 
22 23
 from neutron._i18n import _, _LW
23 24
 from neutron.conf.plugins.ml2.drivers import l2pop as config
24
-from neutron import context as n_context
25 25
 from neutron.db import api as db_api
26 26
 from neutron.db import l3_hamode_db
27 27
 from neutron.plugins.ml2 import driver_api as api

+ 1
- 1
neutron/plugins/ml2/drivers/mech_sriov/agent/sriov_nic_agent.py View File

@@ -21,6 +21,7 @@ import sys
21 21
 import time
22 22
 
23 23
 from neutron_lib import constants as n_constants
24
+from neutron_lib import context
24 25
 from neutron_lib.utils import helpers
25 26
 from oslo_config import cfg
26 27
 from oslo_log import log as logging
@@ -38,7 +39,6 @@ from neutron.api.rpc.handlers import securitygroups_rpc as sg_rpc
38 39
 from neutron.common import config as common_config
39 40
 from neutron.common import profiler as setup_profiler
40 41
 from neutron.common import topics
41
-from neutron import context
42 42
 from neutron.extensions import portbindings
43 43
 from neutron.plugins.ml2.drivers.mech_sriov.agent.common import config
44 44
 from neutron.plugins.ml2.drivers.mech_sriov.agent.common \

+ 1
- 1
neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py View File

@@ -23,6 +23,7 @@ import time
23 23
 
24 24
 import netaddr
25 25
 from neutron_lib import constants as n_const
26
+from neutron_lib import context
26 27
 from neutron_lib.utils import helpers
27 28
 from oslo_config import cfg
28 29
 from oslo_log import log as logging
@@ -53,7 +54,6 @@ from neutron.common import config
53 54
 from neutron.common import constants as c_const
54 55
 from neutron.common import topics
55 56
 from neutron.conf.agent import xenapi_conf
56
-from neutron import context
57 57
 from neutron.extensions import portbindings
58 58
 from neutron.plugins.common import constants as p_const
59 59
 from neutron.plugins.common import utils as p_utils

+ 1
- 1
neutron/plugins/ml2/drivers/type_tunnel.py View File

@@ -17,6 +17,7 @@ import itertools
17 17
 import operator
18 18
 
19 19
 import netaddr
20
+from neutron_lib import context
20 21
 from neutron_lib import exceptions as exc
21 22
 from oslo_config import cfg
22 23
 from oslo_db import api as oslo_db_api
@@ -28,7 +29,6 @@ from sqlalchemy import or_
28 29
 
29 30
 from neutron._i18n import _, _LI, _LW
30 31
 from neutron.common import topics
31
-from neutron import context
32 32
 from neutron.db import api as db_api
33 33
 from neutron.plugins.common import constants as p_const
34 34
 from neutron.plugins.common import utils as plugin_utils

+ 1
- 1
neutron/plugins/ml2/drivers/type_vlan.py View File

@@ -15,6 +15,7 @@
15 15
 
16 16
 import sys
17 17
 
18
+from neutron_lib import context
18 19
 from neutron_lib import exceptions as exc
19 20
 from oslo_config import cfg
20 21
 from oslo_log import log
@@ -22,7 +23,6 @@ from six import moves
22 23
 
23 24
 from neutron._i18n import _, _LE, _LI, _LW
24 25
 from neutron.conf.plugins.ml2.drivers import driver_type
25
-from neutron import context
26 26
 from neutron.db import api as db_api
27 27
 from neutron.db.models.plugins.ml2 import vlanallocation as vlan_alloc_model
28 28
 from neutron.plugins.common import constants as p_const

+ 1
- 1
neutron/plugins/ml2/ovo_rpc.py View File

@@ -14,6 +14,7 @@
14 14
 import traceback
15 15
 
16 16
 import eventlet
17
+from neutron_lib import context as n_ctx
17 18
 from oslo_concurrency import lockutils
18 19
 from oslo_log import log as logging
19 20
 
@@ -23,7 +24,6 @@ from neutron.api.rpc.handlers import resources_rpc
23 24
 from neutron.callbacks import events
24 25
 from neutron.callbacks import registry
25 26
 from neutron.callbacks import resources
26
-from neutron import context as n_ctx
27 27
 from neutron.db import api as db_api
28 28
 from neutron.objects import network
29 29
 from neutron.objects import ports

+ 1
- 22
neutron/policy.py View File

@@ -17,6 +17,7 @@ import collections
17 17
 import re
18 18
 
19 19
 from neutron_lib import constants
20
+from neutron_lib import context
20 21
 from neutron_lib import exceptions
21 22
 from neutron_lib.plugins import directory
22 23
 from oslo_config import cfg
@@ -24,7 +25,6 @@ from oslo_db import exception as db_exc
24 25
 from oslo_log import log as logging
25 26
 from oslo_policy import policy
26 27
 from oslo_utils import excutils
27
-from oslo_utils import importutils
28 28
 import six
29 29
 
30 30
 from neutron._i18n import _, _LE, _LW
@@ -222,7 +222,6 @@ class OwnerCheck(policy.Check):
222 222
         f = getattr(directory.get_plugin(), 'get_%s' % resource_type)
223 223
         # f *must* exist, if not found it is better to let neutron
224 224
         # explode. Check will be performed with admin context
225
-        context = importutils.import_module('neutron.context')
226 225
         try:
227 226
             data = f(context.get_admin_context(),
228 227
                      resource_id,
@@ -409,23 +408,3 @@ def enforce(context, action, target, plugin=None, pluralized=None):
409 408
             log_rule_list(rule)
410 409
             LOG.debug("Failed policy check for '%s'", action)
411 410
     return result
412
-
413
-
414
-def check_is_admin(context):
415
-    """Verify context has admin rights according to policy settings."""
416
-    init()
417
-    # the target is user-self
418
-    credentials = context.to_policy_values()
419
-    if ADMIN_CTX_POLICY not in _ENFORCER.rules:
420
-        return False
421
-    return _ENFORCER.enforce(ADMIN_CTX_POLICY, credentials, credentials)
422
-
423
-
424
-def check_is_advsvc(context):
425
-    """Verify context has advsvc rights according to policy settings."""
426
-    init()
427
-    # the target is user-self
428
-    credentials = context.to_policy_values()
429
-    if ADVSVC_CTX_POLICY not in _ENFORCER.rules:
430
-        return False
431
-    return _ENFORCER.enforce(ADVSVC_CTX_POLICY, credentials, credentials)

+ 1
- 1
neutron/service.py View File

@@ -17,6 +17,7 @@ import inspect
17 17
 import os
18 18
 import random
19 19
 
20
+from neutron_lib import context
20 21
 from neutron_lib.plugins import directory
21 22
 from oslo_concurrency import processutils
22 23
 from oslo_config import cfg
@@ -35,7 +36,6 @@ from neutron.common import config
35 36
 from neutron.common import profiler
36 37
 from neutron.common import rpc as n_rpc
37 38
 from neutron.conf import service
38
-from neutron import context
39 39
 from neutron.db import api as session
40 40
 from neutron import worker as neutron_worker
41 41
 from neutron import wsgi

+ 1
- 1
neutron/services/externaldns/driver.py View File

@@ -46,7 +46,7 @@ class ExternalDNSService(object):
46 46
         """Create a record set in the specified zone.
47 47
 
48 48
         :param context: neutron api request context
49
-        :type context: neutron.context.Context
49
+        :type context: neutron_lib.context.Context
50 50
         :param dns_domain: the dns_domain where the record set will be created
51 51
         :type dns_domain: String
52 52
         :param dns_name: the name associated with the record set

+ 1
- 1
neutron/services/metering/agents/metering_agent.py View File

@@ -15,6 +15,7 @@
15 15
 import sys
16 16
 
17 17
 from neutron_lib import constants
18
+from neutron_lib import context
18 19
 from oslo_config import cfg
19 20
 from oslo_log import log as logging
20 21
 import oslo_messaging
@@ -33,7 +34,6 @@ from neutron.common import rpc as n_rpc
33 34
 from neutron.common import topics
34 35
 from neutron.common import utils
35 36
 from neutron.conf.services import metering_agent
36
-from neutron import context
37 37
 from neutron import manager
38 38
 from neutron import service as neutron_service
39 39
 

+ 1
- 1
neutron/services/qos/qos_plugin.py View File

@@ -52,7 +52,7 @@ class QoSPlugin(qos.QoSPluginBase):
52 52
         """Create a QoS policy.
53 53
 
54 54
         :param context: neutron api request context
55
-        :type context: neutron.context.Context
55
+        :type context: neutron_lib.context.Context
56 56
         :param policy: policy data to be applied
57 57
         :type policy: dict
58 58
 

+ 1
- 1
neutron/services/trunk/drivers/openvswitch/agent/ovsdb_handler.py View File

@@ -16,6 +16,7 @@
16 16
 import functools
17 17
 
18 18
 import eventlet
19
+from neutron_lib import context as n_context
19 20
 from oslo_concurrency import lockutils
20 21
 from oslo_context import context as o_context
21 22
 from oslo_log import log as logging
@@ -28,7 +29,6 @@ from neutron.api.rpc.handlers import resources_rpc
28 29
 from neutron.callbacks import events
29 30
 from neutron.callbacks import registry
30 31
 from neutron.common import utils as common_utils
31
-from neutron import context as n_context
32 32
 from neutron.plugins.ml2.drivers.openvswitch.agent.common \
33 33
     import constants as ovs_agent_constants
34 34
 from neutron.services.trunk import constants

+ 1
- 1
neutron/services/trunk/plugin.py View File

@@ -14,6 +14,7 @@
14 14
 
15 15
 import copy
16 16
 
17
+from neutron_lib import context
17 18
 from oslo_log import log as logging
18 19
 from oslo_utils import uuidutils
19 20
 
@@ -21,7 +22,6 @@ from neutron.api.v2 import attributes
21 22
 from neutron.callbacks import events
22 23
 from neutron.callbacks import registry
23 24
 from neutron.callbacks import resources
24
-from neutron import context
25 25
 from neutron.db import api as db_api
26 26
 from neutron.db import common_db_mixin
27 27
 from neutron.db import db_base_plugin_common

+ 1
- 1
neutron/tests/common/helpers.py View File

@@ -19,6 +19,7 @@ import os
19 19
 import random
20 20
 
21 21
 from neutron_lib import constants
22
+from neutron_lib import context
22 23
 from oslo_utils import timeutils
23 24
 import six
24 25
 import testtools
@@ -26,7 +27,6 @@ import testtools
26 27
 import neutron
27 28
 from neutron.agent.common import ovs_lib
28 29
 from neutron.common import topics
29
-from neutron import context
30 30
 from neutron.db import agents_db
31 31
 from neutron.db import common_db_mixin
32 32
 

+ 4
- 2
neutron/tests/functional/api/test_policies.py View File

@@ -15,9 +15,10 @@
15 15
 
16 16
 import os.path
17 17
 
18
+from neutron_lib import context
19
+
18 20
 from neutron.api import extensions
19 21
 from neutron.api.v2 import attributes
20
-from neutron import context
21 22
 from neutron import policy
22 23
 from neutron.tests import base
23 24
 from neutron.tests import tools
@@ -41,7 +42,6 @@ class APIPolicyTestCase(base.BaseTestCase):
41 42
         self.useFixture(tools.AttributeMapMemento())
42 43
         self.extension_path = os.path.abspath(os.path.join(
43 44
             TEST_PATH, "../../../extensions"))
44
-        policy.reset()
45 45
         self.addCleanup(policy.reset)
46 46
 
47 47
     def _network_definition(self):
@@ -79,9 +79,11 @@ class APIPolicyTestCase(base.BaseTestCase):
79 79
         populating extensions and extending the resource map results in
80 80
         networks with router:external are visible to regular tenants.
81 81
         """
82
+        policy.reset()
82 83
         extension_manager = extensions.ExtensionManager(self.extension_path)
83 84
         extension_manager.extend_resources(self.api_version,
84 85
                                            attributes.RESOURCE_ATTRIBUTE_MAP)
86
+        policy.init()
85 87
         admin_context = context.get_admin_context()
86 88
         tenant_context = context.Context('test_user', 'test_tenant_id', False)
87 89
         self.assertTrue(self._check_external_router_policy(admin_context))

+ 1
- 1
neutron/tests/functional/db/test_ipam.py View File

@@ -14,12 +14,12 @@
14 14
 #    under the License.
15 15
 
16 16
 from neutron_lib import constants
17
+from neutron_lib import context
17 18
 from neutron_lib import exceptions as n_exc
18 19
 from oslo_config import cfg
19 20
 from oslo_utils import uuidutils
20 21
 import testtools
21 22
 
22
-from neutron import context
23 23
 from neutron.db import db_base_plugin_v2 as base_plugin
24 24
 from neutron.db import models_v2
25 25
 from neutron.tests.unit import testlib_api

+ 7
- 1
neutron/tests/functional/pecan_wsgi/test_controllers.py View File

@@ -14,6 +14,7 @@ import uuid
14 14
 
15 15
 import mock
16 16
 from neutron_lib import constants as n_const
17
+from neutron_lib import context
17 18
 from neutron_lib.plugins import directory
18 19
 from oslo_config import cfg
19 20
 from oslo_db import exception as db_exc
@@ -23,7 +24,6 @@ import pecan
23 24
 from pecan import request
24 25
 
25 26
 from neutron.api import extensions
26
-from neutron import context
27 27
 from neutron import manager
28 28
 from neutron.pecan_wsgi.controllers import root as controllers
29 29
 from neutron.pecan_wsgi.controllers import utils as controller_utils
@@ -297,6 +297,8 @@ class TestResourceController(TestRootController):
297 297
 
298 298
     def setUp(self):
299 299
         super(TestResourceController, self).setUp()
300
+        policy.init()
301
+        self.addCleanup(policy.reset)
300 302
         self._gen_port()
301 303
 
302 304
     def _gen_port(self):
@@ -456,6 +458,8 @@ class TestPaginationAndSorting(test_functional.PecanFunctionalTest):
456 458
 
457 459
     def setUp(self):
458 460
         super(TestPaginationAndSorting, self).setUp()
461
+        policy.init()
462
+        self.addCleanup(policy.reset)
459 463
         self.plugin = directory.get_plugin()
460 464
         self.ctx = context.get_admin_context()
461 465
         self._create_networks(self.RESOURCE_COUNT)
@@ -702,6 +706,8 @@ class TestRouterController(TestResourceController):
702 706
             ['neutron.services.l3_router.l3_router_plugin.L3RouterPlugin',
703 707
              'neutron.services.flavors.flavors_plugin.FlavorsPlugin'])
704 708
         super(TestRouterController, self).setUp()
709
+        policy.init()
710
+        self.addCleanup(policy.reset)
705 711
         plugin = directory.get_plugin()
706 712
         ctx = context.get_admin_context()
707 713
         l3_plugin = directory.get_plugin(n_const.L3)

+ 1
- 1
neutron/tests/functional/pecan_wsgi/test_functional.py View File

@@ -17,6 +17,7 @@ import os
17 17
 
18 18
 import mock
19 19
 from neutron_lib import constants
20
+from neutron_lib import context
20 21
 from neutron_lib import exceptions as n_exc
21 22
 from oslo_config import cfg
22 23
 from oslo_middleware import base
@@ -27,7 +28,6 @@ import webob.dec
27 28
 import webtest
28 29
 
29 30
 from neutron.api import extensions as exts
30
-from neutron import context
31 31
 from neutron import manager
32 32
 from neutron import tests
33 33
 from neutron.tests.unit import testlib_api

+ 1
- 1
neutron/tests/functional/pecan_wsgi/test_hooks.py View File

@@ -14,6 +14,7 @@
14 14
 #    under the License.
15 15
 
16 16
 import mock
17
+from neutron_lib import context
17 18
 from neutron_lib.db import constants as db_const
18 19
 from neutron_lib.plugins import directory
19 20
 from oslo_policy import policy as oslo_policy
@@ -21,7 +22,6 @@ from oslo_serialization import jsonutils
21 22
 
22 23
 from neutron.api.v2 import attributes
23 24
 from neutron.callbacks import events
24
-from neutron import context
25 25
 from neutron.db.quota import driver as quota_driver
26 26
 from neutron import manager
27 27
 from neutron.pecan_wsgi.controllers import resource

+ 1
- 1
neutron/tests/functional/plugins/ml2/test_plugin.py View File

@@ -14,8 +14,8 @@
14 14
 #    under the License.
15 15
 
16 16
 from neutron_lib import constants
17
+from neutron_lib import context
17 18
 
18
-from neutron import context
19 19
 from neutron.db import agents_db
20 20
 from neutron.extensions import portbindings
21 21
 from neutron.tests.common import helpers

+ 1
- 1
neutron/tests/functional/scheduler/test_dhcp_agent_scheduler.py View File

@@ -17,10 +17,10 @@ import collections
17 17
 from operator import attrgetter
18 18
 
19 19
 from neutron_lib import constants
20
+from neutron_lib import context
20 21
 import six
21 22
 import testscenarios
22 23
 
23
-from neutron import context
24 24
 from neutron.db import agents_db
25 25
 from neutron.db import agentschedulers_db
26 26
 from neutron.db import common_db_mixin

+ 1
- 1
neutron/tests/functional/scheduler/test_l3_agent_scheduler.py View File

@@ -17,10 +17,10 @@ import collections
17 17
 import random
18 18
 
19 19
 from neutron_lib import constants
20
+from neutron_lib import context
20 21
 from oslo_utils import uuidutils
21 22
 import testscenarios
22 23
 
23
-from neutron import context
24 24
 from neutron.db.models import external_net as ext_net_models
25 25
 from neutron.scheduler import l3_agent_scheduler
26 26
 from neutron.services.l3_router import l3_router_plugin

+ 1
- 1
neutron/tests/functional/services/l3_router/test_l3_dvr_router_plugin.py View File

@@ -14,13 +14,13 @@
14 14
 
15 15
 import mock
16 16
 from neutron_lib import constants
17
+from neutron_lib import context
17 18
 
18 19
 from neutron.api.rpc.handlers import l3_rpc
19 20
 from neutron.callbacks import events
20 21
 from neutron.callbacks import registry
21 22
 from neutron.callbacks import resources
22 23
 from neutron.common import topics
23
-from neutron import context
24 24
 from neutron.extensions import external_net
25 25
 from neutron.extensions import l3
26 26
 from neutron.extensions import portbindings

+ 1
- 1
neutron/tests/retargetable/client_fixtures.py View File

@@ -18,11 +18,11 @@ Neutron API via different methods.
18 18
 import abc
19 19
 
20 20
 import fixtures
21
+from neutron_lib import context
21 22
 from neutron_lib import exceptions as n_exc
22 23
 from neutron_lib.plugins import directory
23 24
 import six
24 25
 
25
-from neutron import context
26 26
 from neutron import manager
27 27
 from neutron.tests import base
28 28
 from neutron.tests.unit import testlib_api

+ 1
- 1
neutron/tests/unit/_test_extension_portbindings.py View File

@@ -13,12 +13,12 @@
13 13
 #    License for the specific language governing permissions and limitations
14 14
 #    under the License.
15 15
 
16
+from neutron_lib import context
16 17
 from neutron_lib.plugins import directory
17 18
 from oslo_config import cfg
18 19
 from six.moves import http_client as httplib
19 20
 from webob import exc
20 21
 
21
-from neutron import context
22 22
 from neutron.extensions import portbindings
23 23
 from neutron.tests.unit.db import test_db_base_plugin_v2
24 24
 

+ 1
- 1
neutron/tests/unit/agent/l2/extensions/test_qos.py View File

@@ -14,6 +14,7 @@
14 14
 #    under the License.
15 15
 
16 16
 import mock
17
+from neutron_lib import context
17 18
 from neutron_lib import exceptions
18 19
 from oslo_utils import uuidutils
19 20
 
@@ -23,7 +24,6 @@ from neutron.api.rpc.callbacks.consumer import registry
23 24
 from neutron.api.rpc.callbacks import events
24 25
 from neutron.api.rpc.callbacks import resources
25 26
 from neutron.api.rpc.handlers import resources_rpc
26
-from neutron import context
27 27
 from neutron.objects.qos import policy
28 28
 from neutron.objects.qos import rule
29 29
 from neutron.plugins.ml2.drivers.openvswitch.agent import (

+ 1
- 1
neutron/tests/unit/agent/test_securitygroups_rpc.py View File

@@ -18,6 +18,7 @@ import contextlib
18 18
 
19 19
 import mock
20 20
 from neutron_lib import constants as const
21
+from neutron_lib import context
21 22
 from neutron_lib.plugins import directory
22 23
 from oslo_config import cfg
23 24
 import oslo_messaging
@@ -30,7 +31,6 @@ from neutron.agent.linux import iptables_manager
30 31
 from neutron.agent import securitygroups_rpc as sg_rpc
31 32
 from neutron.api.rpc.handlers import securitygroups_rpc
32 33
 from neutron.common import rpc as n_rpc
33
-from neutron import context
34 34
 from neutron.db import securitygroups_rpc_base as sg_db_rpc
35 35
 from neutron.extensions import allowedaddresspairs as addr_pair
36 36
 from neutron.extensions import securitygroup as ext_sg

+ 1
- 1
neutron/tests/unit/api/rpc/handlers/test_l3_rpc.py View File

@@ -14,11 +14,11 @@
14 14
 # limitations under the License.
15 15
 
16 16
 from neutron_lib import constants
17
+from neutron_lib import context
17 18
 from neutron_lib.plugins import directory
18 19
 from oslo_config import cfg
19 20
 
20 21
 from neutron.api.rpc.handlers import l3_rpc
21
-from neutron import context
22 22
 from neutron.tests.unit.db import test_db_base_plugin_v2
23 23
 from neutron.tests.unit import testlib_api
24 24
 

+ 1
- 1
neutron/tests/unit/api/rpc/handlers/test_resources_rpc.py View File

@@ -14,6 +14,7 @@
14 14
 # limitations under the License.
15 15
 
16 16
 import mock
17
+from neutron_lib import context
17 18
 from oslo_utils import uuidutils
18 19
 from oslo_versionedobjects import fields as obj_fields
19 20
 from oslo_versionedobjects import fixture
@@ -23,7 +24,6 @@ from neutron.api.rpc.callbacks import resources
23 24
 from neutron.api.rpc.callbacks import version_manager
24 25
 from neutron.api.rpc.handlers import resources_rpc
25 26
 from neutron.common import topics
26
-from neutron import context
27 27
 from neutron.objects import base as objects_base
28 28
 from neutron.objects import common_types
29 29
 from neutron.tests import base

+ 1
- 1
neutron/tests/unit/api/v2/test_attributes.py View File

@@ -15,12 +15,12 @@
15 15
 
16 16
 from neutron_lib.api import converters
17 17
 from neutron_lib import constants
18
+from neutron_lib import context
18 19
 from neutron_lib import exceptions as n_exc
19 20
 from oslo_utils import uuidutils
20 21
 import webob.exc
21 22
 
22 23
 from neutron.api.v2 import attributes
23
-from neutron import context
24 24
 from neutron.tests import base
25 25
 
26 26
 

+ 1
- 1
neutron/tests/unit/api/v2/test_base.py View File

@@ -18,6 +18,7 @@ import os
18 18
 import mock
19 19
 from neutron_lib.api import converters
20 20
 from neutron_lib import constants
21
+from neutron_lib import context
21 22
 from neutron_lib import exceptions as n_exc
22 23
 from neutron_lib.plugins import directory
23 24
 from oslo_config import cfg
@@ -36,7 +37,6 @@ from neutron.api.v2 import attributes
36 37
 from neutron.api.v2 import base as v2_base
37 38
 from neutron.api.v2 import router
38 39
 from neutron.callbacks import registry
39
-from neutron import context
40 40
 from neutron import policy
41 41
 from neutron import quota
42 42
 from neutron.quota import resource_registry

+ 1
- 1
neutron/tests/unit/api/v2/test_resource.py View File

@@ -14,6 +14,7 @@
14 14
 #    under the License.
15 15
 
16 16
 import mock
17
+from neutron_lib import context
17 18
 from neutron_lib import exceptions as n_exc
18 19
 import oslo_i18n
19 20
 from webob import exc
@@ -22,7 +23,6 @@ import webtest
22 23
 from neutron._i18n import _
23 24
 from neutron.api.v2 import resource as wsgi_resource
24 25
 from neutron.common import utils
25
-from neutron import context
26 26
 from neutron.tests import base
27 27
 from neutron import wsgi
28 28
 

+ 11
- 16
neutron/tests/unit/common/test_rpc.py View File

@@ -234,46 +234,41 @@ class TestRequestContextSerializer(base.DietTestCase):
234 234
 
235 235
         context.to_dict.assert_called_once_with()
236 236
 
237
-    @mock.patch('neutron.policy.check_is_advsvc', return_val=False)
238
-    @mock.patch('neutron.policy.check_is_admin', return_val=False)
239
-    def test_deserialize_context(self, m, n):
237
+    def test_deserialize_context(self):
240 238
         context_dict = {'foo': 'bar',
241 239
                         'user_id': 1,
242
-                        'tenant_id': 1}
240
+                        'tenant_id': 1,
241
+                        'is_admin': True}
243 242
 
244 243
         c = self.ser.deserialize_context(context_dict)
245 244
 
246 245
         self.assertEqual(1, c.user_id)
247 246
         self.assertEqual(1, c.project_id)
248 247
 
249
-    @mock.patch('neutron.policy.check_is_advsvc', return_val=False)
250
-    @mock.patch('neutron.policy.check_is_admin', return_val=False)
251
-    def test_deserialize_context_no_user_id(self, m, n):
248
+    def test_deserialize_context_no_user_id(self):
252 249
         context_dict = {'foo': 'bar',
253 250
                         'user': 1,
254
-                        'tenant_id': 1}
251
+                        'tenant_id': 1,
252
+                        'is_admin': True}
255 253
 
256 254
         c = self.ser.deserialize_context(context_dict)
257 255
 
258 256
         self.assertEqual(1, c.user_id)
259 257
         self.assertEqual(1, c.project_id)
260 258
 
261
-    @mock.patch('neutron.policy.check_is_advsvc', return_val=False)
262
-    @mock.patch('neutron.policy.check_is_admin', return_val=False)
263
-    def test_deserialize_context_no_tenant_id(self, m, n):
259
+    def test_deserialize_context_no_tenant_id(self):
264 260
         context_dict = {'foo': 'bar',
265 261
                         'user_id': 1,
266
-                        'project_id': 1}
262
+                        'project_id': 1,
263
+                        'is_admin': True}
267 264
 
268 265
         c = self.ser.deserialize_context(context_dict)
269 266
 
270 267
         self.assertEqual(1, c.user_id)
271 268
         self.assertEqual(1, c.project_id)
272 269
 
273
-    @mock.patch('neutron.policy.check_is_advsvc', return_val=False)
274
-    @mock.patch('neutron.policy.check_is_admin', return_val=False)
275
-    def test_deserialize_context_no_ids(self, m, n):
276
-        context_dict = {'foo': 'bar'}
270
+    def test_deserialize_context_no_ids(self):
271
+        context_dict = {'foo': 'bar', 'is_admin': True}
277 272
 
278 273
         c = self.ser.deserialize_context(context_dict)
279 274
 

+ 1
- 1
neutron/tests/unit/core_extensions/test_qos.py View File

@@ -14,9 +14,9 @@
14 14
 #    under the License.
15 15
 
16 16
 import mock
17
+from neutron_lib import context
17 18
 
18 19
 from neutron.common import exceptions as n_exc
19
-from neutron import context
20 20
 from neutron.core_extensions import base as base_core
21 21
 from neutron.core_extensions import qos as qos_core
22 22
 from neutron.plugins.common import constants as plugin_constants

+ 1
- 1
neutron/tests/unit/db/metering/test_metering_db.py View File

@@ -15,13 +15,13 @@
15 15
 import contextlib
16 16
 
17 17
 from neutron_lib import constants as n_consts
18
+from neutron_lib import context
18 19
 from neutron_lib.db import constants as db_const
19 20
 from oslo_utils import uuidutils
20 21
 import webob.exc
21 22
 
22 23
 from neutron.api import extensions
23 24
 from neutron.common import config
24
-from neutron import context
25 25
 import neutron.extensions
26 26
 from neutron.extensions import metering
27 27
 from neutron.plugins.common import constants

+ 1
- 1
neutron/tests/unit/db/quota/test_api.py View File

@@ -15,8 +15,8 @@
15 15
 import datetime
16 16
 
17 17
 import mock
18
+from neutron_lib import context
18 19
 
19
-from neutron import context
20 20
 from neutron.db.quota import api as quota_api
21 21
 from neutron.tests.unit import testlib_api
22 22
 

+ 1
- 1
neutron/tests/unit/db/quota/test_driver.py View File

@@ -13,10 +13,10 @@
13 13
 # See the License for the specific language governing permissions and
14 14
 # limitations under the License.
15 15
 
16
+from neutron_lib import context
16 17
 from neutron_lib import exceptions as lib_exc
17 18
 
18 19
 from neutron.common import exceptions
19
-from neutron import context
20 20
 from neutron.db import db_base_plugin_v2 as base_plugin
21 21
 from neutron.db.quota import driver
22 22
 from neutron.tests.unit import testlib_api

+ 1
- 1
neutron/tests/unit/db/test_agents_db.py View File

@@ -19,13 +19,13 @@ import datetime
19 19
 import mock
20 20
 
21 21
 from neutron_lib import constants
22
+from neutron_lib import context
22 23
 from neutron_lib import exceptions as n_exc
23 24
 from oslo_config import cfg
24 25
 from oslo_db import exception as exc
25 26
 from oslo_utils import timeutils
26 27
 import testscenarios
27 28
 
28
-from neutron import context
29 29
 from neutron.db import agents_db
30 30
 from neutron.db import db_base_plugin_v2 as base_plugin
31 31
 from neutron.db.models import agent as agent_model

+ 2
- 2
neutron/tests/unit/db/test_agentschedulers_db.py View File

@@ -17,6 +17,7 @@ import datetime
17 17
 
18 18
 import mock
19 19
 from neutron_lib import constants
20
+from neutron_lib import context
20 21
 from neutron_lib.plugins import directory
21 22
 from oslo_config import cfg
22 23
 from oslo_db import exception as db_exc
@@ -30,7 +31,6 @@ from neutron.api.rpc.handlers import dhcp_rpc
30 31
 from neutron.api.rpc.handlers import l3_rpc
31 32
 from neutron.api.v2 import attributes
32 33
 from neutron.common import constants as n_const
33
-from neutron import context
34 34
 from neutron.db import agents_db
35 35
 from neutron.db import agentschedulers_db
36 36
 from neutron.db.models import agent as agent_model
@@ -706,7 +706,7 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
706 706
             self._take_down_agent_and_run_reschedule(L3_HOSTA)  # Exception
707 707
 
708 708
     def test_router_rescheduler_catches_exceptions_on_fetching_bindings(self):
709
-        with mock.patch('neutron.context.get_admin_context') as get_ctx:
709
+        with mock.patch('neutron_lib.context.get_admin_context') as get_ctx:
710 710
             mock_ctx = mock.Mock()
711 711
             get_ctx.return_value = mock_ctx
712 712
             mock_ctx.session.query.side_effect = db_exc.DBError()

+ 1
- 1
neutron/tests/unit/db/test_common_db_mixin.py View File

@@ -14,8 +14,8 @@
14 14
 #    under the License.
15 15
 
16 16
 import mock
17
+from neutron_lib import context
17 18
 
18
-from neutron import context
19 19
 from neutron.db import _utils as db_utils
20 20
 from neutron.tests.unit import testlib_api
21 21
 

+ 1
- 1
neutron/tests/unit/db/test_db_base_plugin_v2.py View File

@@ -22,6 +22,7 @@ import eventlet
22 22
 import mock
23 23
 import netaddr
24 24
 from neutron_lib import constants
25
+from neutron_lib import context
25 26
 from neutron_lib import exceptions as lib_exc
26 27
 from neutron_lib.plugins import directory
27 28
 from neutron_lib.utils import helpers
@@ -47,7 +48,6 @@ from neutron.common import exceptions as n_exc
47 48
 from neutron.common import ipv6_utils
48 49
 from neutron.common import test_lib
49 50
 from neutron.common import utils
50
-from neutron import context
51 51
 from neutron.db import api as db_api
52 52
 from neutron.db import db_base_plugin_common
53 53
 from neutron.db import ipam_backend_mixin

+ 1
- 1
neutron/tests/unit/db/test_dvr_mac_db.py View File

@@ -15,12 +15,12 @@
15 15
 
16 16
 import mock
17 17
 from neutron_lib import constants
18
+from neutron_lib import context
18 19
 from neutron_lib.plugins import directory
19 20
 
20 21
 from neutron.callbacks import events
21 22
 from neutron.callbacks import registry
22 23
 from neutron.callbacks import resources
23
-from neutron import context
24 24
 from neutron.db import api as db_api
25 25
 from neutron.db import dvr_mac_db
26 26
 from neutron.db.models import dvr as dvr_models

+ 1
- 1
neutron/tests/unit/db/test_extraroute_db.py View File

@@ -14,8 +14,8 @@
14 14
 #    under the License.
15 15
 
16 16
 import mock
17
+from neutron_lib import context
17 18
 
18
-from neutron import context
19 19
 from neutron.db import common_db_mixin
20 20
 from neutron.db import extraroute_db
21 21
 from neutron.tests.unit import testlib_api

+ 1
- 1
neutron/tests/unit/db/test_l3_dvr_db.py View File

@@ -15,6 +15,7 @@
15 15
 
16 16
 import mock
17 17
 from neutron_lib import constants as const
18
+from neutron_lib import context
18 19
 from neutron_lib import exceptions
19 20
 from neutron_lib.plugins import directory
20 21
 from oslo_utils import uuidutils
@@ -23,7 +24,6 @@ from neutron.callbacks import events
23 24
 from neutron.callbacks import registry
24 25
 from neutron.callbacks import resources
25 26
 from neutron.common import constants as n_const
26
-from neutron import context
27 27
 from neutron.db import agents_db
28 28
 from neutron.db import common_db_mixin
29 29
 from neutron.db import l3_agentschedulers_db

+ 1
- 1
neutron/tests/unit/db/test_l3_hamode_db.py View File

@@ -14,6 +14,7 @@
14 14
 
15 15
 import mock
16 16
 from neutron_lib import constants
17
+from neutron_lib import context
17 18
 from neutron_lib import exceptions as n_exc
18 19
 from neutron_lib.plugins import directory
19 20
 from oslo_config import cfg
@@ -30,7 +31,6 @@ from neutron.callbacks import exceptions as c_exc
30 31
 from neutron.callbacks import registry
31 32
 from neutron.callbacks import resources
32 33
 from neutron.common import constants as n_const
33
-from neutron import context
34 34
 from neutron.db import agents_db
35 35
 from neutron.db import common_db_mixin
36 36
 from neutron.db import l3_agentschedulers_db

+ 1
- 1
neutron/tests/unit/db/test_provisioning_blocks.py View File

@@ -13,11 +13,11 @@
13 13
 #    under the License.
14 14
 
15 15
 import mock
16
+from neutron_lib import context as n_ctx
16 17
 import testtools
17 18
 
18 19
 from neutron.callbacks import registry
19 20
 from neutron.callbacks import resources
20
-from neutron import context as n_ctx
21 21
 from neutron.db import models_v2
22 22
 from neutron.db import provisioning_blocks as pb
23 23
 from neutron.tests.unit import testlib_api

+ 1
- 1
neutron/tests/unit/db/test_securitygroups_db.py View File

@@ -13,6 +13,7 @@
13 13
 
14 14
 import mock
15 15
 from neutron_lib import constants
16
+from neutron_lib import context
16 17
 import sqlalchemy
17 18
 import testtools
18 19
 
@@ -20,7 +21,6 @@ from neutron.callbacks import events
20 21
 from neutron.callbacks import exceptions
21 22
 from neutron.callbacks import registry
22 23
 from neutron.callbacks import resources
23
-from neutron import context
24 24
 from neutron.db import common_db_mixin
25 25
 from neutron.db import securitygroups_db
26 26
 from neutron.extensions import securitygroup

+ 1
- 1
neutron/tests/unit/db/test_sqlalchemytypes.py View File

@@ -13,6 +13,7 @@
13 13
 import abc
14 14
 import netaddr
15 15
 
16
+from neutron_lib import context
16 17
 from oslo_db import exception
17 18
 from oslo_db.tests.sqlalchemy import base as test_base
18 19
 from oslo_utils import timeutils
@@ -20,7 +21,6 @@ from oslo_utils import uuidutils
20 21
 import six
21 22
 import sqlalchemy as sa
22 23
 
23
-from neutron import context
24 24
 from neutron.db import sqlalchemytypes
25 25
 from neutron.tests import tools
26 26
 

+ 1
- 1
neutron/tests/unit/db/test_standard_attr.py View File

@@ -14,10 +14,10 @@
14 14
 
15 15
 import gc
16 16
 
17
+from neutron_lib import context
17 18
 from sqlalchemy.ext import declarative
18 19
 import testtools
19 20
 
20
-from neutron import context
21 21
 from neutron.db import standard_attr
22 22
 from neutron.tests import base
23 23
 from neutron.tests.unit import testlib_api

+ 1
- 1
neutron/tests/unit/extensions/test_address_scope.py View File

@@ -17,13 +17,13 @@ import contextlib
17 17
 import mock
18 18
 import netaddr
19 19
 from neutron_lib import constants
20
+from neutron_lib import context
20 21
 import webob.exc
21 22
 
22 23
 from neutron.api.v2 import attributes as attr
23 24
 from neutron.callbacks import events
24 25
 from neutron.callbacks import registry
25 26
 from neutron.callbacks import resources
26
-from neutron import context
27 27
 from neutron.db import address_scope_db
28 28
 from neutron.db import db_base_plugin_v2
29 29
 from neutron.extensions import address_scope as ext_address_scope

+ 1
- 1
neutron/tests/unit/extensions/test_agent.py View File

@@ -18,12 +18,12 @@ from datetime import datetime
18 18
 import time
19 19
 
20 20
 from neutron_lib import constants
21
+from neutron_lib import context
21 22
 from oslo_config import cfg
22 23
 from oslo_utils import uuidutils
23 24
 from webob import exc
24 25
 
25 26
 from neutron.api.v2 import attributes
26
-from neutron import context
27 27
 from neutron.db import agents_db
28 28
 from neutron.db import db_base_plugin_v2
29 29
 from neutron.extensions import agent

+ 2
- 1
neutron/tests/unit/extensions/test_availability_zone.py View File

@@ -11,7 +11,8 @@
11 11
 #    License for the specific language governing permissions and limitations
12 12
 #    under the License.
13 13
 
14
-from neutron import context
14
+from neutron_lib import context
15
+
15 16
 from neutron.db import agents_db
16 17
 from neutron.db import db_base_plugin_v2
17 18
 from neutron.extensions import agent

+ 1
- 1
neutron/tests/unit/extensions/test_dns.py View File

@@ -16,11 +16,11 @@ import math
16 16
 
17 17
 import netaddr
18 18
 from neutron_lib import constants
19
+from neutron_lib import context
19 20
 from neutron_lib.plugins import directory
20 21
 from oslo_config import cfg
21 22
 
22 23
 from neutron.common import utils
23
-from neutron import context
24 24
 from neutron.db import db_base_plugin_v2
25 25
 from neutron.extensions import dns
26 26
 from neutron.plugins.ml2 import config

+ 1
- 1
neutron/tests/unit/extensions/test_external_net.py View File

@@ -15,12 +15,12 @@
15 15
 
16 16
 import mock
17 17
 from neutron_lib import constants
18
+from neutron_lib import context
18 19
 from neutron_lib.plugins import directory
19 20
 from oslo_utils import uuidutils
20 21
 import testtools
21 22
 from webob import exc
22 23
 
23
-from neutron import context
24 24
 from neutron.db import models_v2
25 25
 from neutron.extensions import external_net as external_net
26 26
 from neutron.tests.unit.api.v2 import test_base

+ 1
- 1
neutron/tests/unit/extensions/test_extraroute.py View File

@@ -14,12 +14,12 @@
14 14
 #    under the License.
15 15
 
16 16
 from neutron_lib import constants
17
+from neutron_lib import context
17 18
 from neutron_lib.utils import helpers
18 19
 from oslo_config import cfg
19 20
 from oslo_utils import uuidutils
20 21
 from webob import exc
21 22
 
22
-from neutron import context
23 23
 from neutron.db import extraroute_db
24 24
 from neutron.extensions import extraroute
25 25
 from neutron.extensions import l3

+ 1
- 1
neutron/tests/unit/extensions/test_flavors.py View File

@@ -17,12 +17,12 @@ import copy
17 17
 import fixtures
18 18
 import mock
19 19
 
20
+from neutron_lib import context
20 21
 from neutron_lib.db import constants as db_const
21 22
 from oslo_config import cfg
22 23
 from oslo_utils import uuidutils
23 24
 from webob import exc
24 25
 
25
-from neutron import context
26 26
 from neutron.db import api as dbapi
27 27
 from neutron.db.models import l3 as l3_models
28 28
 from neutron.db import servicetype_db

+ 1
- 1
neutron/tests/unit/extensions/test_l3.py View File

@@ -20,6 +20,7 @@ import copy
20 20
 import mock
21 21
 import netaddr
22 22
 from neutron_lib import constants as lib_constants
23
+from neutron_lib import context
23 24
 from neutron_lib import exceptions as n_exc
24 25
 from neutron_lib.plugins import directory
25 26
 from oslo_config import cfg
@@ -36,7 +37,6 @@ from neutron.callbacks import events
36 37
 from neutron.callbacks import exceptions
37 38
 from neutron.callbacks import registry
38 39
 from neutron.callbacks import resources
39
-from neutron import context
40 40
 from neutron.db import common_db_mixin
41 41
 from neutron.db import db_base_plugin_v2
42 42
 from neutron.db import dns_db

+ 2
- 2
neutron/tests/unit/extensions/test_l3_ext_gw_mode.py View File

@@ -17,6 +17,7 @@
17 17
 import mock
18 18
 import netaddr
19 19
 from neutron_lib import constants
20
+from neutron_lib import context as nctx
20 21
 from neutron_lib.plugins import directory
21 22
 from oslo_config import cfg
22 23
 from oslo_db import exception as db_exc
@@ -26,7 +27,6 @@ import testscenarios
26 27
 from webob import exc
27 28
 
28 29
 from neutron.common import utils
29
-from neutron import context as nctx
30 30
 from neutron.db import api as db_api
31 31
 from neutron.db import l3_db
32 32
 from neutron.db import l3_gwmode_db
@@ -121,7 +121,7 @@ class TestL3GwModeMixin(testlib_api.SqlTestCase):
121 121
         self.setup_coreplugin(plugin)
122 122
         self.target_object = TestDbIntPlugin()
123 123
         # Patch the context
124
-        ctx_patcher = mock.patch('neutron.context', autospec=True)
124
+        ctx_patcher = mock.patch('neutron_lib.context', autospec=True)
125 125
         mock_context = ctx_patcher.start()
126 126
         self.context = mock_context.get_admin_context()
127 127
         # This ensure also calls to elevated work in unit tests

+ 1
- 1
neutron/tests/unit/extensions/test_portsecurity.py View File

@@ -14,10 +14,10 @@
14 14
 # limitations under the License.
15 15
 
16 16
 from neutron_lib.api import validators
17
+from neutron_lib import context
17 18
 from neutron_lib.plugins import directory
18 19
 from webob import exc
19 20
 
20
-from neutron import context
21 21
 from neutron.db import _utils as db_utils
22 22
 from neutron.db import db_base_plugin_v2
23 23
 from neutron.db import portsecurity_db

+ 1
- 1
neutron/tests/unit/extensions/test_providernet.py View File

@@ -15,6 +15,7 @@
15 15
 
16 16
 import mock
17 17
 from neutron_lib import constants
18
+from neutron_lib import context
18 19
 from neutron_lib.plugins import directory
19 20
 from oslo_config import cfg
20 21
 from oslo_utils import uuidutils
@@ -23,7 +24,6 @@ import webtest
23 24
 
24 25
 from neutron.api import extensions
25 26
 from neutron.api.v2 import router
26
-from neutron import context
27 27
 from neutron.extensions import providernet as pnet
28 28
 from neutron import quota
29 29
 from neutron.tests import tools

+ 1
- 1
neutron/tests/unit/extensions/test_quotasv2.py View File

@@ -16,6 +16,7 @@
16 16
 import sys
17 17
 
18 18
 import mock
19
+from neutron_lib import context
19 20
 from oslo_config import cfg
20 21
 import testtools
21 22
 from webob import exc
@@ -26,7 +27,6 @@ from neutron.api.v2 import router
26 27
 from neutron.common import config
27 28
 from neutron.common import constants
28 29
 from neutron.common import exceptions
29
-from neutron import context
30 30
 from neutron.db.quota import driver
31 31
 from neutron import quota
32 32
 from neutron.quota import resource_registry

+ 1
- 1
neutron/tests/unit/extensions/test_securitygroup.py View File

@@ -18,6 +18,7 @@ import contextlib
18 18
 import mock
19 19
 from neutron_lib.api import validators
20 20
 from neutron_lib import constants as const
21
+from neutron_lib import context
21 22
 from neutron_lib.plugins import directory
22 23
 from oslo_config import cfg
23 24
 import oslo_db.exception as exc
@@ -27,7 +28,6 @@ import webob.exc
27 28
 
28 29
 from neutron.api.v2 import attributes as attr
29 30
 from neutron.common import exceptions as n_exc
30
-from neutron import context
31 31
 from neutron.db import db_base_plugin_v2
32 32
 from neutron.db import securitygroups_db
33 33
 from neutron.extensions import securitygroup as ext_sg

+ 1
- 1
neutron/tests/unit/extensions/test_segment.py View File

@@ -18,6 +18,7 @@ from keystoneauth1 import exceptions as ks_exc
18 18
 import mock
19 19
 import netaddr
20 20
 from neutron_lib import constants
21
+from neutron_lib import context
21 22
 from neutron_lib import exceptions as n_exc
22 23
 from neutron_lib.plugins import directory
23 24
 from novaclient import exceptions as nova_exc
@@ -32,7 +33,6 @@ from neutron.callbacks import registry
32 33
 from neutron.callbacks import resources
33 34
 from neutron.common import exceptions as neutron_exc
34 35
 from neutron.conf.plugins.ml2.drivers import driver_type
35
-from neutron import context
36 36
 from neutron.db import agents_db
37 37
 from neutron.db import agentschedulers_db
38 38
 from neutron.db import db_base_plugin_v2

+ 1
- 1
neutron/tests/unit/extensions/test_servicetype.py View File

@@ -14,6 +14,7 @@
14 14
 #    under the License.
15 15
 
16 16
 import mock
17
+from neutron_lib import context
17 18
 from neutron_lib import exceptions as n_exc
18 19
 from oslo_config import cfg
19 20
 from oslo_utils import uuidutils
@@ -21,7 +22,6 @@ import webob.exc as webexc
21 22
 import webtest
22 23
 
23 24
 from neutron.api import extensions
24
-from neutron import context
25 25
 from neutron.db.models import servicetype as st_model
26 26
 from neutron.db import servicetype_db as st_db
27 27
 from neutron.extensions import servicetype

+ 1
- 1
neutron/tests/unit/extensions/test_timestamp.py View File

@@ -16,10 +16,10 @@ import datetime
16 16
 import six
17 17
 
18 18
 import mock
19
+from neutron_lib import context
19 20
 from neutron_lib.plugins import directory
20 21
 from oslo_utils import timeutils
21 22
 
22
-from neutron import context
23 23
 from neutron.db import db_base_plugin_v2
24 24
 from neutron.db.models import tag as tag_model
25 25
 from neutron.db import models_v2

+ 1
- 1
neutron/tests/unit/ipam/drivers/neutrondb_ipam/test_db_api.py View File

@@ -13,9 +13,9 @@
13 13
 #    License for the specific language governing permissions and limitations
14 14
 #    under the License.
15 15
 
16
+from neutron_lib import context
16 17
 from oslo_utils import uuidutils
17 18
 
18
-from neutron import context
19 19
 from neutron.ipam.drivers.neutrondb_ipam import db_api
20 20
 from neutron.objects import ipam as ipam_obj
21 21
 from neutron.tests.unit import testlib_api

+ 1
- 1
neutron/tests/unit/ipam/drivers/neutrondb_ipam/test_driver.py View File

@@ -16,12 +16,12 @@
16 16
 import mock
17 17
 import netaddr
18 18
 from neutron_lib import constants
19
+from neutron_lib import context
19 20
 from neutron_lib import exceptions as n_exc
20 21
 from neutron_lib.plugins import directory
21 22
 from oslo_utils import uuidutils
22 23
 
23 24
 from neutron.common import constants as n_const
24
-from neutron import context
25 25
 from neutron.ipam.drivers.neutrondb_ipam import driver
26 26
 from neutron.ipam import exceptions as ipam_exc
27 27
 from neutron.ipam import requests as ipam_req

+ 1
- 1
neutron/tests/unit/ipam/test_requests.py View File

@@ -13,11 +13,11 @@
13 13
 import mock
14 14
 import netaddr
15 15
 from neutron_lib import constants
16
+from neutron_lib import context
16 17
 from oslo_config import cfg
17 18
 from oslo_utils import netutils
18 19
 from oslo_utils import uuidutils
19 20
 
20
-from neutron import context
21 21
 from neutron.ipam import driver
22 22
 from neutron.ipam import exceptions as ipam_exc
23 23
 from neutron.ipam import requests as ipam_req

+ 1
- 1
neutron/tests/unit/ipam/test_subnet_alloc.py View File

@@ -16,13 +16,13 @@
16 16
 import mock
17 17
 import netaddr
18 18
 from neutron_lib import constants
19
+from neutron_lib import context
19 20
 from neutron_lib.plugins import directory
20 21
 from oslo_config import cfg
21 22
 from oslo_db import exception as db_exc
22 23
 from oslo_utils import uuidutils
23 24
 
24 25
 from neutron.common import exceptions as n_exc
25
-from neutron import context
26 26
 from neutron.ipam import requests as ipam_req
27 27
 from neutron.ipam import subnet_alloc
28 28
 from neutron.tests.unit.db import test_db_base_plugin_v2

+ 1
- 1
neutron/tests/unit/objects/db/test_api.py View File

@@ -11,10 +11,10 @@
11 11
 #    under the License.
12 12
 
13 13
 import mock
14
+from neutron_lib import context
14 15
 from neutron_lib import exceptions as n_exc
15 16
 from neutron_lib.plugins import directory
16 17
 
17
-from neutron import context
18 18
 from neutron.db import models_v2
19 19
 from neutron.objects import base
20 20
 from neutron.objects.db import api

+ 2
- 1
neutron/tests/unit/objects/port/extensions/test_allowedaddresspairs.py View File

@@ -10,7 +10,8 @@
10 10
 #    License for the specific language governing permissions and limitations
11 11
 #    under the License.
12 12
 
13
-from neutron import context
13
+from neutron_lib import context
14
+
14 15
 from neutron.objects.port.extensions import allowedaddresspairs
15 16
 from neutron.tests.unit.objects import test_base as obj_test_base
16 17
 from neutron.tests.unit import testlib_api

+ 1
- 1
neutron/tests/unit/objects/test_base.py View File

@@ -18,6 +18,7 @@ import random
18 18
 
19 19
 import mock
20 20
 import netaddr
21
+from neutron_lib import context
21 22
 from neutron_lib import exceptions as n_exc
22 23
 from neutron_lib.utils import helpers
23 24
 from oslo_db import exception as obj_exc
@@ -30,7 +31,6 @@ import testtools
30 31
 
31 32
 from neutron.common import constants
32 33
 from neutron.common import utils
33
-from neutron import context
34 34
 from neutron.db import db_base_plugin_v2
35 35
 from neutron.db.models import external_net as ext_net_model
36 36
 from neutron.db.models import l3 as l3_model

+ 1
- 1
neutron/tests/unit/objects/test_rbac_db.py View File

@@ -12,6 +12,7 @@
12 12
 
13 13
 import mock
14 14
 
15
+from neutron_lib import context as n_context
15 16
 from neutron_lib.db import model_base
16 17
 from neutron_lib import exceptions as n_exc
17 18
 from oslo_versionedobjects import base as obj_base
@@ -19,7 +20,6 @@ from oslo_versionedobjects import fields as obj_fields
19 20
 import sqlalchemy as sa
20 21
 
21 22
 from neutron.callbacks import events
22
-from neutron import context as n_context
23 23
 from neutron.db import rbac_db_models
24 24
 from neutron.extensions import rbac as ext_rbac
25 25
 from neutron.objects import common_types

+ 1
- 1
neutron/tests/unit/objects/test_subnet.py View File

@@ -10,9 +10,9 @@
10 10
 #    License for the specific language governing permissions and limitations
11 11
 #    under the License.
12 12
 
13
+from neutron_lib import context
13 14
 from oslo_utils import uuidutils
14 15
 
15
-from neutron import context
16 16
 from neutron.db import rbac_db_models
17 17
 from neutron.objects import base as obj_base
18 18
 from neutron.objects.db import api as obj_db_api

+ 1
- 1
neutron/tests/unit/plugins/ml2/drivers/base_type_tunnel.py View File

@@ -14,12 +14,12 @@
14 14
 # limitations under the License.
15 15
 
16 16
 import mock
17
+from neutron_lib import context
17 18
 from neutron_lib import exceptions as exc
18 19
 from six import moves
19 20
 import testtools
20 21
 from testtools import matchers
21 22
 
22
-from neutron import context
23 23
 from neutron.plugins.common import constants as p_const
24 24
 from neutron.plugins.ml2 import config
25 25
 from neutron.plugins.ml2 import driver_api as api

+ 1
- 1
neutron/tests/unit/plugins/ml2/drivers/l2pop/test_db.py View File

@@ -13,11 +13,11 @@
13 13
 #    under the License.
14 14
 
15 15
 from neutron_lib import constants
16
+from neutron_lib import context
16 17
 from oslo_utils import uuidutils
17 18
 
18 19
 from neutron.common import constants as n_const
19 20
 from neutron.common import utils
20
-from neutron import context
21 21
 from neutron.db.models import l3 as l3_models
22 22
 from neutron.db.models import l3_attrs
23 23
 from neutron.db.models import l3ha as l3ha_model

+ 1
- 1
neutron/tests/unit/plugins/ml2/drivers/l2pop/test_mech_driver.py View File

@@ -15,6 +15,7 @@
15 15
 
16 16
 import mock
17 17
 from neutron_lib import constants
18
+from neutron_lib import context
18 19
 from neutron_lib import exceptions
19 20
 from neutron_lib.plugins import directory
20 21
 from oslo_serialization import jsonutils
@@ -23,7 +24,6 @@ import testtools
23 24
 from neutron.api.v2 import attributes
24 25
 from neutron.common import constants as n_const
25 26
 from neutron.common import topics
26
-from neutron import context
27 27
 from neutron.db import agents_db
28 28
 from neutron.db import common_db_mixin
29 29
 from neutron.db import l3_agentschedulers_db

+ 1
- 1
neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/extension_drivers/test_qos_driver.py View File

@@ -14,10 +14,10 @@
14 14
 # limitations under the License.
15 15
 
16 16
 import mock
17
+from neutron_lib import context
17 18
 from oslo_utils import uuidutils
18 19
 
19 20
 from neutron.common import constants
20
-from neutron import context
21 21
 from neutron.objects.qos import policy
22 22
 from neutron.objects.qos import rule
23 23
 from neutron.plugins.ml2.drivers.mech_sriov.agent.common import exceptions

+ 1
- 1
neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/extension_drivers/test_qos_driver.py View File

@@ -13,9 +13,9 @@
13 13
 import copy
14 14
 
15 15
 import mock
16
+from neutron_lib import context
16 17
 from oslo_utils import uuidutils
17 18
 
18
-from neutron import context
19 19
 from neutron.objects.qos import policy
20 20
 from neutron.objects.qos import rule
21 21
 from neutron.plugins.ml2.drivers.openvswitch.agent import (

+ 1
- 1
neutron/tests/unit/plugins/ml2/drivers/test_helpers.py View File

@@ -14,10 +14,10 @@
14 14
 #    under the License.
15 15
 
16 16
 import mock
17
+from neutron_lib import context
17 18
 from oslo_db import exception as exc
18 19
 from sqlalchemy.orm import query
19 20
 
20
-from neutron import context
21 21
 from neutron.plugins.ml2.drivers import type_vlan
22 22
 from neutron.tests.unit import testlib_api
23 23
 

+ 1
- 1
neutron/tests/unit/plugins/ml2/drivers/test_type_flat.py View File

@@ -13,10 +13,10 @@
13 13
 #    License for the specific language governing permissions and limitations
14 14
 #    under the License.
15 15
 
16
+from neutron_lib import context
16 17
 from neutron_lib import exceptions as exc
17 18
 
18 19
 from neutron.common import exceptions as n_exc
19
-from neutron import context
20 20
 from neutron.objects.plugins.ml2 import flatallocation as flat_obj
21 21
 from neutron.plugins.common import constants as p_const
22 22
 from neutron.plugins.ml2 import config

+ 1
- 1
neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py View File

@@ -14,10 +14,10 @@
14 14
 #    under the License.
15 15
 
16 16
 import mock
17
+from neutron_lib import context
17 18
 from neutron_lib import exceptions as exc
18 19
 from testtools import matchers
19 20
 
20
-from neutron import context
21 21
 from neutron.db.models.plugins.ml2 import vlanallocation as vlan_alloc_model
22 22
 from neutron.plugins.common import constants as p_const
23 23
 from neutron.plugins.common import utils as plugin_utils

+ 0
- 0
neutron/tests/unit/plugins/ml2/extensions/test_dns_integration.py View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save