Fix port deletion when dns_integration is enabled

The records found in ip_allocations contain objects of type IPAddress,
but the external dns service expects them as string, so we need to
insert a conversion.

Change-Id: I622993fc273121bfd051d2fd9c7811e2ae49a1d8
Closes-Bug: 1714641
changes/61/500261/2
Jens Harbott 5 years ago
parent abdec27573
commit 22d6a1540f
  1. 2
      neutron/plugins/ml2/extensions/dns_integration.py
  2. 2
      neutron/services/externaldns/drivers/designate/driver.py
  3. 8
      neutron/tests/unit/plugins/ml2/extensions/test_dns_integration.py

@ -510,7 +510,7 @@ def _delete_port_in_external_dns_service(resource, event, trigger, **kwargs):
if dns_data_db['current_dns_name']:
ip_allocations = port_obj.IPAllocation.get_objects(context,
port_id=port_id)
records = [alloc['ip_address'] for alloc in ip_allocations]
records = [str(alloc['ip_address']) for alloc in ip_allocations]
_remove_data_from_external_dns_service(
context, dns_driver, dns_data_db['current_dns_domain'],
dns_data_db['current_dns_name'], records)

@ -167,7 +167,7 @@ class Designate(driver.ExternalDNSService):
except d_exc.NotFound:
raise dns.DNSDomainNotFound(dns_domain=dns_domain)
ids = [rec['id'] for rec in recordsets]
ips = [ip for rec in recordsets for ip in rec['records']]
ips = [str(ip) for rec in recordsets for ip in rec['records']]
if set(ips) != set(records):
raise dns.DuplicateRecordSet(dns_name=name)
return ids

@ -123,10 +123,10 @@ class DNSIntegrationTestCase(test_plugin.Ml2PluginV2TestCase):
def _update_port_for_test(self, port, new_dns_name=NEWDNSNAME,
new_dns_domain=None, **kwargs):
mock_client.reset_mock()
records_v4 = [ip['ip_address'] for ip in port['fixed_ips']
if netaddr.IPAddress(ip['ip_address']).version == 4]
records_v6 = [ip['ip_address'] for ip in port['fixed_ips']
if netaddr.IPAddress(ip['ip_address']).version == 6]
ip_addresses = [netaddr.IPAddress(ip['ip_address'])
for ip in port['fixed_ips']]
records_v4 = [ip for ip in ip_addresses if ip.version == 4]
records_v6 = [ip for ip in ip_addresses if ip.version == 6]
recordsets = []
if records_v4:
recordsets.append({'id': V4UUID, 'records': records_v4})

Loading…
Cancel
Save