diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/pybind/mgr/dashboard/controllers/task.py | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/pybind/mgr/dashboard/controllers/task.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/pybind/mgr/dashboard/controllers/task.py b/src/pybind/mgr/dashboard/controllers/task.py new file mode 100644 index 000000000..14e763b75 --- /dev/null +++ b/src/pybind/mgr/dashboard/controllers/task.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +from __future__ import absolute_import + +from ..services import progress +from ..tools import TaskManager +from . import APIDoc, APIRouter, EndpointDoc, RESTController + +TASK_SCHEMA = { + "executing_tasks": (str, "ongoing executing tasks"), + "finished_tasks": ([{ + "name": (str, "finished tasks name"), + "metadata": ({ + "pool": (int, "") + }, ""), + "begin_time": (str, "Task begin time"), + "end_time": (str, "Task end time"), + "duration": (int, ""), + "progress": (int, "Progress of tasks"), + "success": (bool, ""), + "ret_value": (bool, ""), + "exception": (bool, "") + }], "") +} + + +@APIRouter('/task') +@APIDoc("Task Management API", "Task") +class Task(RESTController): + @EndpointDoc("Display Tasks", + parameters={ + 'name': (str, 'Task Name'), + }, + responses={200: TASK_SCHEMA}) + def list(self, name=None): + executing_t, finished_t = TaskManager.list_serializable(name) + + e, f = progress.get_progress_tasks() + executing_t.extend(e) + finished_t.extend(f) + + executing_t.sort(key=lambda t: t['begin_time'], reverse=True) + finished_t.sort(key=lambda t: t['end_time'], reverse=True) + + return { + 'executing_tasks': executing_t, + 'finished_tasks': finished_t + } |