Browse Source

Merge "use context manager from neutron-lib"

Zuul 3 months ago
parent
commit
13ddbdf31a

+ 36
- 36
networking_bgpvpn/neutron/db/bgpvpn_db.py View File

@@ -21,13 +21,13 @@ from sqlalchemy import orm
21 21
 from sqlalchemy.orm import exc
22 22
 
23 23
 from neutron.db import _model_query as model_query
24
-from neutron.db import api as db_api
25 24
 from neutron.db import common_db_mixin
26 25
 from neutron.db import standard_attr
27 26
 
28 27
 from neutron_lib.api.definitions import bgpvpn as bgpvpn_def
29 28
 from neutron_lib.api.definitions import bgpvpn_routes_control as bgpvpn_rc_def
30 29
 from neutron_lib.api.definitions import bgpvpn_vni as bgpvpn_vni_def
30
+from neutron_lib.db import api as db_api
31 31
 from neutron_lib.db import constants as db_const
32 32
 from neutron_lib.db import model_base
33 33
 from neutron_lib.plugins import directory
@@ -214,7 +214,7 @@ def _list_bgpvpns_result_filter_hook(query, filters):
214 214
     return query
215 215
 
216 216
 
217
-@db_api.context_manager.writer
217
+@db_api.CONTEXT_WRITER
218 218
 def _add_port_assoc_route_db_from_dict(context, route, port_association_id):
219 219
     if route['type'] == 'prefix':
220 220
         kwargs = {'prefix': route['prefix']}
@@ -256,7 +256,7 @@ class BGPVPNPluginDb(common_db_mixin.CommonDbMixin):
256 256
             result_filters=_list_bgpvpns_result_filter_hook)
257 257
         return super(BGPVPNPluginDb, cls).__new__(cls, *args, **kwargs)
258 258
 
259
-    @db_api.context_manager.reader
259
+    @db_api.CONTEXT_READER
260 260
     def _get_bgpvpns_for_tenant(self, session, tenant_id, fields):
261 261
         try:
262 262
             qry = session.query(BGPVPN)
@@ -267,7 +267,7 @@ class BGPVPNPluginDb(common_db_mixin.CommonDbMixin):
267 267
         return [self._make_bgpvpn_dict(bgpvpn, fields=fields)
268 268
                 for bgpvpn in bgpvpns]
269 269
 
270
-    @db_api.context_manager.reader
270
+    @db_api.CONTEXT_READER
271 271
     def _make_bgpvpn_dict(self, bgpvpn_db, fields=None):
272 272
         net_list = [net_assocs.network_id for net_assocs in
273 273
                     bgpvpn_db.network_associations]
@@ -302,14 +302,14 @@ class BGPVPNPluginDb(common_db_mixin.CommonDbMixin):
302 302
 
303 303
         return self._fields(res, fields)
304 304
 
305
-    @db_api.context_manager.writer
305
+    @db_api.CONTEXT_WRITER
306 306
     def create_bgpvpn(self, context, bgpvpn):
307 307
         rt = utils.rtrd_list2str(bgpvpn['route_targets'])
308 308
         i_rt = utils.rtrd_list2str(bgpvpn['import_targets'])
309 309
         e_rt = utils.rtrd_list2str(bgpvpn['export_targets'])
310 310
         rd = utils.rtrd_list2str(bgpvpn.get('route_distinguishers', ''))
311 311
 
