Browse Source

stop using common db mixin methods

All of the methods of common db mixin are available via neutron-lib
and the mixin will be removed before long.
This patch switches the code over to use neutron-lib's APIs rather
than those of the mixin and stop using the mixin as a parent class.

Depends-On: https://review.openstack.org/#/c/635596/

Change-Id: I26001dbaecc99d22732f77247a429444e7bc119e
Boden R 2 months ago
parent
commit
1b8b90e923

+ 1
- 3
networking_bigswitch/plugins/bigswitch/bsn_service_plugin.py View File

@@ -16,7 +16,6 @@
16 16
 from datetime import datetime
17 17
 import eventlet
18 18
 
19
-from neutron.db import common_db_mixin
20 19
 from neutron_lib.db import api as db_api
21 20
 from neutron_lib.services import base as service_base
22 21
 from oslo_log import log
@@ -34,8 +33,7 @@ LOG = log.getLogger(__name__)
34 33
 
35 34
 
36 35
 class BSNServicePlugin(service_base.ServicePluginBase,
37
-                       bsnserviceextension.BSNServicePluginBase,
38
-                       common_db_mixin.CommonDbMixin):
36
+                       bsnserviceextension.BSNServicePluginBase):
39 37
 
40 38
     supported_extension_aliases = ["bsn-service-extension"]
41 39
 

+ 13
- 11
networking_bigswitch/plugins/bigswitch/db/network_template_db.py View File

@@ -16,8 +16,8 @@
16 16
 import sqlalchemy as sa
17 17
 
18 18
 from networking_bigswitch.plugins.bigswitch.i18n import _
19
-from neutron.db import common_db_mixin
20 19
 from neutron_lib.db import model_base
20
+from neutron_lib.db import model_query
21 21
 from neutron_lib.db import utils as db_utils
22 22
 from neutron_lib import exceptions
23 23
 from oslo_db import exception as db_exc
@@ -35,7 +35,7 @@ class NetworkTemplateNotFound(exceptions.NotFound):
35 35
     message = _("Network Template %(id)s could not be found")
36 36
 
37 37
 
38
-class NetworkTemplateDbMixin(common_db_mixin.CommonDbMixin):
38
+class NetworkTemplateDbMixin(object):
39 39
     # internal methods
40 40
     def _make_networktemplate_dict(self, template, fields=None):
41 41
         return db_utils.resource_fields({
@@ -45,7 +45,8 @@ class NetworkTemplateDbMixin(common_db_mixin.CommonDbMixin):
45 45
 
46 46
     def _get_networktemplate(self, context, id):
47 47
         try:
48
-            networktemplate = self._get_by_id(context, NetworkTemplate, id)
48
+            networktemplate = model_query.get_by_id(
49
+                context, NetworkTemplate, id)
49 50
         except exc.NoResultFound:
50 51
             raise NetworkTemplateNotFound(id=id)
51 52
         return networktemplate
@@ -55,9 +56,9 @@ class NetworkTemplateDbMixin(common_db_mixin.CommonDbMixin):
55 56
                              sorts=None, limit=None, marker=None,
56 57
                              page_reverse=False):
57 58
         networktemplates = \
58
-            self._get_collection(context, NetworkTemplate,
59
-                                 self._make_networktemplate_dict,
60
-                                 filters=filters, fields=fields)
59
+            model_query.get_collection(context, NetworkTemplate,
60
+                                       self._make_networktemplate_dict,
61
+                                       filters=filters, fields=fields)
61 62
         return networktemplates
62 63
 
63 64
     def get_networktemplate(self, context, id, fields=None):
@@ -106,7 +107,7 @@ class NetworkTemplateAssignmentExists(exceptions.NeutronException):
106 107
         _("Network Template Assignment for tenant ID %(tenant_id)s exists")
107 108
 
108 109
 
109
-class NetworkTemplateAssignmentDbMixin(common_db_mixin.CommonDbMixin):
110
+class NetworkTemplateAssignmentDbMixin(object):
110 111
     # internal methods
111 112
     def _make_networktemplateassignment_dict(self, templateassignment,
112 113
                                              fields=None):
@@ -118,7 +119,7 @@ class NetworkTemplateAssignmentDbMixin(common_db_mixin.CommonDbMixin):
118 119
 
119 120
     def _get_networktemplateassignment(self, context, id):
120 121
         try:
121
-            networktemplateassignment = self._get_by_id(
122
+            networktemplateassignment = model_query.get_by_id(
122 123
                 context, NetworkTemplateAssignment, id)
123 124
         except exc.NoResultFound:
124 125
             raise NetworkTemplateAssignmentNotFound(id=id)
@@ -129,9 +130,10 @@ class NetworkTemplateAssignmentDbMixin(common_db_mixin.CommonDbMixin):
129 130
                                        fields=None, sorts=None, limit=None,
130 131
                                        marker=None, page_reverse=False):
131 132
         networktemplateassignments = \
132
-            self._get_collection(context, NetworkTemplateAssignment,
133
-                                 self._make_networktemplateassignment_dict,
134
-                                 filters=filters, fields=fields)
133
+            model_query.get_collection(
134
+                context, NetworkTemplateAssignment,
135
+                self._make_networktemplateassignment_dict,
136
+                filters=filters, fields=fields)
135 137
         return networktemplateassignments
136 138
 
137 139
     def get_networktemplateassignment(self, context, id, fields=None):

+ 12
- 11
networking_bigswitch/plugins/bigswitch/db/reachability_test_db.py View File

@@ -17,8 +17,8 @@ import sqlalchemy as sa
17 17
 
18 18
 from networking_bigswitch.plugins.bigswitch.i18n import _
19 19
 from networking_bigswitch.plugins.bigswitch.utils import Util
20
-from neutron.db import common_db_mixin
21 20
 from neutron_lib.db import model_base
21
+from neutron_lib.db import model_query
22 22
 from neutron_lib.db import utils as db_utils
23 23
 from neutron_lib import exceptions
24 24
 from oslo_serialization import jsonutils
@@ -128,7 +128,7 @@ class ReachabilityTestSegmentNameMissing(exceptions.NeutronException):
128 128
                 "Please recreate the network and update Test %(test_name)s.")
