From 2d68a0ed42d3eb3d6187fb5ae78b7b38001dcfdb Mon Sep 17 00:00:00 2001 From: Miguel Lavalle Date: Tue, 22 Sep 2015 17:22:31 -0500 Subject: [PATCH] Eliminate autoaddress check for DNS integration The autoaddress check for DNS integartion is not required anymore. It is removed from the DB plugin. This check was being performed to reflect incorrect functionality in the DHCP agent as indicated in bug https://bugs.launchpad.net/neutron/+bug/1498665 Change-Id: I4b00618c328567f998765ed9a023c4c50d950b2b Closes-Bug: #1497450 --- neutron/db/db_base_plugin_v2.py | 29 +++++++---------------- neutron/tests/unit/extensions/test_dns.py | 6 +++-- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/neutron/db/db_base_plugin_v2.py b/neutron/db/db_base_plugin_v2.py index 8fef9b36452..b93e89a27f7 100644 --- a/neutron/db/db_base_plugin_v2.py +++ b/neutron/db/db_base_plugin_v2.py @@ -1065,12 +1065,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, return port.get('dns_name', '') return '' - def _get_dns_names_for_port(self, context, network_id, ips, - request_dns_name): - filter = {'network_id': [network_id]} - subnets = self._get_subnets(context, filters=filter) - v6_subnets = {subnet['id']: subnet for subnet in subnets - if subnet['ip_version'] == 6} + def _get_dns_names_for_port(self, context, ips, request_dns_name): dns_assignment = [] dns_domain = self._get_dns_domain() if request_dns_name: @@ -1079,12 +1074,6 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, request_fqdn = '%s.%s' % (request_dns_name, dns_domain) for ip in ips: - subnet_id = ip['subnet_id'] - is_auto_address_subnet = ( - subnet_id in v6_subnets and - ipv6_utils.is_auto_address_subnet(v6_subnets[subnet_id])) - if is_auto_address_subnet: - continue if request_dns_name: hostname = request_dns_name fqdn = request_fqdn @@ -1169,7 +1158,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, dns_assignment = [] if ips: dns_assignment = self._get_dns_names_for_port( - context, network_id, ips, request_dns_name) + context, ips, request_dns_name) if 'dns_name' in p: db_port['dns_assignment'] = dns_assignment @@ -1191,16 +1180,16 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, self._check_mac_addr_update(context, db_port, new_mac, current_owner) - def _get_dns_names_for_updated_port(self, context, db_port, - original_ips, original_dns_name, - request_dns_name, changes): + def _get_dns_names_for_updated_port(self, context, original_ips, + original_dns_name, request_dns_name, + changes): if changes.original or changes.add or changes.remove: return self._get_dns_names_for_port( - context, db_port['network_id'], changes.original + changes.add, + context, changes.original + changes.add, request_dns_name or original_dns_name) if original_ips: return self._get_dns_names_for_port( - context, db_port['network_id'], original_ips, + context, original_ips, request_dns_name or original_dns_name) return [] @@ -1221,7 +1210,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, new_port, new_mac) if 'dns-integration' in self.supported_extension_aliases: dns_assignment = self._get_dns_names_for_updated_port( - context, port, original_ips, original_dns_name, + context, original_ips, original_dns_name, request_dns_name, changes) result = self._make_port_dict(port) # Keep up with fields that changed @@ -1255,7 +1244,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, def _get_dns_name_for_port_get(self, context, port): if port['fixed_ips']: return self._get_dns_names_for_port( - context, port['network_id'], port['fixed_ips'], + context, port['fixed_ips'], port['dns_name']) return [] diff --git a/neutron/tests/unit/extensions/test_dns.py b/neutron/tests/unit/extensions/test_dns.py index 797da83af57..683cb65b0b0 100644 --- a/neutron/tests/unit/extensions/test_dns.py +++ b/neutron/tests/unit/extensions/test_dns.py @@ -397,10 +397,12 @@ class DnsExtensionTestCase(test_db_base_plugin_v2.TestNetworksV2): self.assertEqual(1, addr_mode_count[constants.DHCPV6_STATEFUL]) self.assertEqual(2, addr_mode_count[constants.IPV6_SLAAC]) self._verify_dns_assigment(port['port'], exp_ips_ipv4=1, - exp_ips_ipv6=1, + exp_ips_ipv6=3, ipv4_cidrs=[sub_dicts[0]['cidr'], sub_dicts[1]['cidr']], - ipv6_cidrs=[sub_dicts[4]['cidr'], + ipv6_cidrs=[sub_dicts[2]['cidr'], + sub_dicts[3]['cidr'], + sub_dicts[4]['cidr'], sub_dicts[5]['cidr']], dns_name=dns_name) return res