312
-        with db_api.context_manager.writer.using(context):
312
+        with db_api.CONTEXT_WRITER.using(context):
313 313
             bgpvpn_db = BGPVPN(
314 314
                 id=uuidutils.generate_uuid(),
315 315
                 tenant_id=bgpvpn['tenant_id'],
@@ -326,24 +326,24 @@ class BGPVPNPluginDb(common_db_mixin.CommonDbMixin):
326 326
 
327 327
         return self._make_bgpvpn_dict(bgpvpn_db)
328 328
 
329
-    @db_api.context_manager.reader
329
+    @db_api.CONTEXT_READER
330 330
     def get_bgpvpns(self, context, filters=None, fields=None):
331 331
         return self._get_collection(context, BGPVPN, self._make_bgpvpn_dict,
332 332
                                     filters=filters, fields=fields)
333 333
 
334
-    @db_api.context_manager.reader
334
+    @db_api.CONTEXT_READER
335 335
     def _get_bgpvpn(self, context, id):
336 336
         try:
337 337
             return self._get_by_id(context, BGPVPN, id)
338 338
         except exc.NoResultFound:
339 339
             raise bgpvpn_ext.BGPVPNNotFound(id=id)
340 340
 
341
-    @db_api.context_manager.reader
341
+    @db_api.CONTEXT_READER
342 342
     def get_bgpvpn(self, context, id, fields=None):
343 343
         bgpvpn_db = self._get_bgpvpn(context, id)
344 344
         return self._make_bgpvpn_dict(bgpvpn_db, fields)
345 345
 
346
-    @db_api.context_manager.writer
346
+    @db_api.CONTEXT_WRITER
347 347
     def update_bgpvpn(self, context, id, bgpvpn):
348 348
         bgpvpn_db = self._get_bgpvpn(context, id)
349 349
         if bgpvpn:
@@ -363,14 +363,14 @@ class BGPVPNPluginDb(common_db_mixin.CommonDbMixin):
363 363
             bgpvpn_db.update(bgpvpn)
364 364
         return self._make_bgpvpn_dict(bgpvpn_db)
365 365
 
366
-    @db_api.context_manager.writer
366
+    @db_api.CONTEXT_WRITER
367 367
     def delete_bgpvpn(self, context, id):
368 368
         bgpvpn_db = self._get_bgpvpn(context, id)
369 369
         bgpvpn = self._make_bgpvpn_dict(bgpvpn_db)
370 370
         context.session.delete(bgpvpn_db)
371 371
         return bgpvpn
372 372
 
373
-    @db_api.context_manager.reader
373
+    @db_api.CONTEXT_READER
374 374
     def _make_net_assoc_dict(self, net_assoc_db, fields=None):
375 375
         res = {'id': net_assoc_db['id'],
376 376
                'tenant_id': net_assoc_db['tenant_id'],
@@ -378,7 +378,7 @@ class BGPVPNPluginDb(common_db_mixin.CommonDbMixin):
378 378
                'network_id': net_assoc_db['network_id']}
379 379
         return self._fields(res, fields)
380 380
 
381
-    @db_api.context_manager.reader
381
+    @db_api.CONTEXT_READER
382 382
     def _get_net_assoc(self, context, assoc_id, bgpvpn_id):
383 383
         try:
384 384
             query = self._model_query(context, BGPVPNNetAssociation)
@@ -389,10 +389,10 @@ class BGPVPNPluginDb(common_db_mixin.CommonDbMixin):
389 389
             raise bgpvpn_ext.BGPVPNNetAssocNotFound(id=assoc_id,
390 390
                                                     bgpvpn_id=bgpvpn_id)
391 391
 
392
-    @db_api.context_manager.writer
392
+    @db_api.CONTEXT_WRITER
393 393
     def create_net_assoc(self, context, bgpvpn_id, net_assoc):
394 394
         try:
395
-            with db_api.context_manager.writer.using(context):
395
+            with db_api.CONTEXT_WRITER.using(context):
396 396
                 net_assoc_db = BGPVPNNetAssociation(
397 397
                     tenant_id=net_assoc['tenant_id'],
398 398
                     bgpvpn_id=bgpvpn_id,
@@ -407,12 +407,12 @@ class BGPVPNPluginDb(common_db_mixin.CommonDbMixin):
407 407
             raise bgpvpn_ext.BGPVPNNetAssocAlreadyExists(
408 408
                 bgpvpn_id=bgpvpn_id, net_id=net_assoc['network_id'])
409 409
 
410
-    @db_api.context_manager.reader
410
+    @db_api.CONTEXT_READER
411 411
     def get_net_assoc(self, context, assoc_id, bgpvpn_id, fields=None):
412 412
         net_assoc_db = self._get_net_assoc(context, assoc_id, bgpvpn_id)
413 413
         return self._make_net_assoc_dict(net_assoc_db, fields)
414 414
 
415
-    @db_api.context_manager.reader
415
+    @db_api.CONTEXT_READER
416 416
     def get_net_assocs(self, context, bgpvpn_id, filters=None, fields=None):
417 417
         if not filters:
418 418
             filters = {}
@@ -421,7 +421,7 @@ class BGPVPNPluginDb(common_db_mixin.CommonDbMixin):
421 421
                                     self._make_net_assoc_dict,
422 422
                                     filters, fields)
423 423
 
424
-    @db_api.context_manager.writer
424
+    @db_api.CONTEXT_WRITER
425 425
     def delete_net_assoc(self, context, assoc_id, bgpvpn_id):
426 426
         LOG.info("deleting network association %(id)s for "
427 427
                  "BGPVPN %(bgpvpn)s", {'id': assoc_id,
@@ -431,7 +431,7 @@ class BGPVPNPluginDb(common_db_mixin.CommonDbMixin):
431 431
         context.session.delete(net_assoc_db)
432 432
         return net_assoc
433 433
 
434
-    @db_api.context_manager.reader
434
+    @db_api.CONTEXT_READER
435 435
     def _make_router_assoc_dict(self, router_assoc_db, fields=None):
436 436
         res = {'id': router_assoc_db['id'],
437 437
                'tenant_id': router_assoc_db['tenant_id'],
@@ -442,7 +442,7 @@ class BGPVPNPluginDb(common_db_mixin.CommonDbMixin):
442 442
                }
443 443
         return self._fields(res, fields)
444 444
 
445
-    @db_api.context_manager.reader
445
+    @db_api.CONTEXT_READER
446 446
     def _get_router_assoc(self, context, assoc_id, bgpvpn_id):
447 447
         try:
448 448
             query = self._model_query(context, BGPVPNRouterAssociation)
@@ -453,11 +453,11 @@ class BGPVPNPluginDb(common_db_mixin.CommonDbMixin):
453 453
             raise bgpvpn_ext.BGPVPNRouterAssocNotFound(id=assoc_id,
454 454
                                                        bgpvpn_id=bgpvpn_id)
455 455
 
456
-    @db_api.context_manager.writer
456
+    @db_api.CONTEXT_WRITER
457 457
     def create_router_assoc(self, context, bgpvpn_id, router_association):
458 458
         router_id = router_association['router_id']
459 459
         try:
460
-            with db_api.context_manager.writer.using(context):
460
+            with db_api.CONTEXT_WRITER.using(context):
461 461
                 router_assoc_db = BGPVPNRouterAssociation(
462 462
                     tenant_id=router_association['tenant_id'],
463 463
                     bgpvpn_id=bgpvpn_id,
@@ -472,12 +472,12 @@ class BGPVPNPluginDb(common_db_mixin.CommonDbMixin):
472 472
             raise bgpvpn_ext.BGPVPNRouterAssocAlreadyExists(
473 473
                 bgpvpn_id=bgpvpn_id, router_id=router_association['router_id'])
474 474
 
475
-    @db_api.context_manager.reader
475
+    @db_api.CONTEXT_READER
476 476
     def get_router_assoc(self, context, assoc_id, bgpvpn_id, fields=None):
477 477
         router_assoc_db = self._get_router_assoc(context, assoc_id, bgpvpn_id)
478 478
         return self._make_router_assoc_dict(router_assoc_db, fields)
479 479
 
480
-    @db_api.context_manager.reader
480
+    @db_api.CONTEXT_READER
481 481
     def get_router_assocs(self, context, bgpvpn_id, filters=None, fields=None):
482 482
         if not filters:
483 483
             filters = {}
@@ -486,14 +486,14 @@ class BGPVPNPluginDb(common_db_mixin.CommonDbMixin):
486 486
                                     self._make_router_assoc_dict,
487 487
                                     filters, fields)
488 488
 
489
-    @db_api.context_manager.writer
489
+    @db_api.CONTEXT_WRITER
490 490
     def update_router_assoc(self, context, assoc_id, bgpvpn_id, router_assoc):
491 491
         router_assoc_db = self._get_router_assoc(context,
492 492
                                                  assoc_id, bgpvpn_id)
493 493
         router_assoc_db.update(router_assoc)
494 494
         return self._make_router_assoc_dict(router_assoc_db)
495 495
 
496
-    @db_api.context_manager.writer
496
+    @db_api.CONTEXT_WRITER
497 497
     def delete_router_assoc(self, context, assoc_id, bgpvpn_id):
498 498
         LOG.info("deleting router association %(id)s for "
499 499
                  "BGPVPN %(bgpvpn)s",
@@ -504,7 +504,7 @@ class BGPVPNPluginDb(common_db_mixin.CommonDbMixin):
504 504
         context.session.delete(router_assoc_db)
505 505
         return router_assoc
506 506
 
507
-    @db_api.context_manager.reader
507
+    @db_api.CONTEXT_READER
508 508
     def _make_port_assoc_dict(self, port_assoc_db, fields=None):
509 509
         routes = [port_assoc_route_dict_from_db(r)
510 510
                   for r in port_assoc_db['routes']]
@@ -516,7 +516,7 @@ class BGPVPNPluginDb(common_db_mixin.CommonDbMixin):
516 516
                'routes': routes}
517 517
         return self._fields(res, fields)
518 518
 
519
-    @db_api.context_manager.reader
519
+    @db_api.CONTEXT_READER
520 520
     def _get_port_assoc(self, context, assoc_id, bgpvpn_id):
521 521
         try:
522 522
             query = self._model_query(context, BGPVPNPortAssociation)
@@ -527,12 +527,12 @@ class BGPVPNPluginDb(common_db_mixin.CommonDbMixin):
527 527
             raise bgpvpn_rc_ext.BGPVPNPortAssocNotFound(id=assoc_id,
528 528
                                                         bgpvpn_id=bgpvpn_id)
529 529
 
530
-    @db_api.context_manager.reader
530
+    @db_api.CONTEXT_READER
531 531
     def create_port_assoc(self, context, bgpvpn_id, port_association):
532 532
         port_id = port_association['port_id']
533 533
         advertise_fixed_ips = port_association['advertise_fixed_ips']
534 534
         try:
535
-            with db_api.context_manager.writer.using(context):
535
+            with db_api.CONTEXT_WRITER.using(context):
536 536
                 port_assoc_db = BGPVPNPortAssociation(
537 537
                     tenant_id=port_association['tenant_id'],
538 538
                     bgpvpn_id=bgpvpn_id,
@@ -547,18 +547,18 @@ class BGPVPNPluginDb(common_db_mixin.CommonDbMixin):
547 547
             raise bgpvpn_rc_ext.BGPVPNPortAssocAlreadyExists(
548 548
                 bgpvpn_id=bgpvpn_id, port_id=port_association['port_id'])
549 549
 
550
-        with db_api.context_manager.writer.using(context):
550
+        with db_api.CONTEXT_WRITER.using(context):
551 551
             for route in port_association['routes']:
552 552
                     _add_port_assoc_route_db_from_dict(context,
553 553
                                                        route, port_assoc_db.id)
554 554
         return self._make_port_assoc_dict(port_assoc_db)
555 555
 
556
-    @db_api.context_manager.reader
556
+    @db_api.CONTEXT_READER
557 557
     def get_port_assoc(self, context, assoc_id, bgpvpn_id, fields=None):
558 558
         port_assoc_db = self._get_port_assoc(context, assoc_id, bgpvpn_id)
559 559
         return self._make_port_assoc_dict(port_assoc_db, fields)
560 560
 
561
-    @db_api.context_manager.reader
561
+    @db_api.CONTEXT_READER
562 562
     def get_port_assocs(self, context, bgpvpn_id, filters=None, fields=None):
563 563
         if not filters:
564 564
             filters = {}
@@ -567,9 +567,9 @@ class BGPVPNPluginDb(common_db_mixin.CommonDbMixin):
567 567
                                     self._make_port_assoc_dict,
568 568
                                     filters, fields)
569 569
 
570
-    @db_api.context_manager.reader
570
+    @db_api.CONTEXT_READER
571 571
     def update_port_assoc(self, context, assoc_id, bgpvpn_id, port_assoc):
572
-        with db_api.context_manager.writer.using(context):
572
+        with db_api.CONTEXT_WRITER.using(context):
573 573
             port_assoc_db = self._get_port_assoc(context, assoc_id, bgpvpn_id)
574 574
             for route_db in port_assoc_db.routes:
575 575
                 context.session.delete(route_db)
@@ -579,7 +579,7 @@ class BGPVPNPluginDb(common_db_mixin.CommonDbMixin):
579 579
         context.session.refresh(port_assoc_db)
580 580
         return self._make_port_assoc_dict(port_assoc_db)
581 581
 
582
-    @db_api.context_manager.writer
582
+    @db_api.CONTEXT_WRITER
583 583
     def delete_port_assoc(self, context, assoc_id, bgpvpn_id):
584 584
         LOG.info(("deleting port association %(id)s for "
585 585
                   "BGPVPN %(bgpvpn)s"),

+ 10
- 10
networking_bgpvpn/neutron/services/service_drivers/bagpipe/bagpipe.py View File

@@ -16,7 +16,6 @@
16 16
 from sqlalchemy import orm
17 17
 from sqlalchemy import sql
18 18
 
19
-from neutron.db import api as db_api
20 19
 from neutron.db.models import l3
21 20
 from neutron.db import models_v2
22 21
 from neutron.debug import debug_agent
@@ -26,6 +25,7 @@ from neutron_lib.callbacks import events
26 25
 from neutron_lib.callbacks import registry
27 26
 from neutron_lib.callbacks import resources
28 27
 from neutron_lib import constants as const
28
+from neutron_lib.db import api as db_api
29 29
 
30 30
 from oslo_log import helpers as log_helpers
31 31
 from oslo_log import log as logging
@@ -42,7 +42,7 @@ LOG = logging.getLogger(__name__)
42 42
 
43 43
 
44 44
 @log_helpers.log_method_call
45
-@db_api.context_manager.reader
45
+@db_api.CONTEXT_READER
46 46
 def get_network_info_for_port(context, port_id, network_id):
47 47
     """Get MAC, IP and Gateway IP addresses informations for a specific port"""
48 48
     try:
@@ -79,7 +79,7 @@ def get_network_info_for_port(context, port_id, network_id):
79 79
             'gateway_mac': gateway_mac[0] if gateway_mac else None}
80 80
 
81 81
 
82
-@db_api.context_manager.reader
82
+@db_api.CONTEXT_READER
83 83
 def get_gateway_mac(context, network_id):
84 84
     gateway_mac = (
85 85
         context.session.
@@ -95,7 +95,7 @@ def get_gateway_mac(context, network_id):
95 95
     return gateway_mac[0] if gateway_mac else None
96 96
 
97 97
 
98
-@db_api.context_manager.reader
98
+@db_api.CONTEXT_READER
99 99
 def get_network_ports(context, network_id):
100 100
     # NOTE(tmorin): currents callers don't look at detailed results
101 101
     # but only test if at least one result exist => can be optimized
@@ -105,7 +105,7 @@ def get_network_ports(context, network_id):
105 105
                    models_v2.Port.admin_state_up == sql.true()).all())
106 106
 
107 107
 
108
-@db_api.context_manager.reader
108
+@db_api.CONTEXT_READER
109 109
 def get_router_ports(context, router_id):
110 110
     return (
111 111
         context.session.query(models_v2.Port).
@@ -116,7 +116,7 @@ def get_router_ports(context, router_id):
116 116
     )
117 117
 
118 118
 
119
-@db_api.context_manager.reader
119
+@db_api.CONTEXT_READER
120 120
 def get_router_bgpvpn_assocs(context, router_id):
121 121
     return (
122 122
         context.session.query(bgpvpn_db.BGPVPNRouterAssociation).
@@ -126,7 +126,7 @@ def get_router_bgpvpn_assocs(context, router_id):
126 126
     )
127 127
 
128 128
 
129
-@db_api.context_manager.reader
129
+@db_api.CONTEXT_READER
130 130
 def get_network_bgpvpn_assocs(context, net_id):
131 131
     return (
132 132
         context.session.query(bgpvpn_db.BGPVPNNetAssociation).
@@ -136,7 +136,7 @@ def get_network_bgpvpn_assocs(context, net_id):
136 136
     )
137 137
 
138 138
 
139
-@db_api.context_manager.reader
139
+@db_api.CONTEXT_READER
140 140
 def get_bgpvpns_of_router_assocs_by_network(context, net_id):
141 141
     return (
142 142
         context.session.query(bgpvpn_db.BGPVPN).
@@ -150,7 +150,7 @@ def get_bgpvpns_of_router_assocs_by_network(context, net_id):
150 150
     )
151 151
 
152 152
 
153
-@db_api.context_manager.reader
153
+@db_api.CONTEXT_READER
154 154
 def get_networks_for_router(context, router_id):
155 155
     ports = get_router_ports(context, router_id)
156 156
     if ports:
@@ -326,7 +326,7 @@ class BaGPipeBGPVPNDriver(v2.BaGPipeBGPVPNDriver):
326 326
 
327 327
         return bgpvpn_network_info
328 328
 
329
-    @db_api.context_manager.reader
329
+    @db_api.CONTEXT_READER
330 330
     def retrieve_bgpvpns_of_router_assocs_by_network(self, context,
331 331
                                                      network_id):
332 332
         return [self.bgpvpn_db._make_bgpvpn_dict(bgpvpn) for bgpvpn in

+ 2
- 2
networking_bgpvpn/neutron/services/service_drivers/bagpipe/bagpipe_v2.py View File

@@ -17,7 +17,6 @@ from sqlalchemy import orm
17 17
 
18 18
 from neutron.api.rpc.callbacks import events as rpc_events
19 19
 from neutron.api.rpc.handlers import resources_rpc
20
-from neutron.db import api as db_api
21 20
 from neutron.db.models import external_net
22 21
 
23 22
 from neutron_lib.api.definitions import bgpvpn_routes_control as bgpvpn_rc_def
@@ -25,6 +24,7 @@ from neutron_lib.api.definitions import bgpvpn_vni as bgpvpn_vni_def
25 24
 from neutron_lib.callbacks import events
26 25
 from neutron_lib.callbacks import registry
27 26
 from neutron_lib.callbacks import resources
27
+from neutron_lib.db import api as db_api
28 28
 from neutron_lib import exceptions as n_exc
29 29
 from neutron_lib.plugins import directory
30 30
 
@@ -48,7 +48,7 @@ class BGPVPNExternalNetAssociation(n_exc.NeutronException):
48 48
                 "network to a BGPVPN")
49 49
 
50 50
 
51
-@db_api.context_manager.reader
51
+@db_api.CONTEXT_READER
52 52
 def network_is_external(context, net_id):
53 53
     try:
54 54
         context.session.query(external_net.ExternalNetwork).filter_by(

+ 12
- 12
networking_bgpvpn/neutron/services/service_drivers/driver_api.py View File

@@ -17,7 +17,7 @@ import abc
17 17
 import copy
18 18
 import six
19 19
 
20
-from neutron.db import api as db_api
20
+from neutron_lib.db import api as db_api
21 21
 
22 22
 from networking_bgpvpn.neutron.db import bgpvpn_db
23 23
 from networking_bgpvpn.neutron.extensions \
@@ -106,7 +106,7 @@ class BGPVPNDriverDBMixin(BGPVPNDriverBase):
106 106
         self.bgpvpn_db = bgpvpn_db.BGPVPNPluginDb()
107 107
 
108 108
     def create_bgpvpn(self, context, bgpvpn):
109
-        with db_api.context_manager.writer.using(context):
109
+        with db_api.CONTEXT_WRITER.using(context):
110 110
             bgpvpn = self.bgpvpn_db.create_bgpvpn(
111 111
                 context, bgpvpn)
112 112
             self.create_bgpvpn_precommit(context, bgpvpn)
@@ -121,7 +121,7 @@ class BGPVPNDriverDBMixin(BGPVPNDriverBase):
121 121
 
122 122
     def update_bgpvpn(self, context, id, bgpvpn_delta):
123 123
         old_bgpvpn = self.get_bgpvpn(context, id)
124
-        with db_api.context_manager.writer.using(context):
124
+        with db_api.CONTEXT_WRITER.using(context):
125 125
             new_bgpvpn = copy.deepcopy(old_bgpvpn)
126 126
             new_bgpvpn.update(bgpvpn_delta)
127 127
             self.update_bgpvpn_precommit(context, old_bgpvpn, new_bgpvpn)
@@ -130,14 +130,14 @@ class BGPVPNDriverDBMixin(BGPVPNDriverBase):
130 130
         return bgpvpn
131 131
 
132 132
     def delete_bgpvpn(self, context, id):
133
-        with db_api.context_manager.writer.using(context):
133
+        with db_api.CONTEXT_WRITER.using(context):
134 134
             bgpvpn = self.bgpvpn_db.get_bgpvpn(context, id)
135 135
             self.delete_bgpvpn_precommit(context, bgpvpn)
136 136
             self.bgpvpn_db.delete_bgpvpn(context, id)
137 137
         self.delete_bgpvpn_postcommit(context, bgpvpn)
138 138
 
139 139
     def create_net_assoc(self, context, bgpvpn_id, network_association):
140
-        with db_api.context_manager.writer.using(context):
140
+        with db_api.CONTEXT_WRITER.using(context):
141 141
             assoc = self.bgpvpn_db.create_net_assoc(context,
142 142
                                                     bgpvpn_id,
143 143
                                                     network_association)
@@ -154,7 +154,7 @@ class BGPVPNDriverDBMixin(BGPVPNDriverBase):
154 154
                                              filters, fields)
155 155
 
156 156
     def delete_net_assoc(self, context, assoc_id, bgpvpn_id):
157
-        with db_api.context_manager.writer.using(context):
157
+        with db_api.CONTEXT_WRITER.using(context):
158 158
             net_assoc = self.bgpvpn_db.get_net_assoc(context,
159 159
                                                      assoc_id,
160 160
                                                      bgpvpn_id)
@@ -166,7 +166,7 @@ class BGPVPNDriverDBMixin(BGPVPNDriverBase):
166 166
         self.delete_net_assoc_postcommit(context, net_assoc)
167 167
 
168 168
     def create_router_assoc(self, context, bgpvpn_id, router_association):
169
-        with db_api.context_manager.writer.using(context):
169
+        with db_api.CONTEXT_WRITER.using(context):
170 170
             assoc = self.bgpvpn_db.create_router_assoc(context, bgpvpn_id,
171 171
                                                        router_association)
172 172
             self.create_router_assoc_precommit(context, assoc)
@@ -182,7 +182,7 @@ class BGPVPNDriverDBMixin(BGPVPNDriverBase):
182 182
                                                 filters, fields)
183 183
 
184 184
     def delete_router_assoc(self, context, assoc_id, bgpvpn_id):
185
-        with db_api.context_manager.writer.using(context):
185
+        with db_api.CONTEXT_WRITER.using(context):
186 186
             router_assoc = self.bgpvpn_db.get_router_assoc(context,
187 187
                                                            assoc_id,
188 188
                                                            bgpvpn_id)
@@ -343,7 +343,7 @@ class BGPVPNDriverRCDBMixin(BGPVPNDriverRCBase, BGPVPNDriverDBMixin):
343 343
 
344 344
     def update_router_assoc(self, context, assoc_id, bgpvpn_id, router_assoc):
345 345
         old_router_assoc = self.get_router_assoc(context, assoc_id, bgpvpn_id)
346
-        with db_api.context_manager.writer.using(context):
346
+        with db_api.CONTEXT_WRITER.using(context):
347 347
             router_assoc = self.bgpvpn_db.update_router_assoc(context,
348 348
                                                               assoc_id,
349 349
                                                               bgpvpn_id,
@@ -365,7 +365,7 @@ class BGPVPNDriverRCDBMixin(BGPVPNDriverRCBase, BGPVPNDriverDBMixin):
365 365
         pass
366 366
 
367 367
     def create_port_assoc(self, context, bgpvpn_id, port_association):
368
-        with db_api.context_manager.writer.using(context):
368
+        with db_api.CONTEXT_WRITER.using(context):
369 369
             port_assoc = self.bgpvpn_db.create_port_assoc(context, bgpvpn_id,
370 370
                                                           port_association)
371 371
             self.create_port_assoc_precommit(context, port_assoc)
@@ -390,7 +390,7 @@ class BGPVPNDriverRCDBMixin(BGPVPNDriverRCBase, BGPVPNDriverDBMixin):
390 390
 
391 391
     def update_port_assoc(self, context, assoc_id, bgpvpn_id, port_assoc):
392 392
         old_port_assoc = self.get_port_assoc(context, assoc_id, bgpvpn_id)
393
-        with db_api.context_manager.writer.using(context):
393
+        with db_api.CONTEXT_WRITER.using(context):
394 394
             port_assoc = self.bgpvpn_db.update_port_assoc(context, assoc_id,
395 395
                                                           bgpvpn_id,
396 396
                                                           port_assoc)
@@ -411,7 +411,7 @@ class BGPVPNDriverRCDBMixin(BGPVPNDriverRCBase, BGPVPNDriverDBMixin):
411 411
         pass
412 412
 
413 413
     def delete_port_assoc(self, context, assoc_id, bgpvpn_id):
414
-        with db_api.context_manager.writer.using(context):
414
+        with db_api.CONTEXT_WRITER.using(context):
415 415
             port_assoc = self.bgpvpn_db.get_port_assoc(context,
416 416
                                                        assoc_id,
417 417
                                                        bgpvpn_id)

Loading…
Cancel
Save