From 7448c5b25629a1010089f06ce2ac2d90285c0b4d Mon Sep 17 00:00:00 2001
From: Jarrod Johnson <jjohnson2@lenovo.com>
Date: Tue, 23 Mar 2021 12:58:54 -0400
Subject: [PATCH] Fix SMMv2 ffdc download

Change-Id: I6ed9eca50a82d989dcbd679d451dd13ce7833c99
---
 pyghmi/ipmi/oem/lenovo/handler.py   | 3 ++-
 pyghmi/ipmi/oem/lenovo/nextscale.py | 8 ++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/pyghmi/ipmi/oem/lenovo/handler.py b/pyghmi/ipmi/oem/lenovo/handler.py
index 931e7d3f..b1181627 100755
--- a/pyghmi/ipmi/oem/lenovo/handler.py
+++ b/pyghmi/ipmi/oem/lenovo/handler.py
@@ -662,7 +662,8 @@ class OEMHandler(generic.OEMHandler):
                                                        autosuffix)
         if self.is_fpc:
             return self.smmhandler.get_diagnostic_data(savefile, progress,
-                                                       autosuffix)
+                                                       autosuffix,
+                                                       self._fpc_variant)
         if self.has_tsma:
             return self.tsmahandler.get_diagnostic_data(savefile, progress,
                                                         autosuffix)
diff --git a/pyghmi/ipmi/oem/lenovo/nextscale.py b/pyghmi/ipmi/oem/lenovo/nextscale.py
index 3934b6e6..5ac2b34b 100644
--- a/pyghmi/ipmi/oem/lenovo/nextscale.py
+++ b/pyghmi/ipmi/oem/lenovo/nextscale.py
@@ -508,7 +508,8 @@ class SMMClient(object):
         self.ipmicmd.xraw_command(netfn=0x32, command=0xa4,
                                   data=[int(bay), 2])
 
-    def get_diagnostic_data(self, savefile, progress=None, autosuffix=False):
+    def get_diagnostic_data(self, savefile, progress=None, autosuffix=False,
+                            variant=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")
@@ -529,7 +530,10 @@ class SMMClient(object):
                 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)
+        if variant and variant >> 5:
+            url = '/preview/smm2-ffdc.tgz?ST1={0}'.format(self.st1)
+        else:
+            url = '/preview/smm-ffdc.tgz?ST1={0}'.format(self.st1)
         if autosuffix and not savefile.endswith('.tgz'):
             savefile += '-smm-ffdc.tgz'
         fd = webclient.FileDownloader(self.wc, url, savefile)