From: Patrick Seidensal Date: Wed, 23 Oct 2019 12:31:36 +0000 (+0200) Subject: mgr/dashboard: AttributeError: 'NoneType' object has no attribute 'items' in smart... X-Git-Tag: v15.1.0~1086^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F31078%2Fhead;p=ceph.git mgr/dashboard: AttributeError: 'NoneType' object has no attribute 'items' in smart data integration Fixes: https://tracker.ceph.com/issues/42443 Signed-off-by: Patrick Seidensal --- diff --git a/src/pybind/mgr/dashboard/controllers/osd.py b/src/pybind/mgr/dashboard/controllers/osd.py index e9eb229aff23..32dd56809682 100644 --- a/src/pybind/mgr/dashboard/controllers/osd.py +++ b/src/pybind/mgr/dashboard/controllers/osd.py @@ -57,6 +57,7 @@ class Osd(RESTController): def add_id(osd): osd['id'] = osd['osd'] return osd + resp = { osd['osd']: add_id(osd) for osd in mgr.get('osd_map')['osds'] if svc_id is None or osd['osd'] == int(svc_id) @@ -77,11 +78,13 @@ class Osd(RESTController): if dev_id not in smart_data: dev_smart_data = mgr.remote('devicehealth', 'do_scrape_daemon', 'osd', svc_id, dev_id) - for _, dev_data in dev_smart_data.items(): - if 'error' in dev_data: - logger.warning('[OSD] Error retrieving smartctl data for device ID %s: %s', - dev_id, dev_smart_data) - smart_data.update(dev_smart_data) + if dev_smart_data: + for _, dev_data in dev_smart_data.items(): + if 'error' in dev_data: + logger.warning( + '[OSD] Error retrieving smartctl data for device ID %s: %s', dev_id, + dev_smart_data) + smart_data.update(dev_smart_data) return smart_data @RESTController.Resource('GET')