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
99122f06
Commit
99122f06
authored
Jan 13, 2014
by
John Jarvis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changing primary key to the ami-id
parent
d26380bf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
21 deletions
+17
-21
util/vpc-tools/abbey.py
+17
-21
No files found.
util/vpc-tools/abbey.py
View file @
99122f06
...
...
@@ -15,7 +15,7 @@ except ImportError:
sys
.
exit
(
1
)
from
pymongo
import
MongoClient
from
pymongo.errors
import
ConnectionFailure
from
pymongo.errors
import
ConnectionFailure
,
DuplicateKeyError
from
pprint
import
pprint
AMI_TIMEOUT
=
600
# time to wait for AMIs to complete
...
...
@@ -42,7 +42,15 @@ class MongoConnection:
self
.
mongo_deployment
=
getattr
(
mongo_db
,
args
.
mongo_deployment_collection
)
self
.
query
=
{
def
update_ami
(
self
,
ami
):
"""
Creates a new document in the AMI
collection with the ami id as the
id
"""
query
=
{
'_id'
:
ami
,
'play'
:
args
.
play
,
'env'
:
args
.
environment
,
'deployment'
:
args
.
deployment
,
...
...
@@ -50,18 +58,12 @@ class MongoConnection:
'configuration_secure_ref'
:
args
.
configuration_secure_version
,
'vars'
:
extra_vars
,
}
def
update_ami
(
self
,
status
,
ami
=
None
):
"""
Creates a new document in the AMI
or updates an existing one with a status
"""
update
=
self
.
query
.
copy
()
update
[
'status'
]
=
status
if
ami
:
update
[
'ami'
]
=
ami
self
.
mongo_ami
.
update
(
self
.
query
,
update
,
True
)
try
:
self
.
mongo_ami
.
insert
(
query
)
except
DuplicateKeyError
as
e
:
if
not
args
.
noop
:
print
"Entry already exists for {}"
.
format
(
ami
)
raise
def
update_deployment
(
self
,
ami
):
"""
...
...
@@ -592,7 +594,6 @@ if __name__ == '__main__':
if
args
.
mongo_host
:
mongo_con
=
MongoConnection
()
mongo_con
.
update_ami
(
status
=
'Generating'
)
try
:
sqs_queue
=
None
...
...
@@ -618,14 +619,9 @@ if __name__ == '__main__':
run
[
0
],
run
[
1
]
/
60
,
run
[
1
]
%
60
)
print
"AMI: {}"
.
format
(
ami
)
if
args
.
mongo_host
:
mongo_con
.
update_ami
(
status
=
'Completed'
,
ami
=
ami
)
mongo_con
.
update_ami
(
ami
)
mongo_con
.
update_deployment
(
ami
)
except
Exception
as
e
:
if
args
.
mongo_host
:
mongo_con
.
update_ami
(
status
=
'Error: {}'
.
format
(
e
.
message
))
raise
finally
:
print
if
not
args
.
no_cleanup
and
not
args
.
noop
:
...
...
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