]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Add text to empty life expectancy column 47876/head
authorFrancesco Torchia <francesco.torchia@suse.com>
Tue, 30 Aug 2022 14:46:03 +0000 (16:46 +0200)
committerFrancesco Torchia <francesco.torchia@suse.com>
Wed, 21 Sep 2022 12:26:21 +0000 (14:26 +0200)
- 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 <francesco.torchia@suse.com>
src/pybind/mgr/dashboard/controllers/osd.py
src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/device-list/device-list.component.html
src/pybind/mgr/dashboard/frontend/src/app/shared/models/devices.ts

index 4a64aadcf5f49326372c582dd554e6cba448703c..f6f8ce1f58a8a651f48c2b57a07afa3e0e628d6b 100644 (file)
@@ -486,8 +486,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)
index 66c18df61b316c0cd9b0ba0627ea732916f68ed2..56fbb965a659f5461a88eaced3eade226db60b39 100644 (file)
@@ -13,6 +13,8 @@
 
 <ng-template #lifeExpectancy
              let-value="value">
+  <span *ngIf="!value.life_expectancy_enabled"
+        i18n>{{ "" | notAvailable }}</span>
   <span *ngIf="value.min && !value.max">&gt; {{value.min | i18nPlural: translationMapping}}</span>
   <span *ngIf="value.max && !value.min">&lt; {{value.max | i18nPlural: translationMapping}}</span>
   <span *ngIf="value.max && value.min">{{value.min}} to {{value.max | i18nPlural: translationMapping}}</span>
index 90817c89f9d06f519017fbda93320fdf669257fe..69ab3f5f3ca14427ca258e7080372b29a3bc9200 100644 (file)
@@ -8,6 +8,7 @@ export interface CephDevice {
   life_expectancy_min?: string;
   life_expectancy_max?: string;
   life_expectancy_stamp?: string;
+  life_expectancy_enabled?: boolean;
 }
 
 /**