129 129
 
130 130
 
131
-class ReachabilityTestDbMixin(common_db_mixin.CommonDbMixin):
131
+class ReachabilityTestDbMixin(object):
132 132
     # internal methods
133 133
     def _make_reachabilitytest_dict(self, reachabilitytest, fields=None):
134 134
         return db_utils.resource_fields({
@@ -150,7 +150,8 @@ class ReachabilityTestDbMixin(common_db_mixin.CommonDbMixin):
150 150
 
151 151
     def _get_reachabilitytest(self, context, id):
152 152
         try:
153
-            reachabilitytest = self._get_by_id(context, ReachabilityTest, id)
153
+            reachabilitytest = model_query.get_by_id(
154
+                context, ReachabilityTest, id)
154 155
         except exc.NoResultFound:
155 156
             raise ReachabilityTestNotFound(id=id)
156 157
         return reachabilitytest
@@ -160,9 +161,9 @@ class ReachabilityTestDbMixin(common_db_mixin.CommonDbMixin):
160 161
                               sorts=None, limit=None, marker=None,
161 162
                               page_reverse=False):
162 163
         reachabilitytests = \
163
-            self._get_collection(context, ReachabilityTest,
164
-                                 self._make_reachabilitytest_dict,
165
-                                 filters=filters, fields=fields)
164
+            model_query.get_collection(context, ReachabilityTest,
165
+                                       self._make_reachabilitytest_dict,
166
+                                       filters=filters, fields=fields)
166 167
         return reachabilitytests
167 168
 
168 169
     def get_reachabilitytest(self, context, id, fields=None):
@@ -282,7 +283,7 @@ class ReachabilityQuickTest(model_base.BASEV2,
282 283
         return destination
283 284
 
284 285
 
285
-class ReachabilityQuickTestDbMixin(common_db_mixin.CommonDbMixin):
286
+class ReachabilityQuickTestDbMixin(object):
286 287
     # internal methods
287 288
     def _make_reachabilityquicktest_dict(self, reachabilityquicktest,
288 289
                                          fields=None):
@@ -305,7 +306,7 @@ class ReachabilityQuickTestDbMixin(common_db_mixin.CommonDbMixin):
305 306
 
306 307
     def _get_reachabilityquicktest(self, context, id):
307 308
         try:
308
-            reachabilityquicktest = self._get_by_id(
309
+            reachabilityquicktest = model_query.get_by_id(
309 310
                 context, ReachabilityQuickTest, id)
310 311
         except exc.NoResultFound:
311 312
             raise ReachabilityTestNotFound(id=id)
@@ -316,9 +317,9 @@ class ReachabilityQuickTestDbMixin(common_db_mixin.CommonDbMixin):
316 317
                                    sorts=None, limit=None, marker=None,
317 318
                                    page_reverse=False):
318 319
         reachabilityquicktests = \
319
-            self._get_collection(context, ReachabilityQuickTest,
320
-                                 self._make_reachabilityquicktest_dict,
321
-                                 filters=filters, fields=fields)
320
+            model_query.get_collection(context, ReachabilityQuickTest,
321
+                                       self._make_reachabilityquicktest_dict,
322
+                                       filters=filters, fields=fields)
322 323
         return reachabilityquicktests
323 324
 
324 325
     def get_reachabilityquicktest(self, context, id, fields=None):

+ 6
- 6
networking_bigswitch/plugins/bigswitch/db/tenant_policy_db.py View File

@@ -17,11 +17,11 @@ import sqlalchemy as sa
17 17
 
18 18
 from networking_bigswitch.plugins.bigswitch.i18n import _
19 19
 from networking_bigswitch.plugins.bigswitch.utils import Util
20
-from neutron.db import common_db_mixin
21 20
 from neutron.db.models import l3 as l3_models
22 21
 from neutron_lib.api import validators
23 22
 from neutron_lib.db import api as db_api
24 23
 from neutron_lib.db import model_base
24
+from neutron_lib.db import model_query
25 25
 from neutron_lib.db import utils as db_utils
26 26
 from neutron_lib import exceptions as n_exc
27 27
 from oslo_config import cfg
@@ -87,7 +87,7 @@ class TenantRouterDoesNotExist(n_exc.NotFound):
87 87
                 "Please create a router before adding policies.")
88 88
 
89 89
 
90
-class TenantPolicyDbMixin(common_db_mixin.CommonDbMixin):
90
+class TenantPolicyDbMixin(object):
91 91
     # internal methods
92 92
     def _make_tenantpolicy_dict(self, tenantpolicy, fields=None):
93 93
         nexthops = [hop['nexthop'] for hop in tenantpolicy.nexthops]
@@ -105,7 +105,7 @@ class TenantPolicyDbMixin(common_db_mixin.CommonDbMixin):
105 105
 
106 106
     def _get_tenantpolicy(self, context, id):
107 107
         try:
108
-            tenantpolicy = self._get_by_id(context, TenantPolicy, id)
108
+            tenantpolicy = model_query.get_by_id(context, TenantPolicy, id)
109 109
         except exc.NoResultFound:
110 110
             raise TenantPolicyNotFound(id=id)
111 111
         return tenantpolicy
@@ -214,9 +214,9 @@ class TenantPolicyDbMixin(common_db_mixin.CommonDbMixin):
214 214
                            page_reverse=False):
