2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-31 01:56:39 +00:00

refine validatehelper

This commit is contained in:
immarvin 2018-03-28 05:53:12 -04:00
parent 9fe1bac09a
commit 4dbbd5f3be
2 changed files with 16 additions and 19 deletions

View File

@ -38,15 +38,15 @@ cmd: /opt/xcat/share/xcat/tools/autotest/testcase/xcat-inventory/validatehelper
check: rc!=0
cmd: /opt/xcat/share/xcat/tools/autotest/testcase/xcat-inventory/validatehelper "osimage" "testosimage1" "rootfstype" "nfs" "/tmp/xcat_inventory_import_validation_osimage/trash/"
cmd: /opt/xcat/share/xcat/tools/autotest/testcase/xcat-inventory/validatehelper "osimage" "testosimage1" "genimgoptions.rootfstype" "nfs" "/tmp/xcat_inventory_import_validation_osimage/trash/"
check: rc==0
cmd: /opt/xcat/share/xcat/tools/autotest/testcase/xcat-inventory/validatehelper "osimage" "testosimage1" "rootfstype" "ramdisk" "/tmp/xcat_inventory_import_validation_osimage/trash/"
cmd: /opt/xcat/share/xcat/tools/autotest/testcase/xcat-inventory/validatehelper "osimage" "testosimage1" "genimgoptions.rootfstype" "ramdisk" "/tmp/xcat_inventory_import_validation_osimage/trash/"
check: rc==0
cmd: /opt/xcat/share/xcat/tools/autotest/testcase/xcat-inventory/validatehelper "osimage" "testosimage1" "rootfstype" "invalid" "/tmp/xcat_inventory_import_validation_osimage/trash/"
cmd: /opt/xcat/share/xcat/tools/autotest/testcase/xcat-inventory/validatehelper "osimage" "testosimage1" "genimgoptions.rootfstype" "invalid" "/tmp/xcat_inventory_import_validation_osimage/trash/"
check: rc!=0
cmd: /opt/xcat/share/xcat/tools/autotest/testcase/xcat-inventory/validatehelper "osimage" "testosimage1" "rootfstype" "" "/tmp/xcat_inventory_import_validation_osimage/trash/"
cmd: /opt/xcat/share/xcat/tools/autotest/testcase/xcat-inventory/validatehelper "osimage" "testosimage1" "genimgoptions.rootfstype" "" "/tmp/xcat_inventory_import_validation_osimage/trash/"
check: rc==0
cmd: cat /tmp/xcat_inventory_import_validation_osimage/backup/testosimage1.stanza 2>/dev/null |mkdef -z
cmd: cat /tmp/xcat_inventory_import_validation_osimage/backup/testosimage1.stanza 2>/dev/null |mkdef -z -f
cmd: rm -rf /tmp/xcat_inventory_import_validation_osimage
end

View File

@ -67,15 +67,13 @@ def GetAttrInFile(fpath,objtype,objname,attrpath):
return myvalue
def compattr(exptattr,rawattr):
if isinstance(exptattr,list) and isinstance(rawattr,str):
if isinstance(exptattr,list) and re.match(r'^\[.*\]$',rawattr):
rawattr=eval(rawattr)
if isinstance(rawattr,str):
if rawattr in exptattr:
return 0
else:
return 1
if isinstance(rawattr,str):
if rawattr in exptattr:
return 0
else:
return cmp(exptattr,rawattr)
return 1
else:
return cmp(exptattr,rawattr)
@ -121,14 +119,13 @@ def UpdateAttrInFile(fpath,fformat,objtype,objname,attrpath,value):
else:
origobjdict=Util_getdictval(objdict,myattrpath)
origattrtype=type(origobjdict)
if origattrtype != str and type(value) == str:
print(value)
newvalue=value
if origattrtype == list and re.match(r'^\[.*\]$',value):
#import pdb
#pdb.set_trace()
newvalue=eval(value)
else:
if isinstance(origobjdict,list) and isinstance(value,str):
newvalue=[value]
else:
newvalue=value
if isinstance(origobjdict,list) and isinstance(newvalue,str):
newvalue=[newvalue]
Util_setdictval(objdict,myattrpath,newvalue)
f=open(fpath,'w')
if fformat == "yaml":