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
804fce06
Commit
804fce06
authored
Jan 22, 2014
by
Feanil Patel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Catch keyerrors.
parent
256493c5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
53 deletions
+56
-53
util/vpc-tools/abbey.py
+56
-53
No files found.
util/vpc-tools/abbey.py
View file @
804fce06
...
...
@@ -407,60 +407,63 @@ 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
)
if
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
...
...
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