Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
60c69e98
Commit
60c69e98
authored
Oct 22, 2012
by
Peter Sankauskas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allowing the EC2 inventory script to gracefully handle AWS API issues
parent
109632e3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
12 deletions
+19
-12
plugins/inventory/ec2.py
+19
-12
No files found.
plugins/inventory/ec2.py
View file @
60c69e98
...
...
@@ -181,9 +181,9 @@ class Ec2Inventory(object):
self
.
eucalyptus_host
=
None
self
.
eucalyptus
=
False
if
config
.
has_option
(
'ec2'
,
'eucalyptus'
):
self
.
eucalyptus
=
config
.
getboolean
(
'ec2'
,
'eucalyptus'
)
self
.
eucalyptus
=
config
.
getboolean
(
'ec2'
,
'eucalyptus'
)
if
self
.
eucalyptus
and
config
.
has_option
(
'ec2'
,
'eucalyptus_host'
):
self
.
eucalyptus_host
=
config
.
get
(
'ec2'
,
'eucalyptus_host'
)
self
.
eucalyptus_host
=
config
.
get
(
'ec2'
,
'eucalyptus_host'
)
# Regions
self
.
regions
=
[]
...
...
@@ -236,16 +236,23 @@ class Ec2Inventory(object):
''' Makes an AWS EC2 API call to the list of instances in a particular
region '''
if
self
.
eucalyptus
:
conn
=
boto
.
connect_euca
(
host
=
self
.
eucalyptus_host
)
conn
.
APIVersion
=
'2010-08-31'
else
:
conn
=
ec2
.
connect_to_region
(
region
)
reservations
=
conn
.
get_all_instances
()
for
reservation
in
reservations
:
for
instance
in
reservation
.
instances
:
self
.
add_instance
(
instance
,
region
)
try
:
if
self
.
eucalyptus
:
conn
=
boto
.
connect_euca
(
host
=
self
.
eucalyptus_host
)
conn
.
APIVersion
=
'2010-08-31'
else
:
conn
=
ec2
.
connect_to_region
(
region
)
reservations
=
conn
.
get_all_instances
()
for
reservation
in
reservations
:
for
instance
in
reservation
.
instances
:
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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment