Browse Source

change import path.

I changed the following path.

neutron.plugins.ml2.db -> neutron.db.segments_db

Change-Id: I2ddd63a31d8ba20a7fd4b7efe3aed3d0d8501eb6
Shinji YANAGIDA 2 years ago
parent
commit
7f8d01f9d9

+ 5
- 5
networking_nec/nwa/l2/drivers/mech_necnwa.py View File

@@ -14,10 +14,10 @@
14 14
 
15 15
 from neutron.common import constants as neutron_const
16 16
 from neutron.common import utils
17
+from neutron.db import segments_db as db_ml2
17 18
 from neutron.extensions import portbindings
18 19
 from neutron.extensions import providernet as prov_net
19 20
 from neutron.plugins.common import constants as plugin_const
20
-from neutron.plugins.ml2 import db
21 21
 from neutron.plugins.ml2 import driver_api as api
22 22
 from neutron.plugins.ml2.drivers.openvswitch.mech_driver \
23 23
     import mech_openvswitch as ovs
@@ -129,7 +129,7 @@ class NECNWAMechanismDriver(ovs.OpenvswitchMechanismDriver):
129 129
             return
130 130
         network_id = context.network.current['id']
131 131
         session = context.network._plugin_context.session
132
-        dummy_segment = db.get_dynamic_segment(
132
+        dummy_segment = db_ml2.get_dynamic_segment(
133 133
             session, network_id, physical_network=physical_network)
134 134
         LOG.debug("1st: dummy segment is %s", dummy_segment)
135 135
         if not dummy_segment:
@@ -138,7 +138,7 @@ class NECNWAMechanismDriver(ovs.OpenvswitchMechanismDriver):
138 138
                 api.NETWORK_TYPE: plugin_const.TYPE_VLAN,
139 139
                 api.SEGMENTATION_ID: 0
140 140
             }
141
-            db.add_network_segment(
141
+            db_ml2.add_network_segment(
142 142
                 session, network_id, dummy_segment, is_dynamic=True)
143 143
         LOG.debug("2nd: dummy segment is %s", dummy_segment)
144 144
         context.set_binding(dummy_segment[api.ID],
@@ -221,13 +221,13 @@ class NECNWAMechanismDriver(ovs.OpenvswitchMechanismDriver):
221 221
 
222 222
     def _l2_delete_segment(self, context, nwa_info):
223 223
         session = context.network._plugin_context.session
224
-        del_segment = db.get_dynamic_segment(
224
+        del_segment = db_ml2.get_dynamic_segment(
225 225
             session,
226 226
             context.network.current['id'],
227 227
             physical_network=nwa_info['physical_network'])
228 228
         if del_segment:
229 229
             LOG.debug('delete_network_segment %s', del_segment)
230
-            db.delete_network_segment(session, del_segment['id'])
230
+            db_ml2.delete_network_segment(session, del_segment['id'])
231 231
 
232 232
     def _l3_create_tenant_fw(self, context):
233 233
         device_owner = context._port['device_owner']

+ 1
- 1
networking_nec/nwa/l2/plugin.py View File

@@ -18,9 +18,9 @@ from neutron.api.rpc.handlers import securitygroups_rpc
18 18
 from neutron.common import rpc as n_rpc
19 19
 from neutron.common import topics
20 20
 from neutron.db import agents_db
21
+from neutron.db import segments_db as db_ml2
21 22
 from neutron.extensions import multiprovidernet as mpnet
22 23
 from neutron.extensions import providernet as provider
23
-from neutron.plugins.ml2 import db as db_ml2
24 24
 from neutron.plugins.ml2 import driver_api as api
25 25
 from neutron.plugins.ml2 import plugin as ml2_plugin
26 26
 from oslo_log import log as logging

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

@@ -15,8 +15,8 @@
15 15
 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
+from neutron.db import segments_db as db_ml2
18 19
 from neutron import manager
19
-from neutron.plugins.ml2 import db as db_ml2
20 20
 from neutron_lib import constants
21 21
 from oslo_log import helpers
22 22
 from oslo_log import log as logging

+ 1
- 1
networking_nec/nwa/l2/utils.py View File

@@ -13,7 +13,7 @@
13 13
 #    under the License.
14 14
 
15 15
 from neutron.db.models import external_net as external_net_db
16
-from neutron.plugins.ml2 import db as db_ml2
16
+from neutron.db import segments_db as db_ml2
17 17
 from neutron.plugins.ml2 import driver_api as api
18 18
 from neutron_lib import constants
19 19
 from oslo_config import cfg

+ 5
- 5
networking_nec/tests/unit/nwa/l2/drivers/test_mech_necnwa.py View File

@@ -550,15 +550,15 @@ class TestNECNWAMechanismDriver(TestMechNwa):
550 550
         physnet = self.driver._find_nwa_physical_network(self.context)
551 551
         self.assertEqual(physnet, 'Common/App/Pod3')
552 552
 
553
-    @patch('neutron.plugins.ml2.db.get_dynamic_segment')
553
+    @patch('neutron.db.segments_db.get_dynamic_segment')
554 554
     def test__bind_segment_to_vif_type_dummy_segment_none(self, gds):
555 555
         gds.return_value = None
556 556
         physnet = 'Common/App/Pod3'
557 557
         rd = self.driver._bind_segment_to_vif_type(self.context, physnet)
558 558
         self.assertIsNone(rd)
559 559
 
560
-    @patch('neutron.plugins.ml2.db.get_dynamic_segment')
561
-    @patch('neutron.plugins.ml2.db.add_network_segment')
560
+    @patch('neutron.db.segments_db.get_dynamic_segment')
561
+    @patch('neutron.db.segments_db.add_network_segment')
562 562
     def test__bind_segment_to_vif_type_dummy_segment_exists(self, ans, gds):
563 563
         gds.return_value = self.network_segments[1]
564 564
         physnet = 'Common/KVM/Pod1-2'
@@ -642,8 +642,8 @@ class TestNECNWAMechanismDriver(TestMechNwa):
642 642
         gntb.side_effect = Exception
643 643
         self.driver._bind_port_nwa(self.context)
644 644
 
645
-    @patch('neutron.plugins.ml2.db.get_dynamic_segment')
646
-    @patch('neutron.plugins.ml2.db.delete_network_segment')
645
+    @patch('neutron.db.segments_db.get_dynamic_segment')
646
+    @patch('neutron.db.segments_db.delete_network_segment')
647 647
     def test__l2_delete_segment(self, dns, gds):
648 648
         gds.return_value = None
649 649
         self.driver._l2_delete_segment(self.context, MagicMock())

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

@@ -76,7 +76,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
76 76
         self.assertTrue(device)
77 77
 
78 78
     @mock.patch('neutron.plugins.ml2.plugin.Ml2Plugin.update_port_status')
79
-    @mock.patch('neutron.plugins.ml2.db.get_network_segments')
79
+    @mock.patch('neutron.db.segments_db.get_network_segments')
80 80
     @mock.patch('neutron.db.api.get_session')
81 81
     @mock.patch('networking_nec.nwa.l2.plugin.'
82 82
                 'NECNWAL2Plugin.get_bound_port_context')
@@ -96,7 +96,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
96 96
         self.assertTrue(device)
97 97
 
98 98
     @mock.patch('neutron.plugins.ml2.plugin.Ml2Plugin.update_port_status')
99
-    @mock.patch('neutron.plugins.ml2.db.get_network_segments')
99
+    @mock.patch('neutron.db.segments_db.get_network_segments')
100 100
     @mock.patch('neutron.db.api.get_session')
101 101
     @mock.patch('networking_nec.nwa.l2.plugin.'
102 102
                 'NECNWAL2Plugin.get_bound_port_context')
@@ -116,7 +116,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
116 116
         self.assertTrue(device)
117 117
 
118 118
     @mock.patch('neutron.plugins.ml2.plugin.Ml2Plugin.update_port_status')
119
-    @mock.patch('neutron.plugins.ml2.db.get_network_segments')
119
+    @mock.patch('neutron.db.segments_db.get_network_segments')
120 120
     @mock.patch('neutron.db.api.get_session')
121 121
     @mock.patch('networking_nec.nwa.l2.plugin.'
122 122
                 'NECNWAL2Plugin.get_bound_port_context')
@@ -135,7 +135,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
135 135
         self.rpc.get_device_details(rpc_context, kwargs={'test': "sample"})
136 136
 
137 137
     @mock.patch('neutron.plugins.ml2.plugin.Ml2Plugin.update_port_status')
138
-    @mock.patch('neutron.plugins.ml2.db.get_network_segments')
138
+    @mock.patch('neutron.db.segments_db.get_network_segments')
139 139
     @mock.patch('neutron.db.api.get_session')
140 140
     @mock.patch('networking_nec.nwa.l2.plugin.'
141 141
                 'NECNWAL2Plugin.get_bound_port_context')
@@ -156,7 +156,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
156 156
 
157 157
     @mock.patch('neutron.plugins.ml2.plugin.Ml2Plugin.update_port_status')
158 158
     @mock.patch('networking_nec.nwa.l2.db_api.ensure_port_binding')
159
-    @mock.patch('neutron.plugins.ml2.db.get_network_segments')
159
+    @mock.patch('neutron.db.segments_db.get_network_segments')
160 160
     @mock.patch('neutron.db.api.get_session')
161 161
     @mock.patch('networking_nec.nwa.l2.plugin.'
162 162
                 'NECNWAL2Plugin.get_bound_port_context')
@@ -186,7 +186,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
186 186
     @mock.patch('networking_nec.nwa.l2.plugin.'
187 187
                 'NECNWAL2Plugin.update_port_status')
188 188
     @mock.patch('networking_nec.nwa.l2.db_api.ensure_port_binding')
189
-    @mock.patch('neutron.plugins.ml2.db.get_network_segments')
189
+    @mock.patch('neutron.db.segments_db.get_network_segments')
190 190
     @mock.patch('neutron.db.api.get_session')
191 191
     @mock.patch('networking_nec.nwa.l2.plugin.'
192 192
                 'NECNWAL2Plugin.get_bound_port_context')
@@ -212,7 +212,7 @@ class TestNECNWAServerRpcCallbacks(base.BaseTestCase):
212 212
     @mock.patch('networking_nec.nwa.l2.plugin.'
213 213
                 'NECNWAL2Plugin.update_port_status')
214 214
     @mock.patch('networking_nec.nwa.l2.db_api.ensure_port_binding')
215
-    @mock.patch('neutron.plugins.ml2.db.get_network_segments')
215
+    @mock.patch('neutron.db.segments_db.get_network_segments')
216 216
     @mock.patch('neutron.db.api.get_session')
217 217
     @mock.patch('networking_nec.nwa.l2.plugin.'
218 218
                 'NECNWAL2Plugin.get_bound_port_context')

+ 2
- 2
networking_nec/tests/unit/nwa/l2/rpc/test_nwa_l2_server_callback.py View File

@@ -26,8 +26,8 @@ class TestNwaL2ServerRpcCallback(base.BaseTestCase):
26 26
         self.context = mock.MagicMock()
27 27
 
28 28
     @mock.patch('neutron.db.api.get_session')
29
-    @mock.patch('neutron.plugins.ml2.db.get_dynamic_segment')
30
-    @mock.patch('neutron.plugins.ml2.db.delete_network_segment')
29
+    @mock.patch('neutron.db.segments_db.get_dynamic_segment')
30
+    @mock.patch('neutron.db.segments_db.delete_network_segment')
31 31
     def test_release_dynamic_segment_from_agent(self, dns, gds, gs):
32 32
         del_segment = {'segmentation_id': 0, 'id': 'ID-0'}
33 33
         gds.return_value = del_segment

+ 3
- 3
networking_nec/tests/unit/nwa/l2/test_plugin.py View File

@@ -54,7 +54,7 @@ class TestNECNWAL2Plugin(base.BaseTestCase):
54 54
 
55 55
         self.assertIsNone(result)
56 56
 
57
-    @patch('neutron.plugins.ml2.db.get_network_segments')
57
+    @patch('neutron.db.segments_db.get_network_segments')
58 58
     def test_extend_network_dict_provider_segment_none(self, f1):
59 59
         context = MagicMock()
60 60
         network = {'id': '99f771b4-af69-45cc-942f-a76be4e8cd1d'}
@@ -64,7 +64,7 @@ class TestNECNWAL2Plugin(base.BaseTestCase):
64 64
                                                               network)
65 65
         self.assertIsNone(result)
66 66
 
67
-    @patch('neutron.plugins.ml2.db.get_network_segments')
67
+    @patch('neutron.db.segments_db.get_network_segments')
68 68
     def test_extend_network_dict_provider_segment_one(self, f1):
69 69
         context = MagicMock()
70 70
         network = {'id': '99f771b4-af69-45cc-942f-a76be4e8cd1d'}
@@ -76,7 +76,7 @@ class TestNECNWAL2Plugin(base.BaseTestCase):
76 76
                                                               network)
77 77
         self.assertIsNone(result)
78 78
 
79
-    @patch('neutron.plugins.ml2.db.get_network_segments')
79
+    @patch('neutron.db.segments_db.get_network_segments')
80 80
     def test_extend_network_dict_provider_segment_multi(self, f1):
81 81
         context = MagicMock()
82 82
         network = {'id': '99f771b4-af69-45cc-942f-a76be4e8cd1d'}

+ 1
- 1
networking_nec/tests/unit/nwa/l3/test_plugin.py View File

@@ -16,8 +16,8 @@ from mock import MagicMock
16 16
 from mock import patch
17 17
 from sqlalchemy.orm import exc as sa_exc
18 18
 
19
-from neutron.common import exceptions as n_exc
20 19
 from neutron.tests import base
20
+from neutron_lib import exceptions as n_exc
21 21
 
22 22
 from networking_nec.nwa.l3.plugin import NECNWAL3Plugin
23 23
 

Loading…
Cancel
Save