diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index 0200259f..1ecf913c 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -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 diff --git a/pyghmi/redfish/oem/generic.py b/pyghmi/redfish/oem/generic.py index 0868a0f8..2a2822e8 100644 --- a/pyghmi/redfish/oem/generic.py +++ b/pyghmi/redfish/oem/generic.py @@ -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') \ No newline at end of file diff --git a/pyghmi/redfish/oem/lenovo/xcc.py b/pyghmi/redfish/oem/lenovo/xcc.py index ac3b54fe..3ab17760 100644 --- a/pyghmi/redfish/oem/lenovo/xcc.py +++ b/pyghmi/redfish/oem/lenovo/xcc.py @@ -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'}) \ No newline at end of file diff --git a/pyghmi/util/webclient.py b/pyghmi/util/webclient.py index ad2fc4da..360aec51 100644 --- a/pyghmi/util/webclient.py +++ b/pyghmi/util/webclient.py @@ -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