diff --git a/pyghmi/ipmi/command.py b/pyghmi/ipmi/command.py index 7450c1e5..161ea411 100644 --- a/pyghmi/ipmi/command.py +++ b/pyghmi/ipmi/command.py @@ -1660,6 +1660,10 @@ class Command(object): r['privilege_level'] = privilege_levels[data[1] & 0b00001111] return r + def get_screenshot(self, outfile): + self.oem_init() + return self._oem.get_screenshot(outfile) + def get_channel_info(self, channel=None): """Get channel info diff --git a/pyghmi/ipmi/oem/generic.py b/pyghmi/ipmi/oem/generic.py index cf2892f3..eaff70cd 100644 --- a/pyghmi/ipmi/oem/generic.py +++ b/pyghmi/ipmi/oem/generic.py @@ -42,6 +42,9 @@ class OEMHandler(object): """ return {} + def get_screenshot(self, outfile): + return {} + def get_system_power_watts(self, ipmicmd): # Use DCMI getpower reading command rsp = ipmicmd.xraw_command(netfn=0x2c, command=2, data=(0xdc, 1, 0, 0)) diff --git a/pyghmi/ipmi/oem/lenovo/handler.py b/pyghmi/ipmi/oem/lenovo/handler.py index 3631b86b..49db6106 100644 --- a/pyghmi/ipmi/oem/lenovo/handler.py +++ b/pyghmi/ipmi/oem/lenovo/handler.py @@ -211,6 +211,11 @@ class OEMHandler(generic.OEMHandler): self._mrethidx = rsp['data'][0] return self._mrethidx + def get_screenshot(self, outfile): + if self.has_xcc: + return self.immhandler.get_screenshot(outfile) + return {} + def remove_storage_configuration(self, cfgspec): if self.has_xcc: return self.immhandler.remove_storage_configuration(cfgspec) diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index 770dcb93..ecba018f 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -914,6 +914,14 @@ class XCCClient(IMMClient): self.ipmicmd.ipmi_session.register_keepalive(self.keepalive, None) self.adp_referer = None + def get_screenshot(self, outfile): + self.wc.grab_json_response('/api/providers/rp_screenshot') + url = '/download/HostScreenShot.png' + fd = webclient.FileDownloader(self.wc, url, outfile) + fd.start() + fd.join() + + def get_user_privilege_level(self, uid): uid = uid - 1 accurl = '/redfish/v1/AccountService/Accounts/{0}'.format(uid) diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index bf10152a..765d6f86 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -432,6 +432,9 @@ class Command(object): self._do_web_request(accinfo[0], userinfo, method='PATCH', etag=etag) return True + def get_screenshot(self, outfile): + return self.oem.get_screenshot(outfile) + def get_ikvm_methods(self): return self.oem.get_ikvm_methods() diff --git a/pyghmi/redfish/oem/generic.py b/pyghmi/redfish/oem/generic.py index 8cb3cc92..ae510359 100644 --- a/pyghmi/redfish/oem/generic.py +++ b/pyghmi/redfish/oem/generic.py @@ -193,6 +193,10 @@ class OEMHandler(object): self._urlcache = cache self.webclient = webclient + def get_screenshot(self, outfile): + raise exc.UnsupportedFunctionality( + 'Retrieving screenshot is not implemented for this platform') + def supports_expand(self, url): # Unfortunately, the state of expand in redfish is pretty dicey, # so an OEM handler must opt into this behavior diff --git a/pyghmi/redfish/oem/lenovo/xcc.py b/pyghmi/redfish/oem/lenovo/xcc.py index ceb2eba1..ef04aca6 100644 --- a/pyghmi/redfish/oem/lenovo/xcc.py +++ b/pyghmi/redfish/oem/lenovo/xcc.py @@ -150,6 +150,13 @@ class OEMHandler(generic.OEMHandler): self.fwc = None self.fwo = None + def get_screenshot(self, outfile): + self.wc.grab_json_response('/api/providers/rp_screenshot') + url = '/download/HostScreenShot.png' + fd = webclient.FileDownloader(self.wc, url, outfile) + fd.start() + fd.join() + def get_extended_bmc_configuration(self, fishclient, hideadvanced=True): immsettings = self.get_system_configuration(fetchimm=True, hideadvanced=hideadvanced) for setting in list(immsettings): diff --git a/pyghmi/redfish/oem/lenovo/xcc3.py b/pyghmi/redfish/oem/lenovo/xcc3.py index b0ff83d2..de85ed85 100644 --- a/pyghmi/redfish/oem/lenovo/xcc3.py +++ b/pyghmi/redfish/oem/lenovo/xcc3.py @@ -42,6 +42,12 @@ class OEMHandler(generic.OEMHandler): def supports_expand(self, url): return True + def get_screenshot(self, outfile): + url = '/web_download/Mini_ScreenShot.jpg' + fd = webclient.FileDownloader(self.webclient, url, outfile) + fd.start() + fd.join() + def get_diagnostic_data(self, savefile, progress=None, autosuffix=False): tsk = self._do_web_request( '/redfish/v1/Systems/1/LogServices/DiagnosticLog/Actions/LogService.CollectDiagnosticData',