Skip to content

Commit

Permalink
Improve log
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Apr 21, 2020
1 parent 421770d commit 8eed618
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions IM/connectors/EC2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1335,18 +1335,19 @@ def delete_networks(self, conn, vm, timeout=240):

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 8eed618

Please sign in to comment.