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
f0ed7375
Commit
f0ed7375
authored
11 years ago
by
Feanil Patel
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #672 from edx/feanil/abbey_keyerror
Feanil/abbey keyerror
parents
a9153e12
61412ce1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
53 deletions
+61
-53
util/vpc-tools/abbey.py
+61
-53
No files found.
util/vpc-tools/abbey.py
View file @
f0ed7375
...
...
@@ -407,60 +407,68 @@ def poll_sqs_ansible():
now
=
int
(
time
.
time
())
if
buf
:
if
(
now
-
max
([
msg
[
'recv_ts'
]
for
msg
in
buf
]))
>
args
.
msg_delay
:
# sort by TS instead of recv_ts
# because the sqs timestamp is not as
# accurate
buf
.
sort
(
key
=
lambda
k
:
k
[
'msg'
][
'TS'
])
to_disp
=
buf
.
pop
(
0
)
if
'START'
in
to_disp
[
'msg'
]:
print
'
\n
{:0>2.0f}:{:0>5.2f} {} : Starting "{}"'
.
format
(
to_disp
[
'msg'
][
'TS'
]
/
60
,
to_disp
[
'msg'
][
'TS'
]
%
60
,
to_disp
[
'msg'
][
'PREFIX'
],
to_disp
[
'msg'
][
'START'
]),
elif
'TASK'
in
to_disp
[
'msg'
]:
print
"
\n
{:0>2.0f}:{:0>5.2f} {} : {}"
.
format
(
to_disp
[
'msg'
][
'TS'
]
/
60
,
to_disp
[
'msg'
][
'TS'
]
%
60
,
to_disp
[
'msg'
][
'PREFIX'
],
to_disp
[
'msg'
][
'TASK'
]),
last_task
=
to_disp
[
'msg'
][
'TASK'
]
elif
'OK'
in
to_disp
[
'msg'
]:
if
args
.
verbose
:
print
"
\n
"
for
key
,
value
in
to_disp
[
'msg'
][
'OK'
]
.
iteritems
():
print
" {:<15}{}"
.
format
(
key
,
value
)
else
:
if
to_disp
[
'msg'
][
'OK'
][
'changed'
]:
changed
=
"*OK*"
try
:
if
(
now
-
max
([
msg
[
'recv_ts'
]
for
msg
in
buf
]))
>
args
.
msg_delay
:
# sort by TS instead of recv_ts
# because the sqs timestamp is not as
# accurate
buf
.
sort
(
key
=
lambda
k
:
k
[
'msg'
][
'TS'
])
to_disp
=
buf
.
pop
(
0
)
if
'START'
in
to_disp
[
'msg'
]:
print
'
\n
{:0>2.0f}:{:0>5.2f} {} : Starting "{}"'
.
format
(
to_disp
[
'msg'
][
'TS'
]
/
60
,
to_disp
[
'msg'
][
'TS'
]
%
60
,
to_disp
[
'msg'
][
'PREFIX'
],
to_disp
[
'msg'
][
'START'
]),
elif
'TASK'
in
to_disp
[
'msg'
]:
print
"
\n
{:0>2.0f}:{:0>5.2f} {} : {}"
.
format
(
to_disp
[
'msg'
][
'TS'
]
/
60
,
to_disp
[
'msg'
][
'TS'
]
%
60
,
to_disp
[
'msg'
][
'PREFIX'
],
to_disp
[
'msg'
][
'TASK'
]),
last_task
=
to_disp
[
'msg'
][
'TASK'
]
elif
'OK'
in
to_disp
[
'msg'
]:
if
args
.
verbose
:
print
"
\n
"
for
key
,
value
in
to_disp
[
'msg'
][
'OK'
]
.
iteritems
():
print
" {:<15}{}"
.
format
(
key
,
value
)
else
:
changed
=
"OK"
print
" {}"
.
format
(
changed
),
task_report
.
append
({
'TASK'
:
last_task
,
'INVOCATION'
:
to_disp
[
'msg'
][
'OK'
][
'invocation'
],
'DELTA'
:
to_disp
[
'msg'
][
'delta'
],
})
elif
'FAILURE'
in
to_disp
[
'msg'
]:
print
" !!!! FAILURE !!!!"
,
for
key
,
value
in
to_disp
[
'msg'
][
'FAILURE'
]
.
iteritems
():
print
" {:<15}{}"
.
format
(
key
,
value
)
raise
Exception
(
"Failed Ansible run"
)
elif
'STATS'
in
to_disp
[
'msg'
]:
print
"
\n
{:0>2.0f}:{:0>5.2f} {} : COMPLETE"
.
format
(
to_disp
[
'msg'
][
'TS'
]
/
60
,
to_disp
[
'msg'
][
'TS'
]
%
60
,
to_disp
[
'msg'
][
'PREFIX'
])
# Since 3 ansible plays get run.
# We see the COMPLETE message 3 times
# wait till the last one to end listening
# for new messages.
completed
+=
1
if
completed
>=
NUM_PLAYBOOKS
:
return
(
to_disp
[
'msg'
][
'TS'
],
task_report
)
invocation
=
to_disp
[
'msg'
][
'OK'
][
'invocation'
]
module
=
invocation
[
'module_name'
]
# 'set_fact' does not provide a changed value.
if
module
==
'set_fact'
:
changed
=
"OK"
elif
to_disp
[
'msg'
][
'OK'
][
'changed'
]:
changed
=
"*OK*"
else
:
changed
=
"OK"
print
" {}"
.
format
(
changed
),
task_report
.
append
({
'TASK'
:
last_task
,
'INVOCATION'
:
to_disp
[
'msg'
][
'OK'
][
'invocation'
],
'DELTA'
:
to_disp
[
'msg'
][
'delta'
],
})
elif
'FAILURE'
in
to_disp
[
'msg'
]:
print
" !!!! FAILURE !!!!"
,
for
key
,
value
in
to_disp
[
'msg'
][
'FAILURE'
]
.
iteritems
():
print
" {:<15}{}"
.
format
(
key
,
value
)
raise
Exception
(
"Failed Ansible run"
)
elif
'STATS'
in
to_disp
[
'msg'
]:
print
"
\n
{:0>2.0f}:{:0>5.2f} {} : COMPLETE"
.
format
(
to_disp
[
'msg'
][
'TS'
]
/
60
,
to_disp
[
'msg'
][
'TS'
]
%
60
,
to_disp
[
'msg'
][
'PREFIX'
])
# Since 3 ansible plays get run.
# We see the COMPLETE message 3 times
# wait till the last one to end listening
# for new messages.
completed
+=
1
if
completed
>=
NUM_PLAYBOOKS
:
return
(
to_disp
[
'msg'
][
'TS'
],
task_report
)
except
KeyError
:
print
"Failed to print status from message: {}"
.
format
(
to_disp
)
if
not
messages
:
# wait 1 second between sqs polls
...
...
This diff is collapsed.
Click to expand it.
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