Only try to delete floating ip if the server has it

Newer clouds are always going to return true for has-extension
os-floating-ips because nova has moved to microversions and away from
extension lists.

Change-Id: I0232db76216468ca9b56343501d02902aaa21963
This commit is contained in:
Monty Taylor 2016-02-17 14:31:53 +00:00
parent da12dbe845
commit c8acf554e9
1 changed files with 9 additions and 1 deletions

View File

@ -632,7 +632,15 @@ class ProviderManager(TaskManager):
# This will either get the server or raise an exception
server = self.getServerFromList(server_id)
if self.hasExtension('os-floating-ips'):
has_floating_ip = False
for (name, network) in server['addresses'].iteritems():
for interface_spec in network:
if interface_spec['version'] != 4:
continue
if ('OS-EXT-IPS:type' in interface_spec
and interface_spec['OS-EXT-IPS:type'] == 'floating'):
has_floating_ip = True
if has_floating_ip:
for ip in self.listFloatingIPs():
if ip['instance_id'] == server_id:
self.log.debug('Deleting floating ip for server %s' %