From: Ricardo Dias Date: Mon, 15 Jul 2019 14:07:42 +0000 (+0100) Subject: mgr/dashboard: progress mgr module service X-Git-Tag: v15.1.0~2173^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=63334ee2b247a478530046f654fe14ce5dd623c8;p=ceph.git mgr/dashboard: progress mgr module service This service module implements helper methods to retrieve tasks information from the progress mgr module. Signed-off-by: Ricardo Dias --- diff --git a/src/pybind/mgr/dashboard/services/progress.py b/src/pybind/mgr/dashboard/services/progress.py new file mode 100644 index 000000000000..4bacc1974625 --- /dev/null +++ b/src/pybind/mgr/dashboard/services/progress.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +''' +Progress Mgr Module Helper + +This python module implements helper methods to retrieve the +executing and completed tasks tacked by the progress mgr module +using the same structure of dashboard tasks +''' + +from __future__ import absolute_import + +from datetime import datetime + +from .. import mgr, logger + + +def get_progress_tasks(): + executing_t = [] + finished_t = [] + progress_events = mgr.remote('progress', "_json") + + for ev in progress_events['events']: + logger.debug("[Progress] event=%s", ev) + executing_t.append({ + # we're prepending the "progress/" prefix to tag tasks that come + # from the progress module + 'name': "progress/{}".format(ev['message']), + 'metadata': dict(ev['refs']), + 'begin_time': "{}Z".format(datetime.fromtimestamp(ev["started_at"]) + .isoformat()), + 'progress': int(100 * ev['progress']) + }) + + for ev in progress_events['completed']: + logger.debug("[Progress] finished event=%s", ev) + finished_t.append({ + 'name': "progress/{}".format(ev['message']), + 'metadata': dict(ev['refs']), + 'begin_time': "{}Z".format(datetime.fromtimestamp(ev["started_at"]) + .isoformat()), + 'end_time': "{}Z".format(datetime.fromtimestamp(ev['finished_at']) + .isoformat()), + 'duration': ev['finished_at'] - ev['started_at'], + 'progress': 100, + 'success': True, + 'ret_value': None, + 'exception': None + }) + + return executing_t, finished_t