Browse Source

Change import path.

neutron.db -> neutron_lib.db
neutron.manager.NeutronManager -> neutron_lib.plugins.directory

Change-Id: I1d6d9b60a2fc830e77134727ebb07e5105a9ceab
Shinji YANAGIDA 2 years ago
parent
commit
4edc55fff8

+ 1
- 1
networking_nec/db/migration/alembic_migrations/env.py View File

@@ -18,7 +18,7 @@
18 18
 from logging import config as logging_config
19 19
 
20 20
 from alembic import context
21
-from neutron.db import model_base
21
+from neutron_lib.db import model_base
22 22
 from oslo_config import cfg
23 23
 from oslo_db.sqlalchemy import session
24 24
 import sqlalchemy as sa

+ 2
- 2
networking_nec/nwa/l2/rpc/ml2_server_callback.py View File

@@ -16,11 +16,11 @@ from oslo_config import cfg
16 16
 
17 17
 from neutron.extensions import portbindings
18 18
 from neutron.extensions import portsecurity as psec
19
-from neutron import manager
20 19
 from neutron.plugins.ml2 import driver_api as api
21 20
 from neutron.plugins.ml2 import rpc
22 21
 from neutron.services.qos import qos_consts
23 22
 from neutron_lib import constants
23
+from neutron_lib.plugins import directory
24 24
 from oslo_log import log as logging
25 25
 
26 26
 from networking_nec._i18n import _LW, _LI
@@ -49,7 +49,7 @@ class NwaML2ServerRpcCallbacks(rpc.RpcCallbacks):
49 49
                   "%(agent_id)s with host %(host)s",
50 50
                   {'device': device, 'agent_id': agent_id, 'host': host})
51 51
 
52
-        plugin = manager.NeutronManager.get_plugin()
52
+        plugin = directory.get_plugin()
53 53
         port_id = plugin._device_to_port_id(rpc_context, device)
54 54
         port_context = plugin.get_bound_port_context(rpc_context,
55 55
                                                      port_id,

+ 6
- 6
networking_nec/nwa/l2/rpc/nwa_l2_server_callback.py View File

@@ -16,8 +16,8 @@ from neutron.db import api as db_api
16 16
 from neutron.db.models import segment as segments_db
17 17
 from neutron.db import models_v2
18 18
 from neutron.db import segments_db as db_ml2
19
-from neutron import manager
20 19
 from neutron_lib import constants
20
+from neutron_lib.plugins import directory
21 21
 from oslo_log import helpers
22 22
 from oslo_log import log as logging
23 23
 import oslo_messaging
@@ -33,7 +33,7 @@ class NwaL2ServerRpcCallback(object):
33 33
     target = oslo_messaging.Target(version='1.0')
34 34
 
35 35
     def get_nwa_network_by_port_id(self, rpc_context, **kwargs):
36
-        plugin = manager.NeutronManager.get_plugin()
36
+        plugin = directory.get_plugin()
37 37
         port_id = kwargs.get('port_id')
38 38
         port = plugin.get_port(rpc_context, port_id)
39 39
 
@@ -42,7 +42,7 @@ class NwaL2ServerRpcCallback(object):
42 42
         return network
43 43
 
44 44
     def get_nwa_network_by_subnet_id(self, rpc_context, **kwargs):
45
-        plugin = manager.NeutronManager.get_plugin()
45
+        plugin = directory.get_plugin()
46 46
         subnet_id = kwargs.get('subnet_id')
47 47
         subnet = plugin.get_subnet(rpc_context, subnet_id)
48 48
 
@@ -51,14 +51,14 @@ class NwaL2ServerRpcCallback(object):
51 51
         return network
52 52
 
53 53
     def get_nwa_network(self, rpc_context, **kwargs):
54
-        plugin = manager.NeutronManager.get_plugin()
54
+        plugin = directory.get_plugin()
55 55
         net_id = kwargs.get('network_id')
56 56
         network = plugin.get_network(rpc_context, net_id)
57 57
 
58 58
         return network
59 59
 
60 60
     def get_nwa_networks(self, rpc_context, **kwargs):
61
-        plugin = manager.NeutronManager.get_plugin()
61
+        plugin = directory.get_plugin()
62 62
         networks = plugin.get_networks(rpc_context)
63 63
 
64 64
         return networks
@@ -85,7 +85,7 @@ class NwaL2ServerRpcCallback(object):
85 85
                 pass
86 86
 
87 87
         # 2 change port state
88
-        plugin = manager.NeutronManager.get_plugin()
88
+        plugin = directory.get_plugin()
89 89
         plugin.update_port_status(
90 90
             rpc_context,
91 91
             port_id,

+ 2
- 2
networking_nec/nwa/l2/rpc/tenant_binding_callback.py View File

@@ -13,7 +13,7 @@
13 13
 #    under the License.
14 14
 
15 15
 from neutron.db import api as db_api
16
-from neutron import manager
16
+from neutron_lib.plugins import directory
17 17
 from oslo_log import helpers
18 18
 from oslo_log import log as logging
19 19
 import oslo_messaging
@@ -122,7 +122,7 @@ class TenantBindingServerRpcCallback(object):
122 122
         with session.begin(subtransactions=True):
123 123
             q_tids = [q.tenant_id
124 124
                       for q in necnwa_api.get_nwa_tenant_queues(session)]
125
-        plugin = manager.NeutronManager.get_plugin()
125
+        plugin = directory.get_plugin()
126 126
         tenant_ids = [server['tenant_id'] for server in kwargs['servers']]
127 127
         ret = []
128 128
         for tenant_id in set(q_tids) - set(tenant_ids):

+ 3
- 4
networking_nec/nwa/l3/rpc/nwa_l3_server_callback.py View File

@@ -13,8 +13,8 @@
13 13
 #    under the License.
14 14
 
15 15
 from neutron.extensions import l3
16
-from neutron import manager
17
-from neutron.plugins.common import constants as plugin_constants
16
+from neutron_lib import constants
17
+from neutron_lib.plugins import directory
18 18
 from oslo_log import log as logging
19 19
 import oslo_messaging
20 20
 
@@ -28,8 +28,7 @@ class NwaL3ServerRpcCallback(object):
28 28
     @property
29 29
     def l3plugin(self):
30 30
         if not hasattr(self, '_l3plugin'):
31
-            self._l3plugin = manager.NeutronManager.get_service_plugins()[
32
-                plugin_constants.L3_ROUTER_NAT]
31
+            self._l3plugin = directory.get_plugin(constants.L3)
33 32
         return self._l3plugin
34 33
 
35 34
     def update_floatingip_status(self, context, floatingip_id, status):

+ 9
- 9
networking_nec/tests/unit/nwa/l2/rpc/test_ml2_server_callback.py View File

@@ -64,7 +64,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
64 64
                 'NECNWAL2Plugin.get_bound_port_context')
65 65
     @mock.patch('networking_nec.nwa.l2.plugin.'
66 66
                 'NECNWAL2Plugin._device_to_port_id')
67
-    @mock.patch('neutron.manager.NeutronManager.get_plugin')
67
+    @mock.patch('neutron_lib.plugins.directory.get_plugin')
68 68
     def test_get_device_details(self, f1, f2, f3):
69 69
         rpc_context = mock.MagicMock()
70 70
         f1.return_value = self.l2_plugin
@@ -82,7 +82,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
82 82
                 'NECNWAL2Plugin.get_bound_port_context')
