Rework delete_unattached_floating_ips function

The current version of delete_unattached_floating_ips was actually
broken. We were passing the incorrect paramaters. All 3 actually
didn't exist.  So we are dropping timeout, since delete_floating_ip()
doesn't support it and changing timeout to retries.

Change-Id: If6adc4b1a020ec1edec41d996ace87634303ea02
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
Paul Belanger 2016-05-18 19:10:45 -04:00
parent a1ab68cd2b
commit 58faf12cc2
No known key found for this signature in database
GPG Key ID: 611A80832067AF38
2 changed files with 7 additions and 6 deletions

View File

@ -3544,7 +3544,7 @@ class OpenStackCloud(object):
fip_id=floating_ip_id, msg=str(e)))
return True
def delete_unattached_floating_ips(self, wait=False, timeout=60):
def delete_unattached_floating_ips(self, retry=1):
"""Safely delete unattached floating ips.
If the cloud can safely purge any unattached floating ips without
@ -3557,8 +3557,10 @@ class OpenStackCloud(object):
process is using add_auto_ip from shade, or is creating the floating
IPs by passing in a server to the create_floating_ip call.
:param wait: Whether to wait for each IP to be deleted
:param timeout: How long to wait for each IP
:param retry: number of times to retry. Optional, defaults to 1,
which is in addition to the initial delete call.
A value of 0 will also cause no checking of results to
occur.
:returns: True if Floating IPs have been deleted, False if not
@ -3569,7 +3571,7 @@ class OpenStackCloud(object):
for ip in self.list_floating_ips():
if not ip['attached']:
processed.append(self.delete_floating_ip(
id=ip['id'], wait=wait, timeout=timeout))
floating_ip_id=ip['id'], retry=retry))
return all(processed) if processed else False
def _attach_ip_to_server(

View File

@ -565,8 +565,7 @@ class TestFloatingIP(base.TestCase):
self.client.delete_unattached_floating_ips()
mock_delete_floating_ip.assert_called_once_with(
id="this-is-a-floating-ip-id",
timeout=60, wait=False)
floating_ip_id='this-is-a-floating-ip-id', retry=1)
@patch.object(OpenStackCloud, '_submit_create_fip')
@patch.object(OpenStackCloud, '_get_free_fixed_port')