Skip to content
Snippets Groups Projects
Commit 42e3f10b authored by Erik Reid's avatar Erik Reid
Browse files

add args to task log meta data

parent dbf3562b
No related branches found
No related tags found
No related merge requests found
...@@ -36,7 +36,8 @@ TASK_LOG_SCHEMA = { ...@@ -36,7 +36,8 @@ TASK_LOG_SCHEMA = {
'worker': {'type': ['string', 'null']}, 'worker': {'type': ['string', 'null']},
'pid': {'type': 'integer'}, 'pid': {'type': 'integer'},
'warning': {'type': 'boolean'}, 'warning': {'type': 'boolean'},
'error': {'type': 'boolean'} 'error': {'type': 'boolean'},
'args': {'type': 'array'}
}, },
'required': ['task', 'id', 'worker', 'pid', 'warning', 'error'], 'required': ['task', 'id', 'worker', 'pid', 'warning', 'error'],
'additionalProperties': False 'additionalProperties': False
......
...@@ -106,17 +106,17 @@ class InventoryTask(Task): ...@@ -106,17 +106,17 @@ class InventoryTask(Task):
self._append_to_log('ERROR', str(exc)) self._append_to_log('ERROR', str(exc))
save_task_log( save_task_log(
InventoryTask.config, InventoryTask.config,
{'messages': self.messages, 'meta': self._meta()}) {'messages': self.messages, 'meta': self._meta(args=args)})
super().on_failure(exc, task_id, args, kwargs, einfo) super().on_failure(exc, task_id, args, kwargs, einfo)
def on_success(self, retval, task_id, args, kwargs): def on_success(self, retval, task_id, args, kwargs):
self._append_to_log('INFO', 'DONE') self._append_to_log('INFO', 'DONE')
save_task_log( save_task_log(
InventoryTask.config, InventoryTask.config,
{'messages': self.messages, 'meta': self._meta()}) {'messages': self.messages, 'meta': self._meta(args=args)})
super().on_success(retval, task_id, args, kwargs) super().on_success(retval, task_id, args, kwargs)
def _meta(self, message = None): def _meta(self, message=None, args=None):
meta_struct = { meta_struct = {
'task': self.name, 'task': self.name,
'id': self.request.id, 'id': self.request.id,
...@@ -127,6 +127,8 @@ class InventoryTask(Task): ...@@ -127,6 +127,8 @@ class InventoryTask(Task):
} }
if message: if message:
meta_struct['message'] = message meta_struct['message'] = message
if args is not None:
meta_struct['args'] = args
return meta_struct return meta_struct
def return_value(self, message='OK'): def return_value(self, message='OK'):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment