Revision 6138f0ef
b/snf-cyclades-app/synnefo/logic/callbacks.py | ||
---|---|---|
39 | 39 |
|
40 | 40 |
from synnefo.lib.utils import merge_time |
41 | 41 |
|
42 |
|
|
43 | 42 |
log = logging.getLogger() |
44 | 43 |
|
45 |
|
|
46 | 44 |
def handle_message_delivery(func): |
47 | 45 |
""" Generic decorator for handling messages. |
48 | 46 |
|
... | ... | |
201 | 199 |
@instance_from_msg |
202 | 200 |
@if_update_required |
203 | 201 |
def update_build_progress(vm, msg, event_time): |
204 |
"""Process a create progress message""" |
|
202 |
""" |
|
203 |
Process a create progress message. Update build progress, or create |
|
204 |
appropriate diagnostic entries for the virtual machine instance. |
|
205 |
""" |
|
205 | 206 |
log.debug("Processing ganeti-create-progress msg: %s", msg) |
206 | 207 |
|
207 | 208 |
if msg['type'] not in ('image-copy-progress', 'image-error', 'image-info', |
... | ... | |
211 | 212 |
|
212 | 213 |
if msg['type'] == 'image-copy-progress': |
213 | 214 |
backend.process_create_progress(vm, event_time, msg['progress']) |
215 |
# we do not add diagnostic messages for copy-progress messages |
|
216 |
return |
|
217 |
|
|
218 |
# default diagnostic fields |
|
219 |
source = msg['type'] |
|
220 |
level = 'DEBUG' |
|
221 |
message = msg.get('messages', None) |
|
222 |
if isinstance(message, list): |
|
223 |
message = " ".join(message) |
|
224 |
|
|
225 |
details = msg.get('stderr', None) |
|
226 |
|
|
227 |
if msg['type'] == 'image-helper': |
|
228 |
# for helper task events join subtype to diagnostic source and |
|
229 |
# set task name as diagnostic message |
|
230 |
if msg.get('subtype', None) and msg.get('subtype') in ['task-start', |
|
231 |
'task-end']: |
|
232 |
message = msg.get('task', message) |
|
233 |
source = "%s-%s" % (source, msg.get('subtype')) |
|
234 |
|
|
235 |
if msg.get('subtype', None) == 'warning': |
|
236 |
level = 'WARNING' |
|
237 |
|
|
238 |
if msg.get('subtype', None) == 'error': |
|
239 |
level = 'ERROR' |
|
240 |
|
|
241 |
if msg.get('subtype', None) == 'info': |
|
242 |
level = 'INFO' |
|
243 |
|
|
244 |
if msg['type'] == 'image-error': |
|
245 |
level = 'ERROR' |
|
246 |
|
|
247 |
if msg['type'] == 'image-warning': |
|
248 |
level = 'WARNING' |
|
249 |
|
|
250 |
if not message.strip(): |
|
251 |
message = " ".join(source.split("-")).capitalize() |
|
252 |
|
|
253 |
# create the diagnostic entry |
|
254 |
backend.create_instance_diagnostic(vm, message, source, level, event_time, |
|
255 |
details=details) |
|
214 | 256 |
|
215 | 257 |
log.debug("Done processing ganeti-create-progress msg for vm %s.", |
216 | 258 |
msg['instance']) |
Also available in: Unified diff