summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinji YANAGIDA <s-yanagida@pb.jp.nec.com>2016-11-24 07:34:42 +0900
committerShinji YANAGIDA <s-yanagida@pb.jp.nec.com>2016-11-26 11:49:09 +0900
commit4edc55fff851795d8396bc6af9e1647151c4601a (patch)
tree4ee59eae17d48be43a2002d949970cecc926978a
parent7f8d01f9d96f6717d0e4379829d13f1689ddbc88 (diff)
Change import path.HEADmaster
neutron.db -> neutron_lib.db neutron.manager.NeutronManager -> neutron_lib.plugins.directory Change-Id: I1d6d9b60a2fc830e77134727ebb07e5105a9ceab
Notes
Notes (review): Code-Review+2: Shinji YANAGIDA <s-yanagida@pb.jp.nec.com> Workflow+1: Shinji YANAGIDA <s-yanagida@pb.jp.nec.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Sat, 26 Nov 2016 03:03:56 +0000 Reviewed-on: https://review.openstack.org/401788 Project: openstack/networking-nec Branch: refs/heads/master
-rw-r--r--networking_nec/db/migration/alembic_migrations/env.py2
-rw-r--r--networking_nec/nwa/l2/rpc/ml2_server_callback.py4
-rw-r--r--networking_nec/nwa/l2/rpc/nwa_l2_server_callback.py12
-rw-r--r--networking_nec/nwa/l2/rpc/tenant_binding_callback.py4
-rw-r--r--networking_nec/nwa/l3/rpc/nwa_l3_server_callback.py7
-rw-r--r--networking_nec/tests/unit/nwa/l2/rpc/test_ml2_server_callback.py18
-rw-r--r--networking_nec/tests/unit/nwa/l2/rpc/test_tenant_binding_callback.py8
7 files changed, 27 insertions, 28 deletions
diff --git a/networking_nec/db/migration/alembic_migrations/env.py b/networking_nec/db/migration/alembic_migrations/env.py
index 0c5fa70..3c5fdd9 100644
--- a/networking_nec/db/migration/alembic_migrations/env.py
+++ b/networking_nec/db/migration/alembic_migrations/env.py
@@ -18,7 +18,7 @@
18from logging import config as logging_config 18from logging import config as logging_config
19 19
20from alembic import context 20from alembic import context
21from neutron.db import model_base 21from neutron_lib.db import model_base
22from oslo_config import cfg 22from oslo_config import cfg
23from oslo_db.sqlalchemy import session 23from oslo_db.sqlalchemy import session
24import sqlalchemy as sa 24import sqlalchemy as sa
diff --git a/networking_nec/nwa/l2/rpc/ml2_server_callback.py b/networking_nec/nwa/l2/rpc/ml2_server_callback.py
index 5f33338..b9a9056 100644
--- a/networking_nec/nwa/l2/rpc/ml2_server_callback.py
+++ b/networking_nec/nwa/l2/rpc/ml2_server_callback.py
@@ -16,11 +16,11 @@ from oslo_config import cfg
16 16
17from neutron.extensions import portbindings 17from neutron.extensions import portbindings
18from neutron.extensions import portsecurity as psec 18from neutron.extensions import portsecurity as psec
19from neutron import manager
20from neutron.plugins.ml2 import driver_api as api 19from neutron.plugins.ml2 import driver_api as api
21from neutron.plugins.ml2 import rpc 20from neutron.plugins.ml2 import rpc
22from neutron.services.qos import qos_consts 21from neutron.services.qos import qos_consts
23from neutron_lib import constants 22from neutron_lib import constants
23from neutron_lib.plugins import directory
24from oslo_log import log as logging 24from oslo_log import log as logging
25 25
26from networking_nec._i18n import _LW, _LI 26from networking_nec._i18n import _LW, _LI
@@ -49,7 +49,7 @@ class NwaML2ServerRpcCallbacks(rpc.RpcCallbacks):
49 "%(agent_id)s with host %(host)s", 49 "%(agent_id)s with host %(host)s",
50 {'device': device, 'agent_id': agent_id, 'host': host}) 50 {'device': device, 'agent_id': agent_id, 'host': host})
51 51
52 plugin = manager.NeutronManager.get_plugin() 52 plugin = directory.get_plugin()
53 port_id = plugin._device_to_port_id(rpc_context, device) 53 port_id = plugin._device_to_port_id(rpc_context, device)
54 port_context = plugin.get_bound_port_context(rpc_context, 54 port_context = plugin.get_bound_port_context(rpc_context,
55 port_id, 55 port_id,
diff --git a/networking_nec/nwa/l2/rpc/nwa_l2_server_callback.py b/networking_nec/nwa/l2/rpc/nwa_l2_server_callback.py
index a15b29f..db6a676 100644
--- a/networking_nec/nwa/l2/rpc/nwa_l2_server_callback.py
+++ b/networking_nec/nwa/l2/rpc/nwa_l2_server_callback.py
@@ -16,8 +16,8 @@ from neutron.db import api as db_api
16from neutron.db.models import segment as segments_db 16from neutron.db.models import segment as segments_db
17from neutron.db import models_v2 17from neutron.db import models_v2
18from neutron.db import segments_db as db_ml2 18from neutron.db import segments_db as db_ml2
19from neutron import manager
20from neutron_lib import constants 19from neutron_lib import constants
20from neutron_lib.plugins import directory
21from oslo_log import helpers 21from oslo_log import helpers
22from oslo_log import log as logging 22from oslo_log import log as logging
23import oslo_messaging 23import oslo_messaging
@@ -33,7 +33,7 @@ class NwaL2ServerRpcCallback(object):
33 target = oslo_messaging.Target(version='1.0') 33 target = oslo_messaging.Target(version='1.0')
34 34
35 def get_nwa_network_by_port_id(self, rpc_context, **kwargs): 35 def get_nwa_network_by_port_id(self, rpc_context, **kwargs):
36 plugin = manager.NeutronManager.get_plugin() 36 plugin = directory.get_plugin()
37 port_id = kwargs.get('port_id') 37 port_id = kwargs.get('port_id')
38 port = plugin.get_port(rpc_context, port_id) 38 port = plugin.get_port(rpc_context, port_id)
39 39
@@ -42,7 +42,7 @@ class NwaL2ServerRpcCallback(object):
42 return network 42 return network
43 43
44 def get_nwa_network_by_subnet_id(self, rpc_context, **kwargs): 44 def get_nwa_network_by_subnet_id(self, rpc_context, **kwargs):
45 plugin = manager.NeutronManager.get_plugin() 45 plugin = directory.get_plugin()
46 subnet_id = kwargs.get('subnet_id') 46 subnet_id = kwargs.get('subnet_id')
47 subnet = plugin.get_subnet(rpc_context, subnet_id) 47 subnet = plugin.get_subnet(rpc_context, subnet_id)
48 48
@@ -51,14 +51,14 @@ class NwaL2ServerRpcCallback(object):
51 return network 51 return network
52 52
53 def get_nwa_network(self, rpc_context, **kwargs): 53 def get_nwa_network(self, rpc_context, **kwargs):
54 plugin = manager.NeutronManager.get_plugin() 54 plugin = directory.get_plugin()
55 net_id = kwargs.get('network_id') 55 net_id = kwargs.get('network_id')
56 network = plugin.get_network(rpc_context, net_id) 56 network = plugin.get_network(rpc_context, net_id)
57 57
58 return network 58 return network
59 59
60 def get_nwa_networks(self, rpc_context, **kwargs): 60 def get_nwa_networks(self, rpc_context, **kwargs):
61 plugin = manager.NeutronManager.get_plugin() 61 plugin = directory.get_plugin()
62 networks = plugin.get_networks(rpc_context) 62 networks = plugin.get_networks(rpc_context)
63 63
64 return networks 64 return networks
@@ -85,7 +85,7 @@ class NwaL2ServerRpcCallback(object):
85 pass 85 pass
86 86
87 # 2 change port state 87 # 2 change port state
88 plugin = manager.NeutronManager.get_plugin() 88 plugin = directory.get_plugin()
89 plugin.update_port_status( 89 plugin.update_port_status(
90 rpc_context, 90 rpc_context,
91 port_id, 91 port_id,
diff --git a/networking_nec/nwa/l2/rpc/tenant_binding_callback.py b/networking_nec/nwa/l2/rpc/tenant_binding_callback.py
index 8609ac8..9d8e7a4 100644
--- a/networking_nec/nwa/l2/rpc/tenant_binding_callback.py
+++ b/networking_nec/nwa/l2/rpc/tenant_binding_callback.py
@@ -13,7 +13,7 @@
13# under the License. 13# under the License.
14 14
15from neutron.db import api as db_api 15from neutron.db import api as db_api
16from neutron import manager 16from neutron_lib.plugins import directory
17from oslo_log import helpers 17from oslo_log import helpers
18from oslo_log import log as logging 18from oslo_log import log as logging
19import oslo_messaging 19import oslo_messaging
@@ -122,7 +122,7 @@ class TenantBindingServerRpcCallback(object):
122 with session.begin(subtransactions=True): 122 with session.begin(subtransactions=True):
123 q_tids = [q.tenant_id 123 q_tids = [q.tenant_id
124 for q in necnwa_api.get_nwa_tenant_queues(session)] 124 for q in necnwa_api.get_nwa_tenant_queues(session)]
125 plugin = manager.NeutronManager.get_plugin() 125 plugin = directory.get_plugin()
126 tenant_ids = [server['tenant_id'] for server in kwargs['servers']] 126 tenant_ids = [server['tenant_id'] for server in kwargs['servers']]
127 ret = [] 127 ret = []
128 for tenant_id in set(q_tids) - set(tenant_ids): 128 for tenant_id in set(q_tids) - set(tenant_ids):
diff --git a/networking_nec/nwa/l3/rpc/nwa_l3_server_callback.py b/networking_nec/nwa/l3/rpc/nwa_l3_server_callback.py
index 0f85500..9337c18 100644
--- a/networking_nec/nwa/l3/rpc/nwa_l3_server_callback.py
+++ b/networking_nec/nwa/l3/rpc/nwa_l3_server_callback.py
@@ -13,8 +13,8 @@
13# under the License. 13# under the License.
14 14
15from neutron.extensions import l3 15from neutron.extensions import l3
16from neutron import manager 16from neutron_lib import constants
17from neutron.plugins.common import constants as plugin_constants 17from neutron_lib.plugins import directory
18from oslo_log import log as logging 18from oslo_log import log as logging
19import oslo_messaging 19import oslo_messaging
20 20
@@ -28,8 +28,7 @@ class NwaL3ServerRpcCallback(object):
28 @property 28 @property
29 def l3plugin(self): 29 def l3plugin(self):
30 if not hasattr(self, '_l3plugin'): 30 if not hasattr(self, '_l3plugin'):
31 self._l3plugin = manager.NeutronManager.get_service_plugins()[ 31 self._l3plugin = directory.get_plugin(constants.L3)
32 plugin_constants.L3_ROUTER_NAT]
33 return self._l3plugin 32 return self._l3plugin
34 33
35 def update_floatingip_status(self, context, floatingip_id, status): 34 def update_floatingip_status(self, context, floatingip_id, status):
diff --git a/networking_nec/tests/unit/nwa/l2/rpc/test_ml2_server_callback.py b/networking_nec/tests/unit/nwa/l2/rpc/test_ml2_server_callback.py
index e374903..b14bd0f 100644
--- a/networking_nec/tests/unit/nwa/l2/rpc/test_ml2_server_callback.py
+++ b/networking_nec/tests/unit/nwa/l2/rpc/test_ml2_server_callback.py
@@ -64,7 +64,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
64 'NECNWAL2Plugin.get_bound_port_context') 64 'NECNWAL2Plugin.get_bound_port_context')
65 @mock.patch('networking_nec.nwa.l2.plugin.' 65 @mock.patch('networking_nec.nwa.l2.plugin.'
66 'NECNWAL2Plugin._device_to_port_id') 66 'NECNWAL2Plugin._device_to_port_id')
67 @mock.patch('neutron.manager.NeutronManager.get_plugin') 67 @mock.patch('neutron_lib.plugins.directory.get_plugin')
68 def test_get_device_details(self, f1, f2, f3): 68 def test_get_device_details(self, f1, f2, f3):
69 rpc_context = mock.MagicMock() 69 rpc_context = mock.MagicMock()
70 f1.return_value = self.l2_plugin 70 f1.return_value = self.l2_plugin
@@ -82,7 +82,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
82 'NECNWAL2Plugin.get_bound_port_context') 82 'NECNWAL2Plugin.get_bound_port_context')
83 @mock.patch('networking_nec.nwa.l2.plugin.' 83 @mock.patch('networking_nec.nwa.l2.plugin.'
84 'NECNWAL2Plugin._device_to_port_id') 84 'NECNWAL2Plugin._device_to_port_id')
85 @mock.patch('neutron.manager.NeutronManager.get_plugin') 85 @mock.patch('neutron_lib.plugins.directory.get_plugin')
86 def test_get_device_details_no_segment(self, f1, f2, f3, f4, f5, f6): 86 def test_get_device_details_no_segment(self, f1, f2, f3, f4, f5, f6):
87 rpc_context = mock.MagicMock() 87 rpc_context = mock.MagicMock()
88 f1.return_value = self.l2_plugin 88 f1.return_value = self.l2_plugin
@@ -102,7 +102,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
102 'NECNWAL2Plugin.get_bound_port_context') 102 'NECNWAL2Plugin.get_bound_port_context')
103 @mock.patch('networking_nec.nwa.l2.plugin.' 103 @mock.patch('networking_nec.nwa.l2.plugin.'
104 'NECNWAL2Plugin._device_to_port_id') 104 'NECNWAL2Plugin._device_to_port_id')
105 @mock.patch('neutron.manager.NeutronManager.get_plugin') 105 @mock.patch('neutron_lib.plugins.directory.get_plugin')
106 def test_get_device_details_multi_segment(self, f1, f2, f3, f4, f5, f6): 106 def test_get_device_details_multi_segment(self, f1, f2, f3, f4, f5, f6):
107 rpc_context = mock.MagicMock() 107 rpc_context = mock.MagicMock()
108 f1.return_value = self.l2_plugin 108 f1.return_value = self.l2_plugin
@@ -122,7 +122,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
122 'NECNWAL2Plugin.get_bound_port_context') 122 'NECNWAL2Plugin.get_bound_port_context')
123 @mock.patch('networking_nec.nwa.l2.plugin.' 123 @mock.patch('networking_nec.nwa.l2.plugin.'
124 'NECNWAL2Plugin._device_to_port_id') 124 'NECNWAL2Plugin._device_to_port_id')
125 @mock.patch('neutron.manager.NeutronManager.get_plugin') 125 @mock.patch('neutron_lib.plugins.directory.get_plugin')
126 def test_get_device_details_segment_size_miss_match(self, f1, f2, f3, f4, 126 def test_get_device_details_segment_size_miss_match(self, f1, f2, f3, f4,
127 f5, f6): 127 f5, f6):
128 rpc_context = mock.MagicMock() 128 rpc_context = mock.MagicMock()
@@ -141,7 +141,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
141 'NECNWAL2Plugin.get_bound_port_context') 141 'NECNWAL2Plugin.get_bound_port_context')
142 @mock.patch('networking_nec.nwa.l2.plugin.' 142 @mock.patch('networking_nec.nwa.l2.plugin.'
143 'NECNWAL2Plugin._device_to_port_id') 143 'NECNWAL2Plugin._device_to_port_id')
144 @mock.patch('neutron.manager.NeutronManager.get_plugin') 144 @mock.patch('neutron_lib.plugins.directory.get_plugin')
145 def test_get_device_details_segment_zero(self, f1, f2, f3, f4, f5, f6): 145 def test_get_device_details_segment_zero(self, f1, f2, f3, f4, f5, f6):
146 rpc_context = mock.MagicMock() 146 rpc_context = mock.MagicMock()
147 f1.return_value = self.l2_plugin 147 f1.return_value = self.l2_plugin
@@ -162,7 +162,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
162 'NECNWAL2Plugin.get_bound_port_context') 162 'NECNWAL2Plugin.get_bound_port_context')
163 @mock.patch('networking_nec.nwa.l2.plugin.' 163 @mock.patch('networking_nec.nwa.l2.plugin.'
164 'NECNWAL2Plugin._device_to_port_id') 164 'NECNWAL2Plugin._device_to_port_id')
165 @mock.patch('neutron.manager.NeutronManager.get_plugin') 165 @mock.patch('neutron_lib.plugins.directory.get_plugin')
166 def test_get_device_details_segment_not_binding(self, f1, f2, f3, f4, f5, 166 def test_get_device_details_segment_not_binding(self, f1, f2, f3, f4, f5,
167 f6, f7): 167 f6, f7):
168 rpc_context = mock.MagicMock() 168 rpc_context = mock.MagicMock()
@@ -192,7 +192,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
192 'NECNWAL2Plugin.get_bound_port_context') 192 'NECNWAL2Plugin.get_bound_port_context')
193 @mock.patch('networking_nec.nwa.l2.plugin.' 193 @mock.patch('networking_nec.nwa.l2.plugin.'
194 'NECNWAL2Plugin._device_to_port_id') 194 'NECNWAL2Plugin._device_to_port_id')
195 @mock.patch('neutron.manager.NeutronManager.get_plugin') 195 @mock.patch('neutron_lib.plugins.directory.get_plugin')
196 def test_get_device_details_bound_segment(self, f1, f2, f3, f4, f5, 196 def test_get_device_details_bound_segment(self, f1, f2, f3, f4, f5,
197 f6, f7): 197 f6, f7):
198 198
@@ -218,7 +218,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
218 'NECNWAL2Plugin.get_bound_port_context') 218 'NECNWAL2Plugin.get_bound_port_context')
219 @mock.patch('networking_nec.nwa.l2.plugin.' 219 @mock.patch('networking_nec.nwa.l2.plugin.'
220 'NECNWAL2Plugin._device_to_port_id') 220 'NECNWAL2Plugin._device_to_port_id')
221 @mock.patch('neutron.manager.NeutronManager.get_plugin') 221 @mock.patch('neutron_lib.plugins.directory.get_plugin')
222 def test_get_device_details_port_state_change(self, f1, f2, f3, f4, f5, 222 def test_get_device_details_port_state_change(self, f1, f2, f3, f4, f5,
223 f6, f7): 223 f6, f7):
224 rpc_context = mock.MagicMock() 224 rpc_context = mock.MagicMock()
@@ -237,7 +237,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
237 kwargs={'test': "sample"}) 237 kwargs={'test': "sample"})
238 self.assertTrue(device) 238 self.assertTrue(device)
239 239
240 @mock.patch('neutron.manager.NeutronManager.get_plugin') 240 @mock.patch('neutron_lib.plugins.directory.get_plugin')
241 def test_update_device_up(self, dummy1): 241 def test_update_device_up(self, dummy1):
242 rpc_context = mock.MagicMock() 242 rpc_context = mock.MagicMock()
243 dummy1.return_value = None 243 dummy1.return_value = None
diff --git a/networking_nec/tests/unit/nwa/l2/rpc/test_tenant_binding_callback.py b/networking_nec/tests/unit/nwa/l2/rpc/test_tenant_binding_callback.py
index eb710e9..d5820d7 100644
--- a/networking_nec/tests/unit/nwa/l2/rpc/test_tenant_binding_callback.py
+++ b/networking_nec/tests/unit/nwa/l2/rpc/test_tenant_binding_callback.py
@@ -26,7 +26,7 @@ class TestTenantBindingServerRpcCallback(base.BaseTestCase):
26 self.callback = tenant_cb.TenantBindingServerRpcCallback() 26 self.callback = tenant_cb.TenantBindingServerRpcCallback()
27 27
28 @mock.patch('neutron.db.api.get_session') 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 @mock.patch('networking_nec.nwa.l2.db_api.get_nwa_tenant_queues') 30 @mock.patch('networking_nec.nwa.l2.db_api.get_nwa_tenant_queues')
31 def test_update_tenant_rpc_servers_both_empty(self, gntq, gs, gp): 31 def test_update_tenant_rpc_servers_both_empty(self, gntq, gs, gp):
32 gntq.return_value = [] 32 gntq.return_value = []
@@ -36,7 +36,7 @@ class TestTenantBindingServerRpcCallback(base.BaseTestCase):
36 self.assertEqual(rd, {'servers': []}) 36 self.assertEqual(rd, {'servers': []})
37 37
38 @mock.patch('neutron.db.api.get_session') 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 @mock.patch('networking_nec.nwa.l2.db_api.get_nwa_tenant_queues') 40 @mock.patch('networking_nec.nwa.l2.db_api.get_nwa_tenant_queues')
41 def test_update_tenant_rpc_servers_both_equal(self, gntq, plugin, gs): 41 def test_update_tenant_rpc_servers_both_equal(self, gntq, plugin, gs):
42 q1 = mock.MagicMock() 42 q1 = mock.MagicMock()
@@ -50,7 +50,7 @@ class TestTenantBindingServerRpcCallback(base.BaseTestCase):
50 self.assertEqual(plugin.nwa_rpc.delete_server.call_count, 0) 50 self.assertEqual(plugin.nwa_rpc.delete_server.call_count, 0)
51 51
52 @mock.patch('neutron.db.api.get_session') 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 @mock.patch('networking_nec.nwa.l2.db_api.get_nwa_tenant_queues') 54 @mock.patch('networking_nec.nwa.l2.db_api.get_nwa_tenant_queues')
55 def test_update_tenant_rpc_servers_create(self, gntq, gp, gs): 55 def test_update_tenant_rpc_servers_create(self, gntq, gp, gs):
56 q1 = mock.MagicMock() 56 q1 = mock.MagicMock()
@@ -67,7 +67,7 @@ class TestTenantBindingServerRpcCallback(base.BaseTestCase):
67 self.assertEqual(plugin.nwa_rpc.delete_server.call_count, 0) 67 self.assertEqual(plugin.nwa_rpc.delete_server.call_count, 0)
68 68
69 @mock.patch('neutron.db.api.get_session') 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 @mock.patch('networking_nec.nwa.l2.db_api.get_nwa_tenant_queues') 71 @mock.patch('networking_nec.nwa.l2.db_api.get_nwa_tenant_queues')
72 def test_update_tenant_rpc_servers_delete(self, gntq, gp, gs): 72 def test_update_tenant_rpc_servers_delete(self, gntq, gp, gs):
73 gntq.return_value = [] 73 gntq.return_value = []