Skip to content

Commit

Permalink
Merge pull request #1026 from grycap/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
micafer authored Apr 21, 2020
2 parents 0cfcf5b + 8eed618 commit 4e7598e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions IM/connectors/EC2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ def cancel_spot_requests(self, conn, vm):
self.log_info("Spot instance request " + str(sir.id) + " deleted")
break

def delete_networks(self, conn, vm, timeout=120):
def delete_networks(self, conn, vm, timeout=240):
"""
Delete the created networks
"""
Expand All @@ -1331,22 +1331,23 @@ def delete_networks(self, conn, vm, timeout=120):
time.sleep(5)

if not deleted:
self.log_error("Timeout (%s) removing the volume %s" % (timeout, subnet.id))
self.log_error("Timeout (%s) deleting the subnet %s" % (timeout, subnet.id))

vpc_id = None
for vpc in conn.get_all_vpcs(filters={"tag:IM-INFRA-ID": vm.inf.id}):
self.log_info("Deleting vpc: %s" % vpc.id)
vpc_id = vpc.id
ig_id = None
for ig in conn.get_all_internet_gateways(filters={"tag:IM-INFRA-ID": vm.inf.id}):
self.log_info("Deleting Internet Gateway: %s" % ig.id)
ig_id = ig.id

if ig_id and vpc_id:
self.log_info("Detacching Internet Gateway: %s from VPC: %s" % (ig_id, vpc_id))
conn.detach_internet_gateway(ig_id, vpc_id)
if ig_id:
self.log_info("Deleting Internet Gateway: %s" % ig.id)
conn.delete_internet_gateway(ig_id)
if vpc_id:
self.log_info("Deleting vpc: %s" % vpc.id)
conn.delete_vpc(vpc_id)

def finalize(self, vm, last, auth_data):
Expand Down

0 comments on commit 4e7598e

Please sign in to comment.