diff --git a/pyghmi/ipmi/command.py b/pyghmi/ipmi/command.py index 6ae8539c..7450c1e5 100644 --- a/pyghmi/ipmi/command.py +++ b/pyghmi/ipmi/command.py @@ -2220,6 +2220,10 @@ class Command(object): self.oem_init() return self._oem.get_graphical_console() + def get_update_status(self): + self.oem_init() + return self._oem.get_update_status() + def update_firmware(self, filename, data=None, progress=None, bank=None): """Send file to BMC to perform firmware update diff --git a/pyghmi/ipmi/oem/generic.py b/pyghmi/ipmi/oem/generic.py index 9f3ec363..cf2892f3 100644 --- a/pyghmi/ipmi/oem/generic.py +++ b/pyghmi/ipmi/oem/generic.py @@ -339,6 +339,10 @@ class OEMHandler(object): raise exc.UnsupportedFunctionality( 'Remote storage configuration not supported on this platform') + def get_update_status(self): + raise exc.UnsupportedFunctionality( + 'Firmwore update not supported on this platform') + def update_firmware(self, filename, data=None, progress=None, bank=None): raise exc.UnsupportedFunctionality( 'Firmware update not supported on this platform') diff --git a/pyghmi/ipmi/oem/lenovo/handler.py b/pyghmi/ipmi/oem/lenovo/handler.py index d2e443e3..3631b86b 100644 --- a/pyghmi/ipmi/oem/lenovo/handler.py +++ b/pyghmi/ipmi/oem/lenovo/handler.py @@ -1184,6 +1184,13 @@ class OEMHandler(generic.OEMHandler): else: raise + def get_update_status(self): + if self.is_fpc or self.has_tsma: + return "ready" + if self.has_xcc: + return self.immhandler.get_update_status() + return super(OEMHandler, self).get_update_status() + def update_firmware(self, filename, data=None, progress=None, bank=None): if self.has_xcc: return self.immhandler.update_firmware( diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index e36b9c77..770dcb93 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -2128,7 +2128,14 @@ class XCCClient(IMMClient): def set_custom_user_privilege(self, uid, privilege): return self.set_user_access(self, uid, privilege) - + + def get_update_status(self): + upd = self.grab_redfish_response_emptyonerror('/redfish/v1/UpdateService') + health = upd.get('Status', {}).get('Health', 'bod') + if health == 'OK': + return 'ready' + return 'unavailable' + def update_firmware(self, filename, data=None, progress=None, bank=None): usd = self.grab_redfish_response_emptyonerror( '/redfish/v1/UpdateService') diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index be930a77..bf10152a 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -1473,6 +1473,9 @@ class Command(object): """ return self.oem.upload_media(filename, progress, data) + def get_update_status(self): + return self.oem.get_update_status() + def update_firmware(self, file, data=None, progress=None, bank=None): """Send file to BMC to perform firmware update diff --git a/pyghmi/redfish/oem/generic.py b/pyghmi/redfish/oem/generic.py index 301e0a25..8cb3cc92 100644 --- a/pyghmi/redfish/oem/generic.py +++ b/pyghmi/redfish/oem/generic.py @@ -1047,6 +1047,13 @@ class OEMHandler(object): raise exc.UnsupportedFunctionality( 'Remote media upload not supported on this platform') + def get_update_status(self): + upd = self._do_web_request('/redfish/v1/UpdateService') + health = upd.get('Status', {}).get('Health', 'bad') + if health == 'OK': + return 'ready' + return 'unavailable' + def update_firmware(self, filename, data=None, progress=None, bank=None, otherfields=()): # disable cache to make sure we trigger the token renewal logic if needed usd = self._do_web_request('/redfish/v1/UpdateService', cache=False)