Skip to content

Commit

Permalink
Remove disconnected IPs: #957
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Dec 12, 2019
1 parent d65a361 commit 90e2462
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion IM/connectors/OpenStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,14 @@ def setIPsFromInstance(self, vm, node):
- node(:py:class:`libcloud.compute.base.Node`): object to connect to EC2 instance.
"""

# First remove old
system = vm.info.systems[0]
cont = 0
while system.getValue('net_interface.%d.connection' % cont):
if system.getValue('net_interface.%d.ip' % cont):
system.delValue('net_interface.%d.ip' % cont)
cont += 1

if 'addresses' in node.extra:
public_ips = []
ip_net_map = {}
Expand All @@ -481,7 +489,6 @@ def setIPsFromInstance(self, vm, node):

map_nets = self.map_radl_ost_networks(vm, ip_net_map)

system = vm.info.systems[0]
i = 0
ips_assigned = []
while system.getValue("net_interface." + str(i) + ".connection"):
Expand Down Expand Up @@ -1622,6 +1629,19 @@ def alter_public_ips(self, vm, radl, auth_data):
nets_id = [net.id for net in vm.requested_radl.networks if net.isPublic()]
system = vm.requested_radl.systems[0]

i = 0
while system.getValue('net_interface.%d.connection' % i):
f = system.getFeature("net_interface.%d.connection" % i)
if f.value in nets_id:
system.delValue('net_interface.%d.connection' % i)
if system.getValue('net_interface.%d.ip' % i):
system.delValue('net_interface.%d.ip' % i)
i += 1

# Also remove them from the info RADL
nets_id = [net.id for net in vm.info.networks if net.isPublic()]
system = vm.info.systems[0]

i = 0
while system.getValue('net_interface.%d.connection' % i):
f = system.getFeature("net_interface.%d.connection" % i)
Expand Down

0 comments on commit 90e2462

Please sign in to comment.