From 88d6fe8fc71066ebdca13252d99150831cf56779 Mon Sep 17 00:00:00 2001 From: Redouane Kachach Date: Wed, 13 Sep 2023 13:46:42 +0200 Subject: [PATCH] Adding service_name and daemon_type and fixing mypy issues Signed-off-by: Redouane Kachach (cherry picked from commit 72e9345faa725bd2aaba41e06ed34927badd7622) --- src/pybind/mgr/orchestrator/module.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index db680ab842972..c1fb129d53d7d 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -135,6 +135,8 @@ yaml.add_representer(HostDetails, HostDetails.yaml_representer) class DaemonFields(enum.Enum): + service_name = 'service_name' + daemon_type = 'daemon_type' name = 'name' host = 'host' status = 'status' @@ -144,6 +146,7 @@ class DaemonFields(enum.Enum): mem_lim = 'mem_lim' image = 'image' + class ServiceType(enum.Enum): mon = 'mon' mgr = 'mgr' @@ -841,13 +844,13 @@ class OrchestratorCli(OrchestratorClientMixin, MgrModule, def ukn(s: Optional[str]) -> str: return '' if s is None else s - def sort_by_field(d: DaemonDescription) -> Optional[str]: + def sort_by_field(d: DaemonDescription) -> Any: if sort_by == DaemonFields.name: return d.name() elif sort_by == DaemonFields.host: return d.hostname elif sort_by == DaemonFields.status: - return d.status + return d.status.name if d.status else None elif sort_by == DaemonFields.refreshed: return d.last_refresh elif sort_by == DaemonFields.age: @@ -858,6 +861,10 @@ class OrchestratorCli(OrchestratorClientMixin, MgrModule, return d.memory_request elif sort_by == DaemonFields.image: return d.container_image_id + elif sort_by == DaemonFields.daemon_type: + return d.daemon_type + elif sort_by == DaemonFields.service_name: + return d.service_name() else: return None -- 2.39.5