Switch to new engine facade for ExtraRoute_dbonly_mixin
Partially-Implements blueprint: enginefacade-switch Change-Id: I355c39bde8d2d16baddf08af61b780b71981abab
This commit is contained in:
parent
568f70fcef
commit
d279ec1180
@ -20,6 +20,7 @@ from neutron_lib.api.definitions import l3 as l3_apidef
|
||||
from neutron_lib.callbacks import events
|
||||
from neutron_lib.callbacks import registry
|
||||
from neutron_lib.callbacks import resources
|
||||
from neutron_lib.db import api as db_api
|
||||
from neutron_lib.db import resource_extend
|
||||
from neutron_lib.exceptions import extraroute as xroute_exc
|
||||
from neutron_lib.utils import helpers
|
||||
@ -53,7 +54,7 @@ class ExtraRoute_dbonly_mixin(l3_db.L3_NAT_dbonly_mixin):
|
||||
def update_router(self, context, id, router):
|
||||
r = router['router']
|
||||
if 'routes' in r:
|
||||
with context.session.begin(subtransactions=True):
|
||||
with db_api.CONTEXT_WRITER.using(context):
|
||||
# check if route exists and have permission to access
|
||||
router_db = self._get_router(context, id)
|
||||
old_router = self._make_router_dict(router_db)
|
||||
@ -67,9 +68,6 @@ class ExtraRoute_dbonly_mixin(l3_db.L3_NAT_dbonly_mixin):
|
||||
context, request_body=router_data,
|
||||
states=(old_router,), resource_id=id,
|
||||
desired_state=router_db))
|
||||
# NOTE(yamamoto): expire to ensure the following update_router
|
||||
# see the effects of the above _update_extra_routes.
|
||||
context.session.expire(router_db, attribute_names=['route_list'])
|
||||
return super(ExtraRoute_dbonly_mixin, self).update_router(
|
||||
context, id, router)
|
||||
|
||||
|
@ -260,7 +260,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
||||
|
||||
def _update_router_db(self, context, router_id, data):
|
||||
"""Update the DB object."""
|
||||
with context.session.begin(subtransactions=True):
|
||||
with db_api.CONTEXT_WRITER.using(context):
|
||||
router_db = self._get_router(context, router_id)
|
||||
old_router = self._make_router_dict(router_db)
|
||||
if data:
|
||||
|
@ -73,7 +73,7 @@ class ServiceTypeManager(object):
|
||||
return {rec.resource_id: rec.provider_name for rec in objs}
|
||||
|
||||
def add_resource_association(self, context, service_type, provider_name,
|
||||
resource_id):
|
||||
resource_id, expire_session=True):
|
||||
r = self.get_service_providers(context,
|
||||
filters={'service_type': [service_type],
|
||||
'name': [provider_name]})
|
||||
@ -94,7 +94,10 @@ class ServiceTypeManager(object):
|
||||
# crawl through everything in the mapper to find the resource with
|
||||
# the ID that matches resource_id and expire that one, but we can
|
||||
# just start with this.
|
||||
context.session.expire_all()
|
||||
# NOTE(ralonsoh): to be removed once the new engine facade is fully
|
||||
# implanted in Neutron.
|
||||
if expire_session:
|
||||
context.session.expire_all()
|
||||
|
||||
def del_resource_associations(self, context, resource_ids):
|
||||
if not resource_ids:
|
||||
|
@ -170,7 +170,7 @@ class DriverController(object):
|
||||
payload.context, [payload.resource_id])
|
||||
self._stm.add_resource_association(
|
||||
payload.context, plugin_constants.L3,
|
||||
new_drv.name, payload.resource_id)
|
||||
new_drv.name, payload.resource_id, expire_session=False)
|
||||
registry.publish(
|
||||
resources.ROUTER_CONTROLLER,
|
||||
events.PRECOMMIT_ADD_ASSOCIATION,
|
||||
|
Loading…
Reference in New Issue
Block a user