diff --git a/pyghmi/ipmi/oem/lenovo/config.py b/pyghmi/ipmi/oem/lenovo/config.py index 5a3758f4..4f7d9c47 100644 --- a/pyghmi/ipmi/oem/lenovo/config.py +++ b/pyghmi/ipmi/oem/lenovo/config.py @@ -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: diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index 51ffe521..32ed8783 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -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] diff --git a/pyghmi/redfish/oem/lenovo/xcc.py b/pyghmi/redfish/oem/lenovo/xcc.py index a11dd458..e4ec6da4 100644 --- a/pyghmi/redfish/oem/lenovo/xcc.py +++ b/pyghmi/redfish/oem/lenovo/xcc.py @@ -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]