mirror of
https://opendev.org/x/pyghmi
synced 2026-01-07 16:52:32 +00:00
Support Boolean types for redfish uefi attribs
BIOS settings set as boolean are now handled with some sanity. Change-Id: I77eb3dd3259746ae4739a2f4c255bdc8d62db9d4
This commit is contained in:
@@ -95,6 +95,20 @@ def _mask_to_cidr(mask):
|
||||
return cidr
|
||||
|
||||
|
||||
def _to_boolean(attrval):
|
||||
attrval = attrval.lower()
|
||||
if not attrval:
|
||||
return False
|
||||
if ('true'.startswith(attrval) or 'yes'.startswith(attrval) or
|
||||
'enabled'.startswith(attrval) or attrval == '1'):
|
||||
return True
|
||||
if ('false'.startswith(attrval) or 'no'.startswith(attrval) or
|
||||
'disabled'.startswith(attrval) or attrval == '0'):
|
||||
return False
|
||||
raise Exception(
|
||||
'Unrecognized candidate for boolean: {0}'.format(attrval))
|
||||
|
||||
|
||||
def _cidr_to_mask(cidr):
|
||||
return socket.inet_ntop(
|
||||
socket.AF_INET, struct.pack(
|
||||
@@ -1088,6 +1102,8 @@ class Command(object):
|
||||
regentry.get('DisplayName', '')):
|
||||
if regentry.get('Type', None) == 'Integer':
|
||||
changeset[change] = int(changeset[change])
|
||||
if regentry.get('Type', None) == 'Boolean':
|
||||
changeset[change] = _to_boolean(changeset[change])
|
||||
redfishsettings = {'Attributes': changeset}
|
||||
self._do_web_request(self._setbiosurl, redfishsettings, 'PATCH',
|
||||
etag=etag)
|
||||
|
||||
Reference in New Issue
Block a user