83 83
     @mock.patch('networking_nec.nwa.l2.plugin.'
84 84
                 'NECNWAL2Plugin._device_to_port_id')
85
-    @mock.patch('neutron.manager.NeutronManager.get_plugin')
85
+    @mock.patch('neutron_lib.plugins.directory.get_plugin')
86 86
     def test_get_device_details_no_segment(self, f1, f2, f3, f4, f5, f6):
87 87
         rpc_context = mock.MagicMock()
88 88
         f1.return_value = self.l2_plugin
@@ -102,7 +102,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
102 102
                 'NECNWAL2Plugin.get_bound_port_context')
103 103
     @mock.patch('networking_nec.nwa.l2.plugin.'
104 104
                 'NECNWAL2Plugin._device_to_port_id')
105
-    @mock.patch('neutron.manager.NeutronManager.get_plugin')
105
+    @mock.patch('neutron_lib.plugins.directory.get_plugin')
106 106
     def test_get_device_details_multi_segment(self, f1, f2, f3, f4, f5, f6):
107 107
         rpc_context = mock.MagicMock()
108 108
         f1.return_value = self.l2_plugin
@@ -122,7 +122,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
122 122
                 'NECNWAL2Plugin.get_bound_port_context')
123 123
     @mock.patch('networking_nec.nwa.l2.plugin.'
124 124
                 'NECNWAL2Plugin._device_to_port_id')
125
-    @mock.patch('neutron.manager.NeutronManager.get_plugin')
125
+    @mock.patch('neutron_lib.plugins.directory.get_plugin')
126 126
     def test_get_device_details_segment_size_miss_match(self, f1, f2, f3, f4,
127 127
                                                         f5, f6):
128 128
         rpc_context = mock.MagicMock()
@@ -141,7 +141,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
141 141
                 'NECNWAL2Plugin.get_bound_port_context')
142 142
     @mock.patch('networking_nec.nwa.l2.plugin.'
143 143
                 'NECNWAL2Plugin._device_to_port_id')
144
-    @mock.patch('neutron.manager.NeutronManager.get_plugin')
144
+    @mock.patch('neutron_lib.plugins.directory.get_plugin')
145 145
     def test_get_device_details_segment_zero(self, f1, f2, f3, f4, f5, f6):
146 146
         rpc_context = mock.MagicMock()
147 147
         f1.return_value = self.l2_plugin
@@ -162,7 +162,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
162 162
                 'NECNWAL2Plugin.get_bound_port_context')