215 215
         with db_api.CONTEXT_READER.using(context):
216 216
             tenantpolicies = \
217
-                self._get_collection(context, TenantPolicy,
218
-                                     self._make_tenantpolicy_dict,
219
-                                     filters=filters, fields=fields)
217
+                model_query.get_collection(context, TenantPolicy,
218
+                                           self._make_tenantpolicy_dict,
219
+                                           filters=filters, fields=fields)
220 220
         return tenantpolicies
221 221
 
222 222
     def get_tenantpolicy(self, context, id, fields=None):

+ 2
- 1
networking_bigswitch/plugins/bigswitch/l3_router_plugin.py View File

@@ -31,6 +31,7 @@ from neutron_lib.callbacks import registry
31 31
 from neutron_lib.callbacks import resources
32 32
 from neutron_lib import constants as lib_constants
33 33
 from neutron_lib.db import api as db_api
34
+from neutron_lib.db import utils as db_utils
34 35
 from neutron_lib import exceptions
35 36
 from neutron_lib.plugins import constants as plugin_constants
36 37
 from neutron_lib.plugins import directory
@@ -410,7 +411,7 @@ class L3RestProxy(cplugin.NeutronRestProxyV2Base,
410 411
             floatingip, fields=fields,
411 412
             process_extensions=process_extensions)
412 413
         res['floating_port_id'] = floatingip['floating_port_id']
413
-        return self._fields(res, fields)
414
+        return db_utils.resource_fields(res, fields)
414 415
 
415 416
     @add_debug_log
416 417
     @log_helper.log_method_call

+ 3
- 2
networking_bigswitch/plugins/bigswitch/plugin.py View File

@@ -79,6 +79,7 @@ from neutron_lib.api.definitions import portbindings
79 79
 from neutron_lib import constants as const
80 80
 from neutron_lib import context as qcontext
81 81
 from neutron_lib.db import api as db_api
82
+from neutron_lib.db import utils as db_utils
82 83
 from neutron_lib import exceptions as lib_exceptions
83 84
 from neutron_lib.plugins import constants as plugin_constants
84 85
 from neutron_lib.plugins import directory
@@ -1220,7 +1221,7 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
1220 1221
             port = super(NeutronRestProxyV2, self).get_port(context, id,
1221 1222
                                                             fields)
1222 1223
             self._extend_port_dict_binding(context, port)
1223
-        return self._fields(port, fields)
1224
+        return db_utils.resource_fields(port, fields)
1224 1225
 
1225 1226
     def get_ports(self, context, filters=None, fields=None):
1226 1227
         with db_api.CONTEXT_READER.using(context):
@@ -1228,7 +1229,7 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
1228 1229
                                                               fields)
1229 1230
             for port in ports:
1230 1231
                 self._extend_port_dict_binding(context, port)
1231
-        return [self._fields(port, fields) for port in ports]
1232
+        return [db_utils.resource_fields(port, fields) for port in ports]
1232 1233
 
1233 1234
     @add_debug_log
1234 1235
     def update_port(self, context, port_id, port):

Loading…
Cancel
Save