From 1d7bdd41857f4b18d3553e28e5446707b4ec222a Mon Sep 17 00:00:00 2001 From: Francesco Torchia Date: Tue, 30 Aug 2022 16:46:03 +0200 Subject: [PATCH] mgr/dashboard: Add text to empty life expectancy column - Add life_expectancy_enabled field to /api/osd/{svc_id}/devices - Add new value 'n/a' for 'Life Expectancy' column Fixes: https://tracker.ceph.com/issues/43116 Signed-off-by: Francesco Torchia (cherry picked from commit 811bba7e083919cf3b21ed01ac29a107b5bd006d) --- src/pybind/mgr/dashboard/controllers/osd.py | 14 ++++++++++++-- .../shared/device-list/device-list.component.html | 2 ++ .../frontend/src/app/shared/models/devices.ts | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/dashboard/controllers/osd.py b/src/pybind/mgr/dashboard/controllers/osd.py index 9c903ed672eec..1e557bd74d41e 100644 --- a/src/pybind/mgr/dashboard/controllers/osd.py +++ b/src/pybind/mgr/dashboard/controllers/osd.py @@ -482,8 +482,18 @@ class Osd(RESTController): @RESTController.Resource('GET') def devices(self, svc_id): - # (str) -> dict - return CephService.send_command('mon', 'device ls-by-daemon', who='osd.{}'.format(svc_id)) + # type: (str) -> Union[list, str] + devices: Union[list, str] = CephService.send_command( + 'mon', 'device ls-by-daemon', who='osd.{}'.format(svc_id)) + mgr_map = mgr.get('mgr_map') + available_modules = [m['name'] for m in mgr_map['available_modules']] + + life_expectancy_enabled = any( + item.startswith('diskprediction_') for item in available_modules) + for device in devices: + device['life_expectancy_enabled'] = life_expectancy_enabled + + return devices @UIRouter('/osd', Scope.OSD) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/device-list/device-list.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/device-list/device-list.component.html index 66c18df61b316..56fbb965a659f 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/device-list/device-list.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/device-list/device-list.component.html @@ -13,6 +13,8 @@ + {{ "" | notAvailable }} > {{value.min | i18nPlural: translationMapping}} < {{value.max | i18nPlural: translationMapping}} {{value.min}} to {{value.max | i18nPlural: translationMapping}} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/models/devices.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/models/devices.ts index 90817c89f9d06..69ab3f5f3ca14 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/models/devices.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/models/devices.ts @@ -8,6 +8,7 @@ export interface CephDevice { life_expectancy_min?: string; life_expectancy_max?: string; life_expectancy_stamp?: string; + life_expectancy_enabled?: boolean; } /** -- 2.47.3