Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
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
configuration
Commits
82d358f5
Commit
82d358f5
authored
Aug 14, 2014
by
e0d
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial working version
parent
b9feb57a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
playbooks/edx-east/lifecycle_inventory.py
+58
-0
No files found.
playbooks/edx-east/lifecycle_inventory.py
0 → 100755
View file @
82d358f5
#!/usr/bin/env python
import
argparse
import
boto
import
json
class
LifecycleInventory
():
profile
=
None
def
__init__
(
self
):
parser
=
argparse
.
ArgumentParser
()
group
=
parser
.
add_argument_group
()
group
.
add_argument
(
'-p'
,
'--profile'
,
help
=
'The aws profile to use when connecting.'
)
args
=
parser
.
parse_args
()
self
.
profile
=
args
.
profile
self
.
run
()
def
push
(
self
,
the_dict
,
key
,
element
):
if
key
in
the_dict
:
the_dict
[
key
]
.
append
(
element
);
else
:
the_dict
[
key
]
=
[
element
]
def
get_instance_dict
(
self
):
ec2
=
boto
.
connect_ec2
(
profile_name
=
self
.
profile
)
reservations
=
ec2
.
get_all_instances
()
dict
=
{}
for
instance
in
[
i
for
r
in
reservations
for
i
in
r
.
instances
]:
dict
[
instance
.
id
]
=
instance
return
dict
def
run
(
self
):
autoscale
=
boto
.
connect_autoscale
(
profile_name
=
self
.
profile
)
groups
=
autoscale
.
get_all_groups
()
instances
=
self
.
get_instance_dict
()
inventory
=
{}
for
group
in
groups
:
for
instance
in
group
.
instances
:
private_ip_address
=
instances
[
instance
.
instance_id
]
.
private_ip_address
self
.
push
(
inventory
,
group
.
name
,
private_ip_address
)
self
.
push
(
inventory
,
group
.
name
+
"_"
+
instance
.
lifecycle_state
,
private_ip_address
)
self
.
push
(
inventory
,
instance
.
lifecycle_state
,
private_ip_address
)
print
json
.
dumps
(
inventory
,
sort_keys
=
True
,
indent
=
2
)
LifecycleInventory
()
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