diff options
author | Jing Lu <lvjing5@huawei.com> | 2017-06-30 06:49:43 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-06-30 06:49:43 +0000 |
commit | 14bc98f0e810e37f4600cb0b16d227e8290e1db2 (patch) | |
tree | b7ef7b0d60c018620875b185fe7b66dbd2a12ef5 /api/database/v1 | |
parent | bf298f7dfa5de497ef3cd69aaea7218ed7559160 (diff) | |
parent | 1b9eeb504ed9416c74e1caf8975b51ee6af86b29 (diff) |
Merge "Change prepareYardstickEnv to prepare_env and add log info"
Diffstat (limited to 'api/database/v1')
-rw-r--r-- | api/database/v1/handlers.py | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/api/database/v1/handlers.py b/api/database/v1/handlers.py index f7c448cda..938015d82 100644 --- a/api/database/v1/handlers.py +++ b/api/database/v1/handlers.py @@ -19,14 +19,6 @@ class TasksHandler(object): db_session.commit() return task - def update_status(self, task, status): - task.status = status - db_session.commit() - - def update_error(self, task, error): - task.error = error - db_session.commit() - def get_task_by_taskid(self, task_id): task = Tasks.query.filter_by(task_id=task_id).first() if not task: @@ -35,7 +27,7 @@ class TasksHandler(object): return task def update_attr(self, task_id, attr): - task = self.get_task_by_taskid(task_id) + task = self.get_task_by_taskid(task_id) for k, v in attr.items(): setattr(task, k, v) @@ -49,14 +41,16 @@ class AsyncTaskHandler(object): db_session.commit() return task - def update_status(self, task, status): - task.status = status - db_session.commit() - - def update_error(self, task, error): - task.error = error - db_session.commit() - def get_task_by_taskid(self, task_id): task = AsyncTasks.query.filter_by(task_id=task_id).first() + if not task: + raise ValueError + return task + + def update_attr(self, task_id, attr): + task = self.get_task_by_taskid(task_id) + + for k, v in attr.items(): + setattr(task, k, v) + db_session.commit() |