Validating an
XML Request Using RACK-IN.xsd
Example of Use of the
RACK-IN.xsd for an Invalid configResolveClass Request
Request:
$cat myXMLRequest.xml
<configResolveClass cookie="1360626069/7189c2b0-d57b-157b-8002-f4759de53d50"
inHierarchical="false"/>
Validating the
request:
/usr/bin/xmllint –schema ./RACK-IN.xsd myXMLRequest.xml
<configResolveClass cookie="1360626069/7189c2b0-d57b-157b-8002-f4759de53d50"
inHierarchical="false"/>
Response:
myXMLRequest.xml:1: element configResolveClass:
Schemas validity error : Element 'configResolveClass': The attribute 'classId' is required but missing.
In the preceding example,
validation of the XML request fails and displays an error because the 'classId'
is missing in the request.
Example of Use of the
RACK-IN.xsd for a Valid configResolveClass Request
Request:
$cat myXMLRequest.xml
<configResolveClass cookie="1360626069/7189c2b0-d57b-157b-8002-f4759de53d50"
inHierarchical="false" classId="topSystem"/>
Request:
/usr/bin/xmllint -schema ./RACK-IN.xsd myXMLRequest.xml
<configResolveClass cookie="1360626069/7189c2b0-d57b-157b-8002-f4759de53d50"
inHierarchical="false" classId="topSystem"/>
In the preceding
example, validation of the XML request for a classResolveClass is successful
and the response is displayed.
Example of Use of the
RACK-IN.xsd for an Invalid configConfMo Request
Request:
$cat setRackUnit.xml
<configConfMo cookie="1300242644/ad04d239-d1aa-498d-b074-ccb923066003"
dn="sys/rack-unit-1" inHierarchical="false">
<inConfig>
<computeRackUnit adminPower="down" usrLbl="UCS C240 M3 For Demo"
availableMemory="16384" dn="sys/rack-unit-1"/>
</inConfig>
</configConfMo>
Validating the
request:
/usr/bin/xmllint -schema ./RACK-IN.xsd /setRackUnit.xml
<configConfMo cookie="1300242644/ad04d239-d1aa-498d-b074-ccb923066003"
dn="sys/rack-unit-1"inHierarchical="false">
<inConfig>
<computeRackUnit adminPower="down" usrLbl="UCS C240 M3 For Demo"
availableMemory="16384" dn="sys/rack-unit-1"/>
</inConfig>
</configConfMo>
Response:
/setRackUnit.xml:3: element computeRackUnit: Schemas validity error :
Element 'computeRackUnit', attribute 'availableMemory': The attribute 'availableMemory' is not allowed.
/setRackUnit.xml fails to validate
The availableMemory
attribute is read-only in the computeRackUnit class. You can view the
read/write attributes in computeRackUnit that can be set using configCongMo XML
by looking at the computeRackUnit definition in RACK-IN.xsd. A sample snippet
is as follows:
<!--computeRackUnit-->
<xs:element name="computeRackUnit" type="computeRackUnit" substitutionGroup="managedObject"/>
<xs:complexType name="computeRackUnit" mixed="true">
<xs:attribute name="adminPower">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="up"/>
<xs:enumeration value="down"/>
<xs:enumeration value="soft-shut-down"/>
<xs:enumeration value="cycle-immediate"/>
<xs:enumeration value="hard-reset-immediate"/>
<xs:enumeration value="bmc-reset-immediate"/>
<xs:enumeration value="bmc-reset-default"/>
<xs:enumeration value="cmos-reset-immediate"/>
<xs:enumeration value="diagnostic-interrupt"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="usrLbl">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[ !#$%&\(\)\*\+,\-\./:;\?@\[\]_\{\|\}~a-zA-Z0-9]{0,64}"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="dn" type="referenceObject"/>
<xs:attribute name="rn" type="referenceRn"/>
<xs:attribute name="status" type="objectStatus"/>
</xs:complexType>
Example of Use of the
RACK-IN.xsd for an Invalid configConfMo Request
Request:
$ cat setBootOrder.xml
<configConfMo cookie="1360205300/79c672f0-d519-1519-8004-30339ee53d50"
inHierarchical="true" dn="sys/rack-unit-1/boot-policy">
<inConfig>
<lsbootDef dn="sys/rack-unit-1/boot-policy" name="boot-policy" purpose="operational" rebootOnUpdate="no">
<lsbootVirtualMedia access="read-only" order="2" type="virtual-media" rn="vm-read-only"/>
<lsbootVirtualMedia access="read-write" order="3" type="virtual-media" rn="vm-read-write"/>
<lsbootLan rn="lan-read-only" access="read-only" order="4" prot="pxe" type="lan"/>
<lsbootStorage rn="storage-read-write" access="read-write" order="1" type="storage">
<lsbootLocalStorage rn="local-storage"/>
</lsbootStorage>
<lsbootEfi rn="efi-read-only" access="read-only" order="5" type="efi"/>
</lsbootDef>
</inConfig>
</configConfMo>
Validating the
request:
/usr/bin/xmllint -schema ./RACK-IN.xsd ./setBootOrder.xml
<configConfMo cookie="1360205300/79c672f0-d519-1519-8004-30339ee53d50"
inHierarchical="true" dn="sys/rack-unit-1/boot-policy">
<inConfig>
<lsbootDef dn="sys/rack-unit-1/boot-policy" name="boot-policy" purpose="operational" rebootOnUpdate="no">
<lsbootVirtualMedia access="read-only" order="2" type="virtual-media" rn="vm-read-only"/>
<lsbootVirtualMedia access="read-write" order="3" type="virtual-media" rn="vm-read-write"/>
<lsbootLan rn="lan-read-only" access="read-only" order="4" prot="pxe" type="lan"/>
<lsbootStorage rn="storage-read-write" access="read-write" order="1" type="storage">
<lsbootLocalStorage rn="local-storage"/>
</lsbootStorage>
<lsbootEfi rn="efi-read-only" access="read-only" order="5" type="efi"/>
</lsbootDef>
</inConfig>
</configConfMo>
Response:
./setBootOrder.xml:3: element lsbootDef: Schemas validity error :
Element 'lsbootDef', attribute 'name': The attribute 'name' is not allowed.
./setBootOrder.xml:3: element lsbootDef: Schemas validity error :
Element 'lsbootDef', attribute 'purpose': The attribute 'purpose' is not allowed.
./setBootOrder.xml fails to validate
Name and purpose
attributes of class lsBootDef are read-only and cannot be used in the
configConMo/set request.
Example of Use of the
RACK-IN.xsd for a Valid configConfMo Request
Request:
usr/bin/xmllint -schema ./RACK-IN.xsd /setRackUnit.xml
<configConfMo cookie="1300242644/ad04d239-d1aa-498d-b074-ccb923066003"
dn="sys/rack-unit-1" inHierarchical="false">
<inConfig>
<computeRackUnit adminPower="down" usrLbl="UCS C240 M3 For Demo" dn="sys/rack-unit-1"/>
</inConfig>
</configConfMo>
xsd file validates
the request and completes the configuration.