From 5918fd4c3aa57f2dddd69e8206f306dbc5da634f Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 5 Jun 2020 09:21:17 -0400 Subject: [PATCH] Tolerate variant of TSMA without sys OEM If no OEM element in the sysinfo, check the manager. Change-Id: I038ae3edcb82acebd33805723f18e1181b3d3d52 --- pyghmi/redfish/command.py | 6 +++++- pyghmi/redfish/oem/lenovo/main.py | 6 +++++- pyghmi/redfish/oem/lookup.py | 13 ++++++++++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index e85e8530..53c01a49 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -518,6 +518,10 @@ class Command(object): def sysinfo(self): return self._do_web_request(self.sysurl) + @property + def bmcinfo(self): + return self._do_web_request(self._bmcurl) + def get_power(self): currinfo = self._do_web_request(self.sysurl, cache=False) return {'powerstate': str(currinfo['PowerState'].lower())} @@ -1403,7 +1407,7 @@ class Command(object): def oem(self): if not self._oem: self._oem = oem.get_oem_handler( - self.sysinfo, self.sysurl, self.wc, self._urlcache) + self.sysinfo, self.sysurl, self.wc, self._urlcache, self) self._oem.set_credentials(self.username, self.password) return self._oem diff --git a/pyghmi/redfish/oem/lenovo/main.py b/pyghmi/redfish/oem/lenovo/main.py index 645aa2a2..61c4db1f 100644 --- a/pyghmi/redfish/oem/lenovo/main.py +++ b/pyghmi/redfish/oem/lenovo/main.py @@ -17,8 +17,12 @@ from pyghmi.redfish.oem.lenovo import tsma from pyghmi.redfish.oem.lenovo import xcc -def get_handler(sysinfo, sysurl, webclient, cache): +def get_handler(sysinfo, sysurl, webclient, cache, cmd): leninf = sysinfo.get('Oem', {}).get('Lenovo', {}) + if not leninf: + bmcinfo = cmd.bmcinfo + if 'Ami' in bmcinfo.get('Oem', {}): + return tsma.TsmHandler(sysinfo, sysurl, webclient, cache) if 'FrontPanelUSB' in leninf or sysinfo.get('SKU', '').startswith('7X58'): return xcc.OEMHandler(sysinfo, sysurl, webclient, cache) else: diff --git a/pyghmi/redfish/oem/lookup.py b/pyghmi/redfish/oem/lookup.py index a06ece5b..5cada0b4 100644 --- a/pyghmi/redfish/oem/lookup.py +++ b/pyghmi/redfish/oem/lookup.py @@ -20,11 +20,18 @@ OEMMAP = { } -def get_oem_handler(sysinfo, sysurl, webclient, cache): +def get_oem_handler(sysinfo, sysurl, webclient, cache, cmd): for oem in sysinfo.get('Oem', {}): if oem in OEMMAP: - return OEMMAP[oem].get_handler(sysinfo, sysurl, webclient, cache) + return OEMMAP[oem].get_handler(sysinfo, sysurl, webclient, cache, + cmd) for oem in sysinfo.get('Links', {}).get('OEM', []): if oem in OEMMAP: - return OEMMAP[oem].get_handler(sysinfo, sysurl, webclient, cache) + return OEMMAP[oem].get_handler(sysinfo, sysurl, webclient, cache, + cmd) + bmcinfo = cmd.bmcinfo + for oem in bmcinfo.get('Oem', {}): + if oem in OEMMAP: + return OEMMAP[oem].get_handler(sysinfo, sysurl, webclient, cache, + cmd) return generic.OEMHandler(sysinfo, sysurl, webclient, cache)