Skip to content

Commit

Permalink
Delete all the sgs: #690
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Nov 20, 2018
1 parent 9c040dd commit 20f0c4a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions IM/connectors/EC2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1318,9 +1318,12 @@ def _get_security_groups(self, conn, vm):
"""
Get all the SGs where the VM is included
"""
sg_names = ["im-%s" % str(vm.inf.id)]
for net in vm.inf.radl.networks:
sg_names.append("im-%s-%s" % (str(vm.inf.id), net.id))

sgs = []
for net in vm.info.networks:
sg_name = "im-%s-%s" % (str(vm.inf.id), net.id)
for sg_name in sg_names:
try:
sgs.extend(conn.get_all_security_groups(filters={'group-name': sg_name}))
except Exception:
Expand Down
4 changes: 3 additions & 1 deletion IM/connectors/OpenStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,9 +984,11 @@ def delete_security_groups(self, driver, inf, timeout=180, delay=10):
"""
Delete the SG of this inf
"""
sg_names = ["im-%s" % str(inf.id)]
for net in inf.radl.networks:
sg_name = "im-%s-%s" % (str(inf.id), net.id)
sg_names.append("im-%s-%s" % (str(inf.id), net.id))

for sg_name in sg_names:
# wait it to terminate and then remove the SG
cont = 0
deleted = False
Expand Down

0 comments on commit 20f0c4a

Please sign in to comment.