mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-27 07:01:22 -07:00
Allowing the EC2 inventory script to gracefully handle AWS API issues
This commit is contained in:
parent
109632e3bc
commit
60c69e9845
1 changed files with 19 additions and 12 deletions
|
@ -236,6 +236,7 @@ class Ec2Inventory(object):
|
||||||
''' Makes an AWS EC2 API call to the list of instances in a particular
|
''' Makes an AWS EC2 API call to the list of instances in a particular
|
||||||
region '''
|
region '''
|
||||||
|
|
||||||
|
try:
|
||||||
if self.eucalyptus:
|
if self.eucalyptus:
|
||||||
conn = boto.connect_euca(host=self.eucalyptus_host)
|
conn = boto.connect_euca(host=self.eucalyptus_host)
|
||||||
conn.APIVersion = '2010-08-31'
|
conn.APIVersion = '2010-08-31'
|
||||||
|
@ -247,6 +248,12 @@ class Ec2Inventory(object):
|
||||||
for instance in reservation.instances:
|
for instance in reservation.instances:
|
||||||
self.add_instance(instance, region)
|
self.add_instance(instance, region)
|
||||||
|
|
||||||
|
except boto.exception.BotoServerError as e:
|
||||||
|
if not self.eucalyptus:
|
||||||
|
print "Looks like AWS is down again:"
|
||||||
|
print e
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def get_instance(self, region, instance_id):
|
def get_instance(self, region, instance_id):
|
||||||
''' Gets details about a specific instance '''
|
''' Gets details about a specific instance '''
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue