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
77a2ad0e
Commit
77a2ad0e
authored
Jun 14, 2015
by
Victor Schröder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improves code organization in get_dict_from_describe_dict method
parent
41b034a5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
plugins/inventory/ec2.py
+22
-0
No files found.
plugins/inventory/ec2.py
View file @
77a2ad0e
...
...
@@ -1087,12 +1087,18 @@ class Ec2Inventory(object):
key
=
self
.
to_safe
(
'ec2_'
+
self
.
uncammelize
(
key
))
# Handle complex types
# Target: Memcached Cache Clusters
if
key
==
'ec2_configuration_endpoint'
and
value
:
host_info
[
'ec2_configuration_endpoint_address'
]
=
value
[
'Address'
]
host_info
[
'ec2_configuration_endpoint_port'
]
=
value
[
'Port'
]
# Target: Cache Nodes and Redis Cache Clusters (single node)
if
key
==
'ec2_endpoint'
and
value
:
host_info
[
'ec2_endpoint_address'
]
=
value
[
'Address'
]
host_info
[
'ec2_endpoint_port'
]
=
value
[
'Port'
]
# Target: Redis Replication Groups
if
key
==
'ec2_node_groups'
and
value
:
host_info
[
'ec2_endpoint_address'
]
=
value
[
0
][
'PrimaryEndpoint'
][
'Address'
]
host_info
[
'ec2_endpoint_port'
]
=
value
[
0
][
'PrimaryEndpoint'
][
'Port'
]
...
...
@@ -1107,25 +1113,41 @@ class Ec2Inventory(object):
host_info
[
'ec2_replica_cluster_port_'
+
str
(
replica_count
)]
=
node
[
'ReadEndpoint'
][
'Port'
]
host_info
[
'ec2_replica_cluster_id_'
+
str
(
replica_count
)]
=
node
[
'CacheClusterId'
]
replica_count
+=
1
# Target: Redis Replication Groups
if
key
==
'ec2_member_clusters'
and
value
:
host_info
[
'ec2_member_clusters'
]
=
','
.
join
([
str
(
i
)
for
i
in
value
])
# Target: All Cache Clusters
elif
key
==
'ec2_cache_parameter_group'
:
host_info
[
"ec2_cache_node_ids_to_reboot"
]
=
','
.
join
([
str
(
i
)
for
i
in
value
[
'CacheNodeIdsToReboot'
]])
host_info
[
'ec2_cache_parameter_group_name'
]
=
value
[
'CacheParameterGroupName'
]
host_info
[
'ec2_cache_parameter_apply_status'
]
=
value
[
'ParameterApplyStatus'
]
# Target: Almost everything
elif
key
==
'ec2_security_groups'
:
sg_ids
=
[]
for
sg
in
value
:
sg_ids
.
append
(
sg
[
'SecurityGroupId'
])
host_info
[
"ec2_security_group_ids"
]
=
','
.
join
([
str
(
i
)
for
i
in
sg_ids
])
# Target: Everything
# Preserve booleans and integers
elif
type
(
value
)
in
[
int
,
bool
]:
host_info
[
key
]
=
value
# Target: Everything
# Sanitize string values
elif
isinstance
(
value
,
six
.
string_types
):
host_info
[
key
]
=
value
.
strip
()
# Target: Everything
# Replace None by an empty string
elif
type
(
value
)
==
type
(
None
):
host_info
[
key
]
=
''
else
:
# Remove non-processed complex types
pass
return
host_info
...
...
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