mirror of
https://opendev.org/x/pyghmi
synced 2026-09-25 01:04:09 +00:00
Provide error checking using XCC hints
The XCC provides hints as to the valid format of open ended text. Apply this as a sanity check before accepting a changeset. Change-Id: I4a97a5a85e4de69fa13894a46dca568cda447705
This commit is contained in:
@@ -353,6 +353,7 @@ class LenovoFirmwareConfig(object):
|
||||
reset = False
|
||||
name = setting.find("mriName").text
|
||||
help = setting.find("desc").text
|
||||
validexpression = None
|
||||
onedata = setting.find('text_data')
|
||||
if onedata is not None:
|
||||
if onedata.get('password') == 'true':
|
||||
@@ -366,6 +367,7 @@ class LenovoFirmwareConfig(object):
|
||||
if onedata is not None:
|
||||
if onedata.get('maxinstance') is not None:
|
||||
forceinstance = True
|
||||
validexpression = onedata.get('pattern', None)
|
||||
instances = list(onedata.iter('instance'))
|
||||
if not instances:
|
||||
protect = True # not supported yet
|
||||
@@ -451,6 +453,7 @@ class LenovoFirmwareConfig(object):
|
||||
readonly_expression=readonly,
|
||||
hide_expression=hide,
|
||||
sortid=sortid,
|
||||
validexpression=validexpression,
|
||||
alias=alias)
|
||||
sortid += 1
|
||||
instidx += 1
|
||||
@@ -479,6 +482,7 @@ class LenovoFirmwareConfig(object):
|
||||
readonly_expression=readonly,
|
||||
hide_expression=hide,
|
||||
sortid=sortid,
|
||||
validexpression=validexpression,
|
||||
alias=alias)
|
||||
sortid += 1
|
||||
continue
|
||||
@@ -503,6 +507,7 @@ class LenovoFirmwareConfig(object):
|
||||
readonly_expression=readonly,
|
||||
hide_expression=hide,
|
||||
sortid=sortid,
|
||||
validexpression=validexpression,
|
||||
alias=alias)
|
||||
sortid = sortid + 1
|
||||
for opt in options:
|
||||
|
||||
@@ -315,6 +315,11 @@ class IMMClient(object):
|
||||
'({2})'.format(
|
||||
newvalue, key,
|
||||
','.join(self.fwo[key]['possible'])))
|
||||
elif self.fwo[key]['validexpression']:
|
||||
if not re.match(self.fwo[key]['validexpression'], newvalue):
|
||||
raise pygexc.InvalidParameterValue(
|
||||
'"{0}" does not match expression "{1}"'.format(
|
||||
newvalue, self.fwo[key]['validexpression']))
|
||||
newnewvalues.append(newvalue)
|
||||
if len(newnewvalues) == 1:
|
||||
self.fwo[key]['new_value'] = newnewvalues[0]
|
||||
|
||||
@@ -253,6 +253,11 @@ class OEMHandler(generic.OEMHandler):
|
||||
'({2})'.format(
|
||||
newvalue, key,
|
||||
','.join(self.fwo[key]['possible'])))
|
||||
elif self.fwo[key]['validexpression']:
|
||||
if not re.match(self.fwo[key]['validexpression'], newvalue):
|
||||
raise pygexc.InvalidParameterValue(
|
||||
'"{0}" does not match expression "{1}"'.format(
|
||||
newvalue, self.fwo[key]['validexpression']))
|
||||
newnewvalues.append(newvalue)
|
||||
if len(newnewvalues) == 1:
|
||||
self.fwo[key]['new_value'] = newnewvalues[0]
|
||||
|
||||
Reference in New Issue
Block a user