mirror of
https://opendev.org/x/pyghmi
synced 2025-10-26 08:55:20 +00:00
Implement diagnostic data retrieval
Port forward the IPMI oem diagnostic data retrieval for Lenovo equipment. Change-Id: Ic4a4e3566771046b4edf7f0d50fcea5b7f49d197
This commit is contained in:
@@ -1257,6 +1257,9 @@ class Command(object):
|
||||
"""
|
||||
return self.oem.update_firmware(file, data, progress, bank)
|
||||
|
||||
def get_diagnostic_data(self, savefile, progress=None):
|
||||
return self.oem.get_diagnostic_data(savefile, progress)
|
||||
|
||||
if __name__ == '__main__':
|
||||
import os
|
||||
import sys
|
||||
|
||||
@@ -76,3 +76,15 @@ class OEMHandler(object):
|
||||
'vintage': os.times()[4]
|
||||
}
|
||||
return res[0]
|
||||
|
||||
def get_diagnostic_data(self, savefile, progress=None):
|
||||
"""Download diagnostic data about target to a file
|
||||
|
||||
This should be a payload that the vendor's support team can use
|
||||
to do diagnostics.
|
||||
:param savefile: File object or filename to save to
|
||||
:param progress: Callback to be informed about progress
|
||||
:return:
|
||||
"""
|
||||
raise exc.UnsupportedFunctionality(
|
||||
'Do not know how to get diagnostic data for this platform')
|
||||
@@ -677,3 +677,29 @@ class OEMHandler(generic.OEMHandler):
|
||||
return 'complete'
|
||||
return 'pending'
|
||||
|
||||
def get_diagnostic_data(self, savefile, progress=None):
|
||||
self.wc.grab_json_response('/api/providers/ffdc',
|
||||
{'Generate_FFDC': 1})
|
||||
percent = 0
|
||||
while percent != 100:
|
||||
time.sleep(3)
|
||||
result = self.wc.grab_json_response('/api/providers/ffdc',
|
||||
{'Generate_FFDC_status': 1})
|
||||
self._refresh_token()
|
||||
if progress:
|
||||
progress({'phase': 'initializing', 'progress': float(percent)})
|
||||
percent = result['progress']
|
||||
while 'FileName' not in result:
|
||||
result = self.wc.grab_json_response('/api/providers/ffdc',
|
||||
{'Generate_FFDC_status': 1})
|
||||
url = '/ffdc/{0}'.format(result['FileName'])
|
||||
fd = webclient.FileDownloader(self.wc, url, savefile)
|
||||
fd.start()
|
||||
while fd.isAlive():
|
||||
fd.join(1)
|
||||
if progress and self.wc.get_download_progress():
|
||||
progress({'phase': 'download',
|
||||
'progress': 100 * self.wc.get_download_progress()})
|
||||
self._refresh_token()
|
||||
if progress:
|
||||
progress({'phase': 'complete'})
|
||||
@@ -210,6 +210,9 @@ class SecureHTTPConnection(httplib.HTTPConnection, object):
|
||||
if isinstance(file, str) or isinstance(file, unicode):
|
||||
file = open(file, 'wb')
|
||||
webclient = self.dupe()
|
||||
dlheaders = self.stdheaders.copy()
|
||||
if 'Accept-Encoding' in dlheaders:
|
||||
del dlheaders['Accept-Encoding']
|
||||
webclient.request('GET', url)
|
||||
rsp = webclient.getresponse()
|
||||
self._currdl = rsp
|
||||
|
||||
Reference in New Issue
Block a user