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
This commit is contained in:
Jens Harbott 2017-11-09 14:15:13 +00:00
parent 0ab0d5b1cf
commit 050a3752b5
2 changed files with 18 additions and 2 deletions

View File

@ -1982,10 +1982,12 @@ class Service(service.RPCService, service.Service):
tenant_fips = self._list_floatingips(context, region=region) 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( valid, invalid = self._determine_floatingips(
elevated_context, tenant_fips) elevated_context, result)
self._invalidate_floatingips(context, invalid) self._invalidate_floatingips(context, invalid)

View File

@ -2325,6 +2325,20 @@ class CentralServiceTest(CentralTestCase):
self.assertEqual(fip['address'], fip_ptr['address']) self.assertEqual(fip['address'], fip_ptr['address'])
self.assertIsNone(fip_ptr['ptrdname']) 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): def test_get_floatingip_with_record(self):
context = self.get_context(tenant='a') context = self.get_context(tenant='a')