From 9cb6cebf265e9b1ff30c9bfef3ba9fa6c0fde862 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 7 Aug 2019 10:55:48 -0400 Subject: [PATCH] Map subordinate chassis when doing sensors Some implementations model subchassis. For those, descend into the subchassis to get those sensors. Change-Id: I4ed9b3599edffe897821a8571205a75afb6b49f0 --- pyghmi/redfish/command.py | 51 +++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index 77277044..b57e90b0 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -665,31 +665,36 @@ class Command(object): def _sensormap(self): if not self._varsensormap: for chassis in self.sysinfo.get('Links', {}).get('Chassis', []): - chassisurl = chassis['@odata.id'] - chassisinfo = self._do_web_request(chassisurl) - powurl = chassisinfo.get('Power', {}).get('@odata.id', '') - if powurl: - powinf = self._do_web_request(powurl) - for voltage in powinf.get('Voltages', []): - if 'Name' in voltage: - self._varsensormap[voltage['Name']] = { - 'name': voltage['Name'], 'url': powurl, - 'type': 'Voltage'} - thermurl = chassisinfo.get('Thermal', {}).get('@odata.id', '') - if thermurl: - therminf = self._do_web_request(thermurl) - for fan in therminf.get('Fans', []): - if 'Name' in fan: - self._varsensormap[fan['Name']] = { - 'name': fan['Name'], 'type': 'Fan', - 'url': thermurl} - for temp in therminf.get('Temperatures', []): - if 'Name' in temp: - self._varsensormap[temp['Name']] = { - 'name': temp['Name'], 'type': 'Temperature', - 'url': thermurl} + self._mapchassissensors(chassis) return self._varsensormap + def _mapchassissensors(self, chassis): + chassisurl = chassis['@odata.id'] + chassisinfo = self._do_web_request(chassisurl) + powurl = chassisinfo.get('Power', {}).get('@odata.id', '') + if powurl: + powinf = self._do_web_request(powurl) + for voltage in powinf.get('Voltages', []): + if 'Name' in voltage: + self._varsensormap[voltage['Name']] = { + 'name': voltage['Name'], 'url': powurl, + 'type': 'Voltage'} + thermurl = chassisinfo.get('Thermal', {}).get('@odata.id', '') + if thermurl: + therminf = self._do_web_request(thermurl) + for fan in therminf.get('Fans', []): + if 'Name' in fan: + self._varsensormap[fan['Name']] = { + 'name': fan['Name'], 'type': 'Fan', + 'url': thermurl} + for temp in therminf.get('Temperatures', []): + if 'Name' in temp: + self._varsensormap[temp['Name']] = { + 'name': temp['Name'], 'type': 'Temperature', + 'url': thermurl} + for subchassis in chassisinfo.get('Links', {}).get('Contains', []): + self._mapchassissensors(subchassis) + @property def _bmcurl(self): if not self._varbmcurl: