1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

added error checking around boto ec2 connection errors when using a bad region name

This commit is contained in:
jclaybaugh 2013-06-07 18:13:22 +00:00
parent e204394c2c
commit 4733dc6b5b

View file

@ -244,7 +244,11 @@ class Ec2Inventory(object):
conn.APIVersion = '2010-08-31' conn.APIVersion = '2010-08-31'
else: else:
conn = ec2.connect_to_region(region) conn = ec2.connect_to_region(region)
if conn is None:
print("AWS is down or region name: %s likely not supported. connection to region failed." % region)
sys.exit(1)
reservations = conn.get_all_instances() reservations = conn.get_all_instances()
for reservation in reservations: for reservation in reservations:
for instance in reservation.instances: for instance in reservation.instances:
@ -279,6 +283,10 @@ class Ec2Inventory(object):
else: else:
conn = ec2.connect_to_region(region) conn = ec2.connect_to_region(region)
if conn is None:
print("AWS is down or region name: %s likely not supported. connection to region failed." % region)
sys.exit(1)
reservations = conn.get_all_instances([instance_id]) reservations = conn.get_all_instances([instance_id])
for reservation in reservations: for reservation in reservations:
for instance in reservation.instances: for instance in reservation.instances: