summaryrefslogtreecommitdiffstats
path: root/api/utils/daemonthread.py
diff options
context:
space:
mode:
authorRex Lee <limingjiang@huawei.com>2017-01-10 08:54:16 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-01-10 08:54:16 +0000
commitceebb672c85c5dbce6df17f0c263375d17adcc05 (patch)
tree807b3fbdcef0025eb56d2c8b093e7f7d24ed3a9a /api/utils/daemonthread.py
parent45db0fdabb4585b96756a390650181a3c46facf7 (diff)
parent254414758828a12a353e0670704faa5bcb792cae (diff)
Merge "Record test case names when run a task using API"
Diffstat (limited to 'api/utils/daemonthread.py')
-rw-r--r--api/utils/daemonthread.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/api/utils/daemonthread.py b/api/utils/daemonthread.py
index 47c0b9108..19182c429 100644
--- a/api/utils/daemonthread.py
+++ b/api/utils/daemonthread.py
@@ -8,11 +8,10 @@
##############################################################################
import threading
import os
-import datetime
import errno
from api import conf
-from api.utils.influx import write_data_tasklist
+from api.database.handlers import TasksHandler
class DaemonThread(threading.Thread):
@@ -21,19 +20,24 @@ class DaemonThread(threading.Thread):
super(DaemonThread, self).__init__(target=method, args=args)
self.method = method
self.command_list = args[0]
- self.task_id = args[1]
+ self.task_dict = args[1]
def run(self):
- timestamp = datetime.datetime.now()
+ self.task_dict['status'] = 0
+ task_id = self.task_dict['task_id']
try:
- write_data_tasklist(self.task_id, timestamp, 0)
- self.method(self.command_list, self.task_id)
- write_data_tasklist(self.task_id, timestamp, 1)
+ task_handler = TasksHandler()
+ task = task_handler.insert(self.task_dict)
+
+ self.method(self.command_list, task_id)
+
+ task_handler.update_status(task, 1)
except Exception as e:
- write_data_tasklist(self.task_id, timestamp, 2, error=str(e))
+ task_handler.update_status(task, 2)
+ task_handler.update_error(task, str(e))
finally:
- _handle_testsuite_file(self.task_id)
+ _handle_testsuite_file(task_id)
def _handle_testsuite_file(task_id):