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
6d57736b
Commit
6d57736b
authored
Apr 27, 2016
by
Max Rothman
Committed by
Feanil Patel
May 02, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make pre_supervisor_checks.py region-aware (#2989)
parent
8a29daf9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
playbooks/roles/supervisor/files/pre_supervisor_checks.py
+6
-5
No files found.
playbooks/roles/supervisor/files/pre_supervisor_checks.py
View file @
6d57736b
import
argparse
import
boto
from
boto.utils
import
get_instance_metadata
from
boto.utils
import
get_instance_metadata
,
get_instance_identity
from
boto.exception
import
AWSConnectionError
import
hipchat
import
os
...
...
@@ -27,12 +27,14 @@ HIPCHAT_USER = "PreSupervisor"
MAX_BACKOFF
=
120
INITIAL_BACKOFF
=
1
REGION
=
get_instance_identity
()[
'document'
][
'region'
]
def
services_for_instance
(
instance_id
):
"""
Get the list of all services named by the services tag in this
instance's tags.
"""
ec2
=
boto
.
connect_ec2
(
)
ec2
=
boto
.
ec2
.
connect_to_region
(
REGION
)
reservations
=
ec2
.
get_all_instances
(
instance_ids
=
[
instance_id
])
for
reservation
in
reservations
:
for
instance
in
reservation
.
instances
:
...
...
@@ -47,7 +49,7 @@ def services_for_instance(instance_id):
yield
service
def
edp_for_instance
(
instance_id
):
ec2
=
boto
.
connect_ec2
(
)
ec2
=
boto
.
ec2
.
connect_to_region
(
REGION
)
reservations
=
ec2
.
get_all_instances
(
instance_ids
=
[
instance_id
])
for
reservation
in
reservations
:
for
instance
in
reservation
.
instances
:
...
...
@@ -164,8 +166,7 @@ if __name__ == '__main__':
instance_id
=
get_instance_metadata
()[
'instance-id'
]
prefix
=
instance_id
ec2
=
boto
.
connect_ec2
()
ec2
=
boto
.
ec2
.
connect_to_region
(
REGION
)
reservations
=
ec2
.
get_all_instances
(
instance_ids
=
[
instance_id
])
instance
=
reservations
[
0
]
.
instances
[
0
]
if
instance
.
instance_profile
[
'arn'
]
.
endswith
(
'/abbey'
):
...
...
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