From: Kiefer Chang Date: Thu, 5 Dec 2019 10:05:30 +0000 (+0800) Subject: mgr/dashboard: Fix OSD IDs are not displayed when using cephadm backend X-Git-Tag: v15.1.0~465^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3f3c56d2a10edbdfbb81ad2468e3c03909fd8d20;p=ceph-ci.git mgr/dashboard: Fix OSD IDs are not displayed when using cephadm backend The basename of device path should be used for OSD mapping comparison. e.g. `/dev/sda` -> `sda`. Fixes: https://tracker.ceph.com/issues/43136 Signed-off-by: Kiefer Chang --- diff --git a/src/pybind/mgr/dashboard/controllers/orchestrator.py b/src/pybind/mgr/dashboard/controllers/orchestrator.py index f38ac90a87e..6235f209ee0 100644 --- a/src/pybind/mgr/dashboard/controllers/orchestrator.py +++ b/src/pybind/mgr/dashboard/controllers/orchestrator.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import +import os.path import cherrypy from ceph.deployment.drive_group import DriveGroupSpec, DriveGroupValidationError @@ -83,7 +84,8 @@ class OrchestratorInventory(RESTController): node_osds = device_osd_map.get(inventory_node['name']) for device in inventory_node['devices']: if node_osds: - device['osd_ids'] = sorted(node_osds.get(device['path'], [])) + dev_name = os.path.basename(device['path']) + device['osd_ids'] = sorted(node_osds.get(dev_name, [])) else: device['osd_ids'] = [] return inventory_nodes diff --git a/src/pybind/mgr/dashboard/tests/test_orchestrator.py b/src/pybind/mgr/dashboard/tests/test_orchestrator.py index 7ed687e1eb0..2817a691680 100644 --- a/src/pybind/mgr/dashboard/tests/test_orchestrator.py +++ b/src/pybind/mgr/dashboard/tests/test_orchestrator.py @@ -73,14 +73,14 @@ class OrchestratorControllerTest(ControllerTestCase): 'name': 'host-0', 'devices': [ {'path': 'nvme0n1'}, - {'path': 'sdb'}, - {'path': 'sdc'}, + {'path': '/dev/sdb'}, + {'path': '/dev/sdc'}, ] }, { 'name': 'host-1', 'devices': [ - {'path': 'sda'}, + {'path': '/dev/sda'}, {'path': 'sdb'}, ] }