Revision a50a2bff snf-image-helper/common.sh
b/snf-image-helper/common.sh | ||
---|---|---|
40 | 40 |
ERRORS=( ) |
41 | 41 |
WARNINGS=( ) |
42 | 42 |
|
43 |
MSG_TYPE_ERROR="error" |
|
44 |
MSG_TYPE_TASK_START="task-start" |
|
45 |
MSG_TYPE_TASK_END="task-end" |
|
46 |
|
|
43 | 47 |
add_cleanup() { |
44 | 48 |
local cmd="" |
45 | 49 |
for arg; do cmd+=$(printf "%q " "$arg"); done |
... | ... | |
57 | 61 |
echo "Warning: $@" >&2 |
58 | 62 |
} |
59 | 63 |
|
60 |
report_start_task() {
|
|
64 |
report_task_start() {
|
|
61 | 65 |
|
62 |
local type="start-task"
|
|
66 |
local type="$MSG_TYPE_TASK_START"
|
|
63 | 67 |
local timestamp=$(date +%s.%N) |
64 | 68 |
local name="${PROGNAME}" |
65 | 69 |
|
66 |
report+="\"type\":\"$type\"," |
|
70 |
report+="{\"type\":\"$type\","
|
|
67 | 71 |
report+="\"timestamp\":$(date +%s.%N)," |
68 | 72 |
report+="\"name\":\"$name\"}" |
69 | 73 |
|
... | ... | |
85 | 89 |
echo "$report" |
86 | 90 |
} |
87 | 91 |
|
88 |
report_end_task() { |
|
89 |
|
|
90 |
local type="end-task" |
|
92 |
report_task_end() { |
|
93 |
local type="$MSG_TYPE_TASK_END" |
|
91 | 94 |
local timestam=$(date +%s.%N) |
92 | 95 |
local name=${PROGNAME} |
93 | 96 |
local warnings=$(json_list WARNINGS[@]) |
94 | 97 |
|
95 |
report="\"type\":\"$type\"," |
|
96 |
report+="\"timestamp\":$(date +%s)," |
|
98 |
report="{\"type\":\"$type\","
|
|
99 |
report+="\"timestamp\":$(date +%s.%N),"
|
|
97 | 100 |
report+="\"name\":\"$name\"," |
98 | 101 |
report+="\"warnings\":\"$warnings\"}" |
99 | 102 |
|
... | ... | |
101 | 104 |
} |
102 | 105 |
|
103 | 106 |
report_error() { |
104 |
local type="ganeti-error"
|
|
107 |
local type="$MSG_TYPE_ERROR"
|
|
105 | 108 |
local timestamp=$(date +%s.%N) |
106 | 109 |
local location="${PROGNAME}" |
107 | 110 |
local errors=$(json_list ERRORS[@]) |
108 | 111 |
local warnings=$(json_list WARNINGS[@]) |
109 | 112 |
local stderr="$(cat "$STDERR_FILE" | sed 's/"/\\"/g')" |
110 | 113 |
|
111 |
report="\"type\":\"$type\"," |
|
114 |
report="{\"type\":\"$type\","
|
|
112 | 115 |
report+="\"timestamp\":$(date +%s)," |
113 | 116 |
report+="\"location\":\"$location\"," |
114 | 117 |
report+="\"errors\":$errors," |
... | ... | |
400 | 403 |
rc=$? |
401 | 404 |
|
402 | 405 |
if [ $rc -eq 0 ]; then |
403 |
report_end_task
|
|
406 |
report_task_end
|
|
404 | 407 |
else |
405 | 408 |
report_error |
406 | 409 |
fi |
Also available in: Unified diff