diff --git a/neutron_vpnaas/db/vpn/vpn_db.py b/neutron_vpnaas/db/vpn/vpn_db.py index c4fae60d4..12c39c73a 100644 --- a/neutron_vpnaas/db/vpn/vpn_db.py +++ b/neutron_vpnaas/db/vpn/vpn_db.py @@ -668,6 +668,11 @@ class VPNPluginDb(vpnaas.VPNPluginBase, if query.first(): raise vpn_exception.EndpointGroupInUse(group_id=group_id) + def get_vpnservice_router_id(self, context, vpnservice_id): + with db_api.CONTEXT_READER.using(context): + vpnservice = self._get_vpnservice(context, vpnservice_id) + return vpnservice['router_id'] + class VPNPluginRpcDbMixin(object): def _build_local_subnet_cidr_map(self, context): diff --git a/neutron_vpnaas/services/vpn/service_drivers/base_ipsec.py b/neutron_vpnaas/services/vpn/service_drivers/base_ipsec.py index c7c3e883a..7f45b9a83 100644 --- a/neutron_vpnaas/services/vpn/service_drivers/base_ipsec.py +++ b/neutron_vpnaas/services/vpn/service_drivers/base_ipsec.py @@ -112,20 +112,20 @@ class BaseIPsecVPNDriver(service_drivers.VpnDriver, metaclass=abc.ABCMeta): pass def create_ipsec_site_connection(self, context, ipsec_site_connection): - vpnservice = self.service_plugin._get_vpnservice( + router_id = self.service_plugin.get_vpnservice_router_id( context, ipsec_site_connection['vpnservice_id']) - self.agent_rpc.vpnservice_updated(context, vpnservice['router_id']) + self.agent_rpc.vpnservice_updated(context, router_id) def update_ipsec_site_connection( self, context, old_ipsec_site_connection, ipsec_site_connection): - vpnservice = self.service_plugin._get_vpnservice( + router_id = self.service_plugin.get_vpnservice_router_id( context, ipsec_site_connection['vpnservice_id']) - self.agent_rpc.vpnservice_updated(context, vpnservice['router_id']) + self.agent_rpc.vpnservice_updated(context, router_id) def delete_ipsec_site_connection(self, context, ipsec_site_connection): - vpnservice = self.service_plugin._get_vpnservice( + router_id = self.service_plugin.get_vpnservice_router_id( context, ipsec_site_connection['vpnservice_id']) - self.agent_rpc.vpnservice_updated(context, vpnservice['router_id']) + self.agent_rpc.vpnservice_updated(context, router_id) def create_ikepolicy(self, context, ikepolicy): pass diff --git a/neutron_vpnaas/tests/unit/services/vpn/service_drivers/test_ipsec.py b/neutron_vpnaas/tests/unit/services/vpn/service_drivers/test_ipsec.py index fdc114da9..9c26db98c 100644 --- a/neutron_vpnaas/tests/unit/services/vpn/service_drivers/test_ipsec.py +++ b/neutron_vpnaas/tests/unit/services/vpn/service_drivers/test_ipsec.py @@ -98,9 +98,8 @@ class TestIPsecDriver(base.BaseTestCase): self.svc_plugin = mock.Mock() self.svc_plugin.get_l3_agents_hosting_routers.return_value = [l3_agent] self._fake_vpn_router_id = _uuid() - self.svc_plugin._get_vpnservice.return_value = { - 'router_id': self._fake_vpn_router_id - } + self.svc_plugin.get_vpnservice_router_id.return_value = \ + self._fake_vpn_router_id self.driver = ipsec_driver.IPsecVPNDriver(self.svc_plugin) self.validator = ipsec_validator.IpsecVpnValidator(self.driver) self.context = n_ctx.get_admin_context()