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
c18f6cae
Commit
c18f6cae
authored
Jun 14, 2015
by
Victor Schröder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Creates get_elasticache_replication_groups_by_region method to handle the API call
parent
40ce0727
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
plugins/inventory/ec2.py
+35
-0
No files found.
plugins/inventory/ec2.py
View file @
c18f6cae
...
...
@@ -366,6 +366,7 @@ class Ec2Inventory(object):
self
.
get_rds_instances_by_region
(
region
)
if
self
.
elasticache_enabled
:
self
.
get_elasticache_clusters_by_region
(
region
)
self
.
get_elasticache_replication_groups_by_region
(
region
)
self
.
write_to_cache
(
self
.
inventory
,
self
.
cache_path_cache
)
self
.
write_to_cache
(
self
.
index
,
self
.
cache_path_index
)
...
...
@@ -462,6 +463,40 @@ class Ec2Inventory(object):
for
cluster
in
clusters
:
self
.
add_elasticache_cluster
(
cluster
,
region
)
def
get_elasticache_replication_groups_by_region
(
self
,
region
):
''' Makes an AWS API call to the list of ElastiCache replication groups
in a particular region.'''
# ElastiCache boto module doesn't provide a get_all_intances method,
# that's why we need to call describe directly (it would be called by
# the shorthand method anyway...)
try
:
conn
=
elasticache
.
connect_to_region
(
region
)
if
conn
:
response
=
conn
.
describe_replication_groups
()
except
boto
.
exception
.
BotoServerError
as
e
:
error
=
e
.
reason
if
e
.
error_code
==
'AuthFailure'
:
error
=
self
.
get_auth_error_message
()
if
not
e
.
reason
==
"Forbidden"
:
error
=
"Looks like AWS RDS is down:
\n
%
s"
%
e
.
message
self
.
fail_with_error
(
error
)
try
:
# Boto also doesn't provide wrapper classes to ReplicationGroups
# Because of that wo can't make use of the get_list method in the
# AWSQueryConnection. Let's do the work manually
replication_groups
=
response
[
'DescribeReplicationGroupsResponse'
][
'DescribeReplicationGroupsResult'
][
'ReplicationGroups'
]
except
KeyError
as
e
:
error
=
"ElastiCache query to AWS failed (unexpected format)."
self
.
fail_with_error
(
error
)
for
replication_group
in
replication_groups
:
self
.
add_elasticache_replication_group
(
replication_group
,
region
)
def
get_auth_error_message
(
self
):
''' create an informative error message if there is an issue authenticating'''
errors
=
[
"Authentication error retrieving ec2 inventory."
]
...
...
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