2
0
mirror of https://opendev.org/x/pyghmi synced 2026-01-11 02:32:31 +00:00

Add get screenshot capability

This can get image files from the BMCs representing the current graphical console.

Change-Id: Ibe45e9584cb5445b92139bd563372180b630b219
This commit is contained in:
Jarrod Johnson
2025-04-05 13:40:17 -04:00
parent b8e6a1f8ae
commit db29760efd
8 changed files with 40 additions and 0 deletions

View File

@@ -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

View File

@@ -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))

View File

@@ -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)

View File

@@ -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)

View File

@@ -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()

View File

@@ -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

View File

@@ -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):

View File

@@ -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',