From 1988c09d48552ad0517cc20703365bd8f796854d Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 1 May 2019 10:35:23 -0400 Subject: [PATCH] Use the registry info to help set Provide support for wildcards in settings and attributes, as well as case insensitivity. This brings set nearly to parity with the XCC configuration set in the ipmi half. Change-Id: I6eef01af8e9e3bb7be03538509a606728c3c33da --- pyghmi/redfish/command.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index 19b03a65..f1232883 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -19,6 +19,7 @@ # for redfish compliant endpoints from datetime import datetime, timedelta +from fnmatch import fnmatch import json import os import socket @@ -620,6 +621,28 @@ class Command(object): self._do_web_request(rb, {'Action': 'Bios.ResetBios'}) def set_system_configuration(self, changeset): + currsettings = self.get_system_configuration() + for change in list(changeset): + if change not in currsettings: + found = False + for attr in currsettings: + if fnmatch(attr.lower(), change.lower()): + found = True + changeset[attr] = changeset[change] + if found: + del changeset[change] + for change in changeset: + changeval = changeset[change] + if (currsettings.get(change, {}).get('possible', []) + and changeval not in currsettings[change]['possible']): + normval = changeval.lower() + normval = re.sub(r'\s+', ' ', normval) + if not normval.endswith('*'): + normval += '*' + for cand in currsettings[change]['possible']: + if fnmatch(cand.lower(), normval): + changeset[change] = cand + break redfishsettings = {'Attributes': changeset} self._do_web_request(self._setbiosurl, redfishsettings, 'PATCH')