From 131030a82350cec7d262d097c13a4c51292769d4 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 17 Jun 2019 14:24:39 -0400 Subject: [PATCH] Add retrieval of diagnostic data for SMM The Lenovo SMM also support service data, provide a backend to support that. Change-Id: I3f44b6bca5fd243334d28e7932c124f1800c4a4f --- pyghmi/ipmi/oem/lenovo/handler.py | 2 ++ pyghmi/ipmi/oem/lenovo/nextscale.py | 32 +++++++++++++++++++++++++++++ pyghmi/util/webclient.py | 1 + 3 files changed, 35 insertions(+) diff --git a/pyghmi/ipmi/oem/lenovo/handler.py b/pyghmi/ipmi/oem/lenovo/handler.py index 6924f316..001ab95a 100755 --- a/pyghmi/ipmi/oem/lenovo/handler.py +++ b/pyghmi/ipmi/oem/lenovo/handler.py @@ -621,6 +621,8 @@ class OEMHandler(generic.OEMHandler): def get_diagnostic_data(self, savefile, progress): if self.has_xcc: return self.immhandler.get_diagnostic_data(savefile, progress) + if self.is_fpc: + return self.smmhandler.get_diagnostic_data(savefile, progress) def get_oem_capping_enabled(self): if self.has_tsm: diff --git a/pyghmi/ipmi/oem/lenovo/nextscale.py b/pyghmi/ipmi/oem/lenovo/nextscale.py index 7b410158..5104c661 100644 --- a/pyghmi/ipmi/oem/lenovo/nextscale.py +++ b/pyghmi/ipmi/oem/lenovo/nextscale.py @@ -264,6 +264,38 @@ class SMMClient(object): self.ipmicmd.xraw_command(netfn=0x32, command=0xa4, data=[int(bay), 2]) + def get_diagnostic_data(self, savefile, progress=None): + rsp = self.ipmicmd.xraw_command(netfn=0x32, command=0xb1, data=[0]) + if bytearray(rsp['data'])[0] != 0: + raise Exception("Service data generation already in progress") + rsp = self.ipmicmd.xraw_command(netfn=0x34, command=0x12, data=[0]) + if bytearray(rsp['data'])[0] != 0: + raise Exception("Service data generation already in progress") + rsp['data'] = b'\x01' + initpct = 1.0 + if progress: + progress({'phase': 'initializing', 'progress': initpct}) + while bytearray(rsp['data'])[0] != 0: + ipmisession.Session.pause(3) + initpct += 3.0 + if initpct > 99.0: + initpct = 99.0 + rsp = self.ipmicmd.xraw_command(netfn=0x34, command=0x12, data=[1]) + if progress: + progress({'phase': 'initializing', 'progress': initpct}) + if self.wc is None: + raise Exception("Failed to connect to web api") + url = '/preview/smm-ffdc.tgz?ST1={0}'.format(self.st1) + 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()}) + if progress: + progress({'phase': 'complete'}) + def process_fru(self, fru): # TODO(jjohnson2): can also get EIOM, SMM, and riser data if warranted fru['Serial Number'] = self.ipmicmd.xraw_command( diff --git a/pyghmi/util/webclient.py b/pyghmi/util/webclient.py index b3629701..1ecb1426 100644 --- a/pyghmi/util/webclient.py +++ b/pyghmi/util/webclient.py @@ -109,6 +109,7 @@ class SecureHTTPConnection(httplib.HTTPConnection, object): **kwargs): if 'timeout' not in kwargs: kwargs['timeout'] = 60 + self._currdl = None self.lastjsonerror = None self.broken = False self.thehost = host