2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-14 03:37:47 +00:00

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
This commit is contained in:
Jarrod Johnson 2019-05-01 10:35:23 -04:00
parent e073e078a8
commit 1988c09d48

View File

@ -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')