From 3233918e305104fda05afce5f6c8313de0299d8c Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 25 Jan 2016 21:55:40 +0900 Subject: [PATCH] l3_db: Check dns-integration extension Do not call methods from DNSDbMixin unless the extension is supported. Closes-Bug: #1537746 Change-Id: I72f4ae947cb3f58938c75691a4d7da8d6203466f --- neutron/db/l3_db.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/neutron/db/l3_db.py b/neutron/db/l3_db.py index 75f6bb87768..0656f371a83 100644 --- a/neutron/db/l3_db.py +++ b/neutron/db/l3_db.py @@ -1031,6 +1031,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase): msg = _("Network %s does not contain any IPv4 subnet") % f_net_id raise n_exc.BadRequest(resource='floatingip', msg=msg) + dns_integration = utils.is_extension_supported(self, 'dns-integration') with context.session.begin(subtransactions=True): # This external port is never exposed to the tenant. # it is used purely for internal system and admin use when @@ -1078,12 +1079,14 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase): context.session.add(floatingip_db) floatingip_dict = self._make_floatingip_dict( floatingip_db, process_extensions=False) - dns_actions_data = self._process_dns_floatingip_create_precommit( - context, floatingip_dict, fip) + if dns_integration: + dns_data = self._process_dns_floatingip_create_precommit( + context, floatingip_dict, fip) - self._process_dns_floatingip_create_postcommit(context, - floatingip_dict, - dns_actions_data) + if dns_integration: + self._process_dns_floatingip_create_postcommit(context, + floatingip_dict, + dns_data) return floatingip_dict def create_floatingip(self, context, floatingip, @@ -1092,6 +1095,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase): def _update_floatingip(self, context, id, floatingip): fip = floatingip['floatingip'] + dns_integration = utils.is_extension_supported(self, 'dns-integration') with context.session.begin(subtransactions=True): floatingip_db = self._get_floatingip(context, id) old_floatingip = self._make_floatingip_dict(floatingip_db) @@ -1102,11 +1106,13 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase): self._core_plugin.get_port( context.elevated(), fip_port_id)) floatingip_dict = self._make_floatingip_dict(floatingip_db) - dns_actions_data = self._process_dns_floatingip_update_precommit( - context, floatingip_dict) - self._process_dns_floatingip_update_postcommit(context, - floatingip_dict, - dns_actions_data) + if dns_integration: + dns_data = self._process_dns_floatingip_update_precommit( + context, floatingip_dict) + if dns_integration: + self._process_dns_floatingip_update_postcommit(context, + floatingip_dict, + dns_data) return old_floatingip, floatingip_dict def _floatingips_to_router_ids(self, floatingips): @@ -1128,7 +1134,8 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase): def _delete_floatingip(self, context, id): floatingip = self._get_floatingip(context, id) floatingip_dict = self._make_floatingip_dict(floatingip) - self._process_dns_floatingip_delete(context, floatingip_dict) + if utils.is_extension_supported(self, 'dns-integration'): + self._process_dns_floatingip_delete(context, floatingip_dict) # Foreign key cascade will take care of the removal of the # floating IP record once the port is deleted. We can't start # a transaction first to remove it ourselves because the delete_port