From 766504950a0f178187c5690bffb196aa9e8c2d7e 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 a8171e466f5c..16c94dea0ab8 100644 --- a/src/pybind/mgr/dashboard/controllers/osd.py +++ b/src/pybind/mgr/dashboard/controllers/osd.py @@ -483,8 +483,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 66c18df61b31..56fbb965a659 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 90817c89f9d0..69ab3f5f3ca1 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