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.

Conflicts:
	neutron/plugins/ml2/extensions/dns_integration.py

Change-Id: I622993fc273121bfd051d2fd9c7811e2ae49a1d8
Closes-Bug: 1714641
(cherry picked from commit 77a596ab7c)
This commit is contained in:
Jens Harbott 2017-09-02 08:00:51 +00:00 committed by garyk
parent 298f437be4
commit dd9deaf3a1
3 changed files with 6 additions and 6 deletions

View File

@ -433,7 +433,7 @@ def _delete_port_in_external_dns_service(resource, event, trigger, **kwargs):
if dns_data_db['current_dns_name']:
ip_allocations = context.session.query(
models_v2.IPAllocation).filter_by(port_id=port_id).all()
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)

View File

@ -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

View File

@ -116,10 +116,10 @@ class DNSIntegrationTestCase(test_plugin.Ml2PluginV2TestCase):
def _update_port_for_test(self, port, new_dns_name=NEWDNSNAME,
**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})