Search code examples
xmlxsdwbem

How do I associate instances in xmlCIM?


I am using the Common Information Model (CIM) to model an infrastructure. The model describes a number of classes for different IT systems. It is comprehensive, so that it consists of a series hierarchies rather than one. For example, to represent a physical server chassis, you define an instance of CIM_Chassis. Then to represent the logical server that would run on that hardware, you define an instance of CIM_ComputerSystem. You should then associate the two with an instance of CIM_SystemPackaging, to note that one is provided by the other. There's no property in either class where you can set one as property of another. They are two separate classes, associated by the third. The model will be described in XML, validated by the current XML Schema for CIM. I don't understand from the XSD for CIM_SystemPackaging, what content it is supposed to contain.

This XML demonstrates the problem (chassis is the alias for CIM_Chassis.xsd, etc.):

<chassis:CIM_Chassis>
  <chassis:CreationClassName>CIM_Chassis</chassis:CreationClassName>    
  <chassis:Manufacturer>Cisco</chassis:Manufacturer>
  <chassis:Model>Catalyst 6000</chassis:Model>
  <chassis:Tag>6548431</chassis:Tag>
</chassis:CIM_Chassis>

<computer:CIM_ComputerSystem>
  <computer:CreationClassName>CIM_ComputerSystem</computer:CreationClassName>
  <computer:Name>Switch1</computer:Name>
</computer:CIM_ComputerSystem>

<sp:CIM_SystemPackaging>
  <sp:Antecedent>?</sp:Antecedent>
  <sp:Dependent>?</sp:Dependent>
</sp:CIM_SystemPackaging>

What should I put where the ? are? The schema documentation is silent on the matter, and there seem to be no XML examples on the web. This does not validate:

E [Xerces] cvc-complex-type.2.4.b: The content of element 'sp:Antecedent' is not complete. One of '{WC[##other:"http://schemas.dmtf.org/wbem/wscim/1/common",""]}' is expected.

In the Schema, Dependent and Antecedent are of type cimReference, which is:

<xs:complexType name="cimReference">
  <xs:sequence>
    <xs:any namespace="##other" maxOccurs="unbounded" processContents="lax"/>
  </xs:sequence>
  <xs:anyAttribute namespace="##any" processContents="lax"/>
</xs:complexType>

So that doesn't help me much. I wondered if I am meant to do embed the instance inside the antecedent:

<sp:CIM_SystemPackaging>
  <sp:Antecedent>
    <chassis:CIM_Chassis>
      ...etc...
    </chassis:CIM_Chassis>
  </sp:Antecedent>
  <sp:Dependent>
    <computer:CIM_ComputerSystem>
      ...etc...
    </computer:CIM_ComputerSystem>
  </sp:Dependent>
</sp:CIM_SystemPackaging>

This validates OK, but wouldn't seem to scale. Since there could be an object for each piece of hardware inside the chassis, and they all need to be associated with the chassis with similar association classes, it would quickly become impossible. It also seems to go against the whole association model. Is anyone familiar enough with CIM to explain how it is supposed to work?


Solution

  • I eventually found the below in DSP0230:

    "The xs:any element in this definition [cim:cimReference] represents a structure of a single transport reference that uniquely identifies a location to which messages may be directed for the referenced entity. This structure may be either a single element that expresses the complete transport reference or a sequence of elements, if the transport reference requires multiple elements to uniquely identify a location."

    Given example:

    <AssociatedComponent xmlns:wsa="http://www.w3.org/2005/08/addressing">
      <wsa:Address>. . .</wsa:Address>
    </AssociatedComponent>
    

    Given that CIM was intended for over-the-network management rather than static representation, it sort of makes sense that it would be a reference to somewhere else rather than something else. I conclude that I can put anything I like in, and will need in my application logic to handle the references. Since most objects have an InstanceID element, I will use that as the reference target:

    <chassis:CIM_Chassis>
      <chassis:CreationClassName>CIM_Chassis</chassis:CreationClassName>    
      <chassis:InstanceID>uniqueid1</chassis:InstanceID>
      <chassis:Manufacturer>Cisco</chassis:Manufacturer>
      <chassis:Model>Catalyst 6000</chassis:Model>
      <chassis:Tag>6548431</chassis:Tag>
    </chassis:CIM_Chassis>
    
    <computer:CIM_ComputerSystem>
      <computer:CreationClassName>CIM_ComputerSystem</computer:CreationClassName>
      <computer:InstanceID>uniqueid2</computer:InstanceID>
      <computer:Name>Switch1</computer:Name>
    </computer:CIM_ComputerSystem>
    
    <sp:CIM_SystemPackaging>
      <sp:Antecedent>
        <chassis:InstanceID>unqiueid1</chassis:InstanceID>
      </sp:Antecedent>
      <sp:Dependent>
        <computer:InstanceID>unqiueid2</computer:InstanceID>
      </sp:Dependent>
    </sp:CIM_SystemPackaging>