From 35351756bf3987157ccc94a3a4508b6931cb6a1d Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 25 Mar 2020 11:41:40 -0400 Subject: [PATCH] Make reset Bios configuration adaptive So of course it turns out that in redfish multiple firmware developers implemented another exactly identical behavior with different requirements. Accomodate by trying to detect at least two variants seen in the industry. Change-Id: I5aec979f12fd775bcf8570fde411eaee787ba9c3 --- pyghmi/redfish/command.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index bb0e597c..0bb59f16 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -1,3 +1,4 @@ +# coding: utf8 # Copyright 2019 Lenovo # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -1044,10 +1045,26 @@ class Command(object): """ biosinfo = self._do_web_request(self._biosurl) rb = biosinfo.get('Actions', {}).get('#Bios.ResetBios', {}) + actinf = rb.get('@Redfish.ActionInfo', None) rb = rb.get('target', '') + parms = {} + if actinf: + actinf = self._do_web_request( + '/redfish/v1/Systems/Self/Bios/ResetBiosActionInfo') + for parm in actinf.get('Parameters', ()): + if parm.get('Required', False): + if parm.get('Name', None) == 'ResetType' and parm.get( + 'AllowableValues', [None])[0] == 'Reset': + parms['ResetType'] = 'Reset' + else: + raise Exception( + 'Unrecognized required parameter {0}'.format( + parm.get('Name', 'Unknown'))) if not rb: raise Exception('BIOS reset not detected on this system') - self._do_web_request(rb, {'Action': 'Bios.ResetBios'}) + if not parms: + parms = {'Action': 'Bios.ResetBios'} + self._do_web_request(rb, parms) def set_system_configuration(self, changeset): currsettings, reginfo = self._getsyscfg()