From 9ccd58758161677818b641a8d775844c8b8c9a2a Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 5 Nov 2019 11:38:00 -0500 Subject: [PATCH] Fix firmware info on incomplete data The UEFI information may be incomplete. Gracefully degrade as required. Change-Id: I37b58a7ff3c0e9c1ccc08019202783fb79e8f4a7 --- pyghmi/redfish/oem/lenovo/tsma.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pyghmi/redfish/oem/lenovo/tsma.py b/pyghmi/redfish/oem/lenovo/tsma.py index d75cf460..b12ac3a4 100644 --- a/pyghmi/redfish/oem/lenovo/tsma.py +++ b/pyghmi/redfish/oem/lenovo/tsma.py @@ -95,14 +95,16 @@ class TsmHandler(generic.OEMHandler): wc = self.wc fwinf = wc.grab_json_response('/api/DeviceVersion') for biosinf in fwinf: - if biosinf['device'] != 1: + if biosinf.get('device', None) != 1: continue - biosinf = fwinf[1] + if not biosinf.get('buildname', False): + break biosres = { - 'version': '{0}.{1}'.format( - biosinf['main'][0], biosinf['main'][1:]), 'build': biosinf['buildname'] } + if biosinf.get('main', False): + biosres['version'] = '{0}.{1}'.format( + biosinf['main'][0], biosinf['main'][1:]), yield ('UEFI', biosres) break name = 'TSM'