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:
parent
298f437be4
commit
dd9deaf3a1
|
@ -433,7 +433,7 @@ def _delete_port_in_external_dns_service(resource, event, trigger, **kwargs):
|
||||||
if dns_data_db['current_dns_name']:
|
if dns_data_db['current_dns_name']:
|
||||||
ip_allocations = context.session.query(
|
ip_allocations = context.session.query(
|
||||||
models_v2.IPAllocation).filter_by(port_id=port_id).all()
|
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(
|
_remove_data_from_external_dns_service(
|
||||||
context, dns_driver, dns_data_db['current_dns_domain'],
|
context, dns_driver, dns_data_db['current_dns_domain'],
|
||||||
dns_data_db['current_dns_name'], records)
|
dns_data_db['current_dns_name'], records)
|
||||||
|
|
|
@ -167,7 +167,7 @@ class Designate(driver.ExternalDNSService):
|
||||||
except d_exc.NotFound:
|
except d_exc.NotFound:
|
||||||
raise dns.DNSDomainNotFound(dns_domain=dns_domain)
|
raise dns.DNSDomainNotFound(dns_domain=dns_domain)
|
||||||
ids = [rec['id'] for rec in recordsets]
|
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):
|
if set(ips) != set(records):
|
||||||
raise dns.DuplicateRecordSet(dns_name=name)
|
raise dns.DuplicateRecordSet(dns_name=name)
|
||||||
return ids
|
return ids
|
||||||
|
|
|
@ -116,10 +116,10 @@ class DNSIntegrationTestCase(test_plugin.Ml2PluginV2TestCase):
|
||||||
def _update_port_for_test(self, port, new_dns_name=NEWDNSNAME,
|
def _update_port_for_test(self, port, new_dns_name=NEWDNSNAME,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
mock_client.reset_mock()
|
mock_client.reset_mock()
|
||||||
records_v4 = [ip['ip_address'] for ip in port['fixed_ips']
|
ip_addresses = [netaddr.IPAddress(ip['ip_address'])
|
||||||
if netaddr.IPAddress(ip['ip_address']).version == 4]
|
for ip in port['fixed_ips']]
|
||||||
records_v6 = [ip['ip_address'] for ip in port['fixed_ips']
|
records_v4 = [ip for ip in ip_addresses if ip.version == 4]
|
||||||
if netaddr.IPAddress(ip['ip_address']).version == 6]
|
records_v6 = [ip for ip in ip_addresses if ip.version == 6]
|
||||||
recordsets = []
|
recordsets = []
|
||||||
if records_v4:
|
if records_v4:
|
||||||
recordsets.append({'id': V4UUID, 'records': records_v4})
|
recordsets.append({'id': V4UUID, 'records': records_v4})
|
||||||
|
|
Loading…
Reference in New Issue