From 66973bfd0c0a247e422d8c449816acc2e99ed5bd Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 21 May 2019 13:19:26 -0400 Subject: [PATCH] Add disk hardware information Use the storage management capabilities to provide information about disk hardware. Change-Id: Ide2cc01ece07f7ca7839bc0bb5f1b877d65bc80d --- pyghmi/redfish/command.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index 6fcc9b43..2091eff2 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -906,7 +906,8 @@ class Command(object): adpurls = self._get_adp_urls() cpurls = self._get_cpu_urls() memurls = self._get_mem_urls() - allurls = adpurls + cpurls + memurls + diskurls = self._get_disk_urls() + allurls = adpurls + cpurls + memurls + diskurls list(self._do_bulk_requests(allurls)) for cpu in self._get_cpu_inventory(withids=withids, urls=cpurls): yield cpu @@ -914,6 +915,25 @@ class Command(object): yield mem for adp in self._get_adp_inventory(withids=withids, urls=adpurls): yield adp + for disk in self._get_disk_inventory(withids=withids, urls=diskurls): + yield disk + + def _get_disk_inventory(self, onlyname=False, withids=False, urls=None): + if not urls: + urls = self._get_disk_urls() + for inf in self._do_bulk_requests(urls): + inf, _ = inf + ddata = { + 'Model': inf.get('Model', None), + 'Serial Number': inf.get('SerialNumber', None), + 'Description': inf.get('Name'), + } + loc = inf.get('PhysicalLocation', {}).get('Info', None) + if loc: + dname = 'Disk {0}'.format(loc) + else: + dname = inf.get('Id', 'Disk') + yield (dname, ddata) def _get_adp_inventory(self, onlyname=False, withids=False, urls=None): if not urls: @@ -1020,6 +1040,18 @@ class Command(object): cpuinfo = {'Model': currcpuinfo.get('Model', None)} yield (name, cpuinfo) + def _get_disk_urls(self): + storurl = self.sysinfo.get('Storage', {}).get('@odata.id', None) + urls = [] + if storurl: + storurl = self._do_web_request(storurl) + for url in storurl.get('Members', []): + url = url['@odata.id'] + ctldata = self._do_web_request(url) + for durl in ctldata.get('Drives', []): + urls.append(durl['@odata.id']) + return urls + def _get_cpu_urls(self): cpurl = self.sysinfo.get('Processors', {}).get('@odata.id', None) if cpurl is None: