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
edx
configuration
Commits
4960a6b1
Commit
4960a6b1
authored
May 16, 2016
by
Kevin Falcone
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3022 from edx/jibsheet/region-aware-lifecycle-watcher
Jibsheet/region aware lifecycle watcher
parents
b3c74b47
71e6708f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
11 deletions
+18
-11
playbooks/edx-east/lifecycle_inventory.py
+7
-6
util/vpc-tools/asg_lifcycle_watcher.py
+11
-5
No files found.
playbooks/edx-east/lifecycle_inventory.py
View file @
4960a6b1
...
...
@@ -30,8 +30,10 @@ group and state.
"""
import
argparse
import
boto
import
boto.ec2.autoscale
import
json
from
collections
import
defaultdict
from
os
import
environ
class
LifecycleInventory
():
...
...
@@ -54,7 +56,7 @@ class LifecycleInventory():
return
environment
,
deployment
def
get_instance_dict
(
self
):
ec2
=
boto
.
connect_ec2
(
profile_name
=
self
.
profile
)
ec2
=
boto
.
ec2
.
connect_to_region
(
region
,
profile_name
=
self
.
profile
)
reservations
=
ec2
.
get_all_instances
()
dict
=
{}
...
...
@@ -65,8 +67,8 @@ class LifecycleInventory():
return
dict
def
run
(
self
):
a
utoscale
=
boto
.
connect_autoscale
(
profile_name
=
self
.
profile
)
groups
=
a
utoscale
.
get_all_groups
()
a
sg
=
boto
.
ec2
.
autoscale
.
connect_to_region
(
region
,
profile_name
=
self
.
profile
)
groups
=
a
sg
.
get_all_groups
()
instances
=
self
.
get_instance_dict
()
inventory
=
defaultdict
(
list
)
...
...
@@ -92,7 +94,6 @@ if __name__=="__main__":
parser
.
add_argument
(
'-l'
,
'--list'
,
help
=
'Ansible passes this, we ignore it.'
,
action
=
'store_true'
,
default
=
True
)
args
=
parser
.
parse_args
()
LifecycleInventory
(
args
.
profile
)
.
run
()
region
=
environ
.
get
(
'AWS_REGION'
,
'us-east-1'
)
LifecycleInventory
(
args
.
profile
)
.
run
()
util/vpc-tools/asg_lifcycle_watcher.py
View file @
4960a6b1
...
...
@@ -18,6 +18,8 @@ It relies on some component applying the proper tags and performing pre-retireme
import
argparse
import
boto
import
boto.ec2
import
boto.sqs
import
json
import
subprocess
from
boto.sqs.message
import
RawMessage
...
...
@@ -44,15 +46,19 @@ class LifecycleHandler:
os
.
environ
[
"PATH"
]
=
bin_directory
+
os
.
pathsep
+
os
.
environ
[
"PATH"
]
self
.
aws_bin
=
spawn
.
find_executable
(
'aws'
)
self
.
python_bin
=
spawn
.
find_executable
(
'python'
)
self
.
region
=
os
.
environ
.
get
(
'AWS_REGION'
,
'us-east-1'
)
self
.
base_cli_command
=
"{python_bin} {aws_bin}
--profile {profile}
"
.
format
(
self
.
base_cli_command
=
"{python_bin} {aws_bin} "
.
format
(
python_bin
=
self
.
python_bin
,
aws_bin
=
self
.
aws_bin
,
profile
=
self
.
profile
)
aws_bin
=
self
.
aws_bin
)
if
self
.
profile
:
self
.
base_cli_command
+=
"--profile {profile} "
.
format
(
profile
=
self
.
profile
)
if
self
.
region
:
self
.
base_cli_command
+=
"--region {region} "
.
format
(
region
=
self
.
region
)
self
.
dry_run
=
dry_run
self
.
ec2_con
=
boto
.
connect_ec2
(
)
self
.
sqs_con
=
boto
.
connect_sqs
(
)
self
.
ec2_con
=
boto
.
ec2
.
connect_to_region
(
self
.
region
)
self
.
sqs_con
=
boto
.
sqs
.
connect_to_region
(
self
.
region
)
def
process_lifecycle_messages
(
self
):
queue
=
self
.
sqs_con
.
get_queue
(
self
.
queue
)
...
...
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