163 163
     @mock.patch('networking_nec.nwa.l2.plugin.'
164 164
                 'NECNWAL2Plugin._device_to_port_id')
165
-    @mock.patch('neutron.manager.NeutronManager.get_plugin')
165
+    @mock.patch('neutron_lib.plugins.directory.get_plugin')
166 166
     def test_get_device_details_segment_not_binding(self, f1, f2, f3, f4, f5,
167 167
                                                     f6, f7):
168 168
         rpc_context = mock.MagicMock()
@@ -192,7 +192,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
192 192
                 'NECNWAL2Plugin.get_bound_port_context')
193 193
     @mock.patch('networking_nec.nwa.l2.plugin.'
194 194
                 'NECNWAL2Plugin._device_to_port_id')
195
-    @mock.patch('neutron.manager.NeutronManager.get_plugin')
195
+    @mock.patch('neutron_lib.plugins.directory.get_plugin')
196 196
     def test_get_device_details_bound_segment(self, f1, f2, f3, f4, f5,
197 197
                                               f6, f7):
198 198
 
@@ -218,7 +218,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
218 218
                 'NECNWAL2Plugin.get_bound_port_context')
219 219
     @mock.patch('networking_nec.nwa.l2.plugin.'
220 220
                 'NECNWAL2Plugin._device_to_port_id')
221
-    @mock.patch('neutron.manager.NeutronManager.get_plugin')
221
+    @mock.patch('neutron_lib.plugins.directory.get_plugin')
222 222
     def test_get_device_details_port_state_change(self, f1, f2, f3, f4, f5,
223 223
                                                   f6, f7):
224 224
         rpc_context = mock.MagicMock()
@@ -237,7 +237,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
237 237
                                              kwargs={'test': "sample"})
238 238
         self.assertTrue(device)
239 239
 
240
-    @mock.patch('neutron.manager.NeutronManager.get_plugin')
240
+    @mock.patch('neutron_lib.plugins.directory.get_plugin')
241 241
     def test_update_device_up(self, dummy1):
242 242
         rpc_context = mock.MagicMock()
243 243
         dummy1.return_value = None

+ 4
- 4
networking_nec/tests/unit/nwa/l2/rpc/test_tenant_binding_callback.py View File

@@ -26,7 +26,7 @@ class TestTenantBindingServerRpcCallback(base.BaseTestCase):
26 26
         self.callback = tenant_cb.TenantBindingServerRpcCallback()
27 27
 
28 28
     @mock.patch('neutron.db.api.get_session')
29
-    @mock.patch('neutron.manager.NeutronManager.get_plugin')
29
+    @mock.patch('neutron_lib.plugins.directory.get_plugin')
30 30
     @mock.patch('networking_nec.nwa.l2.db_api.get_nwa_tenant_queues')
31 31
     def test_update_tenant_rpc_servers_both_empty(self, gntq, gs, gp):
32 32
         gntq.return_value = []
@@ -36,7 +36,7 @@ class TestTenantBindingServerRpcCallback(base.BaseTestCase):
36 36
         self.assertEqual(rd, {'servers': []})
37 37
 
38 38
     @mock.patch('neutron.db.api.get_session')
39
-    @mock.patch('neutron.manager.NeutronManager.get_plugin')
39
+    @mock.patch('neutron_lib.plugins.directory.get_plugin')
40 40
     @mock.patch('networking_nec.nwa.l2.db_api.get_nwa_tenant_queues')
41 41
     def test_update_tenant_rpc_servers_both_equal(self, gntq, plugin, gs):
42 42
         q1 = mock.MagicMock()
@@ -50,7 +50,7 @@ class TestTenantBindingServerRpcCallback(base.BaseTestCase):
50 50
         self.assertEqual(plugin.nwa_rpc.delete_server.call_count, 0)
51 51
 
52 52
     @mock.patch('neutron.db.api.get_session')
53
-    @mock.patch('neutron.manager.NeutronManager.get_plugin')
53
+    @mock.patch('neutron_lib.plugins.directory.get_plugin')
54 54
     @mock.patch('networking_nec.nwa.l2.db_api.get_nwa_tenant_queues')
55 55
     def test_update_tenant_rpc_servers_create(self, gntq, gp, gs):
56 56
         q1 = mock.MagicMock()
@@ -67,7 +67,7 @@ class TestTenantBindingServerRpcCallback(base.BaseTestCase):
67 67
         self.assertEqual(plugin.nwa_rpc.delete_server.call_count, 0)
68 68
 
69 69
     @mock.patch('neutron.db.api.get_session')
70
-    @mock.patch('neutron.manager.NeutronManager.get_plugin')
70
+    @mock.patch('neutron_lib.plugins.directory.get_plugin')
71 71
     @mock.patch('networking_nec.nwa.l2.db_api.get_nwa_tenant_queues')
72 72
     def test_update_tenant_rpc_servers_delete(self, gntq, gp, gs):
73 73
         gntq.return_value = []

Loading…
Cancel
Save