From 694c84c61b4fb9124a37414ed8afdca6bb8c518a Mon Sep 17 00:00:00 2001 From: elajkat Date: Fri, 9 Sep 2022 21:27:19 +0200 Subject: [PATCH] Adopt to oslo.db 12.1.0 Change-Id: Ic166fd810b1e49ac02d32921a6294e5f3c758489 --- neutron_vpnaas/services/vpn/service_drivers/base_ipsec.py | 2 ++ neutron_vpnaas/tests/unit/db/vpn/test_vpn_db.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/neutron_vpnaas/services/vpn/service_drivers/base_ipsec.py b/neutron_vpnaas/services/vpn/service_drivers/base_ipsec.py index 7f45b9a83..0f09260dd 100644 --- a/neutron_vpnaas/services/vpn/service_drivers/base_ipsec.py +++ b/neutron_vpnaas/services/vpn/service_drivers/base_ipsec.py @@ -20,6 +20,7 @@ import oslo_messaging from neutron.db.models import l3agent from neutron.db.models import servicetype from neutron_lib import constants as lib_constants +from neutron_lib.db import api as db_api from neutron_lib.plugins import directory from neutron_vpnaas.db.vpn import vpn_models @@ -70,6 +71,7 @@ class IPsecVpnDriverCallBack(object): self.driver.name) return query + @db_api.CONTEXT_READER def get_vpn_services_on_host(self, context, host=None): """Returns the vpnservices on the host.""" vpnservices = self._get_agent_hosting_vpn_services( diff --git a/neutron_vpnaas/tests/unit/db/vpn/test_vpn_db.py b/neutron_vpnaas/tests/unit/db/vpn/test_vpn_db.py index d763b45ac..b0ab5dc96 100644 --- a/neutron_vpnaas/tests/unit/db/vpn/test_vpn_db.py +++ b/neutron_vpnaas/tests/unit/db/vpn/test_vpn_db.py @@ -32,6 +32,7 @@ from neutron_lib.api.definitions import vpn from neutron_lib.callbacks import events from neutron_lib import constants as lib_constants from neutron_lib import context +from neutron_lib.db import api as db_api from neutron_lib.exceptions import l3 as l3_exception from neutron_lib.exceptions import vpn as vpn_exception from neutron_lib.plugins import constants as nconstants @@ -423,7 +424,7 @@ class VPNTestMixin(object): def _set_active(self, model, resource_id): service_plugin = directory.get_plugin(nconstants.VPN) adminContext = context.get_admin_context() - with adminContext.session.begin(subtransactions=True): + with db_api.CONTEXT_WRITER.using(adminContext): resource_db = service_plugin._get_resource( adminContext, model,