From 050a3752b5164cc0ad78fa8d87b57777358c40e7 Mon Sep 17 00:00:00 2001 From: Jens Harbott Date: Thu, 9 Nov 2017 14:15:13 +0000 Subject: [PATCH] Show the correct ptr record instead of the first one Instead of calling _get_floatingip() and discarding its results, update the list of fips that we want to return accordingly. Change-Id: I05e8e2fb1677a4d53c4484cccec73b318a039007 Closes-Bug: 1731253 --- designate/central/service.py | 6 ++++-- designate/tests/test_central/test_service.py | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/designate/central/service.py b/designate/central/service.py index 95adcdf32..f938a6500 100644 --- a/designate/central/service.py +++ b/designate/central/service.py @@ -1982,10 +1982,12 @@ class Service(service.RPCService, service.Service): tenant_fips = self._list_floatingips(context, region=region) - self._get_floatingip(context, region, floatingip_id, tenant_fips) + fip = self._get_floatingip(context, region, floatingip_id, tenant_fips) + + result = self._list_to_dict([fip], keys=['region', 'id']) valid, invalid = self._determine_floatingips( - elevated_context, tenant_fips) + elevated_context, result) self._invalidate_floatingips(context, invalid) diff --git a/designate/tests/test_central/test_service.py b/designate/tests/test_central/test_service.py index 002c612bf..fdef66972 100644 --- a/designate/tests/test_central/test_service.py +++ b/designate/tests/test_central/test_service.py @@ -2325,6 +2325,20 @@ class CentralServiceTest(CentralTestCase): self.assertEqual(fip['address'], fip_ptr['address']) self.assertIsNone(fip_ptr['ptrdname']) + def test_get_floatingip_dual_no_record(self): + context = self.get_context(tenant='a') + + self.network_api.fake.allocate_floatingip(context.tenant) + fip = self.network_api.fake.allocate_floatingip(context.tenant) + + fip_ptr = self.central_service.get_floatingip( + context, fip['region'], fip['id']) + + self.assertEqual(fip['region'], fip_ptr['region']) + self.assertEqual(fip['id'], fip_ptr['id']) + self.assertEqual(fip['address'], fip_ptr['address']) + self.assertIsNone(fip_ptr['ptrdname']) + def test_get_floatingip_with_record(self): context = self.get_context(tenant='a')