Merge "Only try to delete floating ip if the server has it"

This commit is contained in:
Jenkins 2016-02-24 21:01:59 +00:00 committed by Gerrit Code Review
commit b2f9546dcf
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' %