1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """
24
25 Functions to create XML documens and elements conforming to the DMTF
26 standard DSP0201, Representation of CIM in XML, v2.2.
27
28 http://www.dmtf.org/standards/wbem/DSP201.html
29 http://www.dmtf.org/standards/published_documents/DSP201.pdf
30
31 Elements generated by this module should conform to version 2.2 of the
32 DTD:
33
34 http://www.dmtf.org/standards/wbem/CIM_DTD_V22.dtd
35
36 There should be one class for each element described in the DTD. The
37 constructors take builtin Python types, or other cim_xml classes where
38 child elements are required.
39
40 Every class is a subclass of the Element class and so shares the same
41 attributes and methods, and can be used with the built-in Python XML
42 handling routines. In particular you can call the toxml() and
43 toprettyxml() methods to generate XML.
44
45 Note that converting using toprettyxml() inserts whitespace which may
46 corrupt the data in the XML (!!) so you should only do this when
47 displaying to humans who can ignore it, and never for computers. XML
48 always passes through all non-markup whitespace.
49
50 """
51
52 import sys
53 import xml.dom.minidom
54 from xml.dom.minidom import Element
55
56 __all__ = ['CIMElement', 'CIM', 'DECLARATION', 'DECLGROUP',
57 'DECLGROUP_WITHNAME', 'DECLGROUP_WITHPATH', 'QUALIFIER_DECLARATION',
58 'SCOPE', 'VALUE', 'VALUE_ARRAY', 'VALUE_REFERENCE',
59 'VALUE_REFARRAY', 'VALUE_OBJECT', 'VALUE_NAMEDINSTANCE',
60 'VALUE_NAMEDOBJECT', 'VALUE_OBJECTWITHLOCALPATH',
61 'VALUE_OBJECTWITHPATH', 'VALUE_NULL', 'NAMESPACEPATH',
62 'LOCALNAMESPACEPATH', 'HOST', 'NAMESPACE', 'CLASSPATH',
63 'LOCALCLASSPATH', 'CLASSNAME', 'INSTANCEPATH', 'LOCALINSTANCEPATH',
64 'INSTANCENAME', 'OBJECTPATH', 'KEYBINDING', 'KEYVALUE', 'CLASS',
65 'INSTANCE', 'QUALIFIER', 'PROPERTY', 'PROPERTY_ARRAY',
66 'PROPERTY_REFERENCE', 'METHOD', 'PARAMETER', 'PARAMETER_REFERENCE',
67 'PARAMETER_ARRAY', 'PARAMETER_REFARRAY',
68 'TABLECELL_DECLARATION', 'TABLECELL_REFERENCE',
69 'TABLEROW_DECLARATION', 'TABLE','TABLEROW',
70 'MESSAGE', 'MULTIREQ', 'MULTIEXPREQ', 'SIMPLEREQ', 'SIMPLEEXPREQ',
71 'IMETHODCALL', 'METHODCALL', 'EXPMETHODCALL', 'PARAMVALUE',
72 'IPARAMVALUE', 'EXPPARAMVALUE', 'MULTIRSP', 'MULTIEXPRSP',
73 'SIMPLERSP', 'SIMPLEEXPRSP', 'METHODRESPONSE', 'EXPMETHODRESPONSE',
74 'IMETHODRESPONSE', 'ERROR', 'RETURNVALUE', 'IRETURNVALUE',
75 'RESPONSEDESTINATION', 'SIMPLEREQACK']
76
78 """Return a minidom text node with the specified data string.
79
80 When converting that node to an XML string using ``toxml()``, XML-escaping
81 will be applied if needed (for example, ``_text('&').toxml() = '&'``).
82
83 Note: The API for the minidom text node function has changed in
84 Python 2.3. The code for older Python versions has been removed from this
85 function in PyWBEM 0.8.0; the Python version check is now done in
86 __init__.py.
87 """
88
89
90 t = xml.dom.minidom.Text()
91 t.data = data
92
93 return t
94
95
96
97
98
99
100
101
102
103 _CDATA_ESCAPING = False
104
106 """Return a list of minidom nodes with the properly escaped ``pcdata``
107 inside.
108
109 The following special XML characters are escaped:
110 * left angle bracket (<)
111 * Right angle bracket (>)
112 * Ampersand (&)
113
114 By default, XML-based escaping is used for these characters. XML-based
115 escaping will cause the corresponding XML entity references to be used
116 (for example, the ampersand character ``&`` will be represented as
117 ``&``, and the returned list contains one text node with the escaped
118 pcdata string.
119
120 Nesting of escaped pcdata is naturally supported with XML-based escaping.
121 For example, if the pcdata string is ``a&b``, the XML-escaped string
122 will be ``a&amp;b``.
123
124 If the ``cim_xml._CDATA_ESCAPING`` switch is set to True, CDATA-based
125 escaping is used instead. CDATA-based escaping will cause a CDATA section
126 to be used for the entire string, or consecutive CDATA sequences (see
127 discussion of nesting, below). The returned node list contains only CDATA
128 section nodes. Example: The pcdata string ``a<b>c`` will become
129 ``<![CDATA[a<b>]]>``, allowing the special XML characters to be used
130 unchanged inside of the CDATA section.
131
132 Nesting of escaped pcdata is supported with CDATA-based escaping, by using
133 the following approach: If the input pcdata string already contains CDATA
134 sections, they are split into separate strings, splitting the CDATA end
135 token string in the middle, and these part strings are CDATA-escaped
136 separately. See http://en.wikipedia.org/wiki/CDATA#Nesting for details.
137
138 Escaping of already escaped pcdata is needed in support of nested embedded
139 instances. That requires that each level of escaping can lateron be
140 unescaped, one at a time.
141 """
142
143 nodelist = []
144
145 if _CDATA_ESCAPING and type(pcdata) in (str,unicode) and \
146 (pcdata.find("<") >= 0 or \
147 pcdata.find(">") >= 0 or \
148 pcdata.find("&") >= 0):
149
150
151
152
153
154
155 pcdata_part_list = pcdata.split("]]>")
156
157
158 i = 0
159 for pcdata_part in pcdata_part_list:
160 i += 1
161
162 left = "" if i == 1 else "]>"
163
164
165 right = "" if i == len(pcdata_part_list) else "]"
166
167
168
169
170 node = xml.dom.minidom.CDATASection()
171 node.data = left + pcdata_part + right
172
173 nodelist.append(node)
174
175 else:
176
177
178 node = _text(pcdata)
179
180 nodelist.append(node)
181
182 return nodelist
183
185 """A base class that has a few bonus helper methods."""
186
188 """Set the NAME attribute of the element."""
189 self.setAttribute('NAME', name)
190
192 """Set an attribute if the value parameter is not None."""
193 if value is not None:
194 self.setAttribute(name, value)
195
197 """Append a child element which can be None."""
198 if child is not None:
199 self.appendChild(child)
200
202 """Append a list or tuple of children."""
203 [self.appendChild(child) for child in children]
204
205
206
207 -class CIM(CIMElement):
208 """
209 The CIM element is the root element of every XML Document that is
210 valid with respect to this schema.
211
212 Each document takes one of two forms; it either contains a single
213 MESSAGE element defining a CIM message (to be used in the HTTP
214 mapping), or it contains a DECLARATION element used to declare a
215 set of CIM objects.
216
217 <!ELEMENT CIM (MESSAGE | DECLARATION)>
218 <!ATTLIST CIM
219 CIMVERSION CDATA #REQUIRED
220 DTDVERSION CDATA #REQUIRED>
221 """
222
223 - def __init__(self, data, cim_version, dtd_version):
224 Element.__init__(self, 'CIM')
225 self.setAttribute('CIMVERSION', cim_version)
226 self.setAttribute('DTDVERSION', dtd_version)
227 self.appendChild(data)
228
229
230
232 """
233 The DECLARATION element defines a set of one or more declarations
234 of CIM objects. These are partitioned into logical declaration
235 subsets.
236
237 <!ELEMENT DECLARATION (DECLGROUP | DECLGROUP.WITHNAME |
238 DECLGROUP.WITHPATH)+>
239 """
240
244
246 """
247 The DECLGROUP element defines a logical set of CIM Class, Instance
248 and Qualifier declarations. It MAY optionally include a
249 NAMESPACEPATH or LOCALNAMESPACEPATH element which, if present,
250 defines the common namespace in which all objects within the group
251 are declared.
252
253 <!ELEMENT DECLGROUP ((LOCALNAMESPACEPATH | NAMESPACEPATH)?,
254 QUALIFIER.DECLARATION*, VALUE.OBJECT*)>
255 """
256
260
262
263 """
264 The DECLGROUP.WITHNAME element defines a logical set of CIM Class,
265 Instance and Qualifier declarations. It MAY optionally include a
266 NAMESPACEPATH or LOCALNAMESPACEPATH element which, if present,
267 defines the common namespace in which all objects within the group
268 are declared.
269
270 <!ELEMENT DECLGROUP.WITHNAME ((LOCALNAMESPACEPATH | NAMESPACEPATH)?,
271 QUALIFIER.DECLARATION*, VALUE.NAMEDOBJECT*)>
272 """
273
277
279
280 """
281 The DECLGROUP.WITHPATH element defines a logical set of CIM Class
282 and Instance declarations. Each object is declared with its own
283 independent naming and location information.
284
285 <!ELEMENT DECLGROUP.WITHPATH (VALUE.OBJECTWITHPATH |
286 VALUE.OBJECTWITHLOCALPATH)*>
287 """
288
292
294
295 """
296 The QUALIFIER.DECLARATION element defines a single CIM Qualifier
297 declaration.
298
299 <!ELEMENT QUALIFIER.DECLARATION (SCOPE?, (VALUE | VALUE.ARRAY)?)>
300 <!ATTLIST QUALIFIER.DECLARATION
301 %CIMName;
302 %CIMType; #REQUIRED
303 ISARRAY (true|false) #IMPLIED
304 %ArraySize;
305 %QualifierFlavor;>
306 """
307
308 - def __init__(self, name, type, value, is_array=None,
309 array_size=None, qualifier_scopes={},
310 overridable=None, tosubclass=None,
311 toinstance=None, translatable=None):
312
313 Element.__init__(self, 'QUALIFIER.DECLARATION')
314 self.setName(name)
315 self.setAttribute('TYPE', type)
316 if is_array is not None:
317 self.setOptionalAttribute('ISARRAY', str(is_array).lower())
318 if array_size is not None:
319 self.setAttribute('ARRAYSIZE', str(array_size))
320 if overridable is not None:
321 self.setAttribute('OVERRIDABLE', str(overridable).lower())
322 if tosubclass is not None:
323 self.setAttribute('TOSUBCLASS', str(tosubclass).lower())
324 if toinstance is not None:
325 self.setAttribute('TOINSTANCE', str(toinstance).lower())
326 if translatable is not None:
327 self.setAttribute('TRANSLATABLE', str(translatable).lower())
328
329 if qualifier_scopes:
330 scope = SCOPE(qualifier_scopes)
331 self.appendOptionalChild(scope)
332 if value is not None:
333 if is_array:
334 xval = VALUE_ARRAY(value)
335 else:
336 xval = VALUE(value)
337 self.appendOptionalChild(xval)
338
340 """
341 The SCOPE element defines the scope of a QUALIFIER.DECLARATION in
342 the case that there are restrictions on the scope of the Qualifier
343 declaration.
344
345 <!ELEMENT SCOPE EMPTY>
346 <!ATTLIST SCOPE
347 CLASS (true|false) 'false'
348 ASSOCIATION (true|false) 'false'
349 REFERENCE (true|false) 'false'
350 PROPERTY (true|false) 'false'
351 METHOD (true|false) 'false'
352 PARAMETER (true|false) 'false'
353 INDICATION (true|false) 'false'>
354 """
355
357 Element.__init__(self, 'SCOPE')
358 if 'any' in scopes and scopes['any']:
359 scopes = {'CLASS': True,
360 'ASSOCIATION': True,
361 'REFERENCE': True,
362 'PROPERTY': True,
363 'METHOD': True,
364 'PARAMETER': True,
365 'INDICATION': True}
366 for k, v in scopes.items():
367 self.setOptionalAttribute(k, str(v).lower())
368
369
370
372 """
373 The VALUE element is used to define a single (non-array and
374 non-reference) CIM Property value, CIM Qualifier value, or a CIM
375 Method Parameter value.
376
377 <!ELEMENT VALUE (#PCDATA)>
378 """
379
384
386
387 """
388 The VALUE.ARRAY element is used to represent the value of a CIM
389 Property or Qualifier that has an array type.
390
391 <!ELEMENT VALUE.ARRAY (VALUE*)>
392 """
393
397
399
400 """
401 The VALUE.REFERENCE element is used to define a single CIM
402 reference Property value.
403
404 <!ELEMENT VALUE.REFERENCE (CLASSPATH | LOCALCLASSPATH | CLASSNAME |
405 INSTANCEPATH | LOCALINSTANCEPATH |
406 INSTANCENAME)>
407 """
408
410 Element.__init__(self, 'VALUE.REFERENCE')
411 self.appendChild(data)
412
414
415 """
416 The VALUE.REFARRAY element is used to represent the value of an
417 array of CIM references.
418
419 <!ELEMENT VALUE.REFARRAY (VALUE.REFERENCE*)>
420 """
421
425
427
428 """
429 The VALUE.OBJECT element is used to define a value which is
430 comprised of a single CIM Class or Instance definition.
431
432 <!ELEMENT VALUE.OBJECT (CLASS | INSTANCE)>
433 """
434
436 Element.__init__(self, 'VALUE.OBJECT')
437 self.appendChild(data)
438
440
441 """
442 The VALUE.NAMEDINSTANCE element is used to define a value which
443 is comprised of a single named CIM Instance definition.
444
445 <!ELEMENT VALUE.NAMEDINSTANCE (INSTANCENAME, INSTANCE)>
446 """
447
448 - def __init__(self, instancename, instance):
449 Element.__init__(self, 'VALUE.NAMEDINSTANCE')
450 self.appendChild(instancename)
451 self.appendChild(instance)
452
454
455 """
456 The VALUE.NAMEDOBJECT element is used to define a value which
457 is comprised of a single named CIM Class or Instance definition.
458
459 <!ELEMENT VALUE.NAMEDOBJECT (CLASS | (INSTANCENAME, INSTANCE))>
460 """
461
463 Element.__init__(self, 'VALUE.NAMEDOBJECT')
464 if type(data) == tuple or type(data) == list:
465 self.appendChildren(data)
466 else:
467 self.appendChild(data)
468
470
471 """
472 The VALUE.OBJECTWITHLOCALPATH element is used to define a value
473 which is comprised of a single CIM Object (Class or Instance)
474 definition with additional information that defines the local path
475 to that Object.
476
477 <!ELEMENT VALUE.OBJECTWITHLOCALPATH ((LOCALCLASSPATH, CLASS) |
478 (LOCALINSTANCEPATH, INSTANCE))>
479 """
480
482 Element.__init__(self, 'VALUE.OBJECTWITHLOCALPATH')
483 self.appendChild(data1)
484 self.appendChild(data2)
485
487
488 """
489 The VALUE.OBJECTWITHPATH element is used to define a value
490 which is comprised of a single CIM Object (Class or Instance)
491 definition with additional information that defines the absolute
492 path to that Object.
493
494 <!ELEMENT VALUE.OBJECTWITHPATH ((CLASSPATH, CLASS) |
495 (INSTANCEPATH, INSTANCE))>
496 """
497
499 Element.__init__(self, 'VALUE.OBJECTWITHPATH')
500 self.appendChild(data1)
501 self.appendChild(data2)
502
504
505 """
506 The VALUE.NULL element is used to represent a TABLECELL that has
507 no assigned value.
508
509 <!ELEMENT VALUE.NULL EMPTY>
510 """
511
513 Element.__init__(self, 'VALUE.NULL')
514
515
516
518
519 """
520 The NAMESPACEPATH element is used to define a Namespace Path. It
521 consists of a HOST element and a LOCALNAMESPACE element.
522
523 <!ELEMENT NAMESPACEPATH (HOST, LOCALNAMESPACEPATH)>
524 """
525
526 - def __init__(self, host, localnamespacepath):
527 Element.__init__(self, 'NAMESPACEPATH')
528 self.appendChild(host)
529 self.appendChild(localnamespacepath)
530
532
533 """
534 The LOCALNAMESPACEPATH element is used to define a local Namespace
535 path (one without a Host component). It consists of one or more
536 NAMESPACE elements (one for each namespace in the path).
537
538 <!ELEMENT LOCALNAMESPACEPATH (NAMESPACE+)>
539 """
540
544
545 -class HOST(CIMElement):
546
547 """
548 The HOST element is used to define a single Host. The element
549 content MUST specify a legal value for a hostname in accordance
550 with the CIM specification.
551
552 <!ELEMENT HOST (#PCDATA)>
553 """
554
556 Element.__init__(self, 'HOST')
557 self.appendChild(_text(pcdata))
558
560
561 """
562 The NAMESPACE element is used to define a single Namespace
563 component of a Namespace path.
564
565 <!ELEMENT NAMESPACE EMPTY>
566 <!ATTLIST NAMESPACE
567 %CIMName;>
568 """
569
573
575
576 """
577 The CLASSPATH element defines the absolute path to a CIM Class. It
578 is formed from a namespace path and Class name.
579
580 <!ELEMENT CLASSPATH (NAMESPACEPATH, CLASSNAME)>
581 """
582
583 - def __init__(self, namespacepath, classname):
584 Element.__init__(self, 'CLASSPATH')
585 self.appendChild(namespacepath)
586 self.appendChild(classname)
587
588
590
591 """
592 The LOCALCLASSPATH element defines the a local path to a CIM
593 Class. It is formed from a local namespace path and Class name.
594
595 <!ELEMENT LOCALCLASSPATH (LOCALNAMESPACEPATH, CLASSNAME)>
596 """
597
598 - def __init__(self, localnamespacepath, classname):
599 Element.__init__(self, 'LOCALCLASSPATH')
600 self.appendChild(localnamespacepath)
601 self.appendChild(classname)
602
604
605 """
606 The CLASSNAME element defines the qualifying name of a CIM Class.
607
608 <!ELEMENT CLASSNAME EMPTY>
609 <!ATTLIST CLASSNAME
610 %CIMName;>
611 """
612
616
618
619 """
620 The INSTANCEPATH element defines the absolute path to a CIM
621 Instance. It is comprised of a Namespace path and an Instance Name
622 (model path).
623
624 <!ELEMENT INSTANCEPATH (NAMESPACEPATH, INSTANCENAME)>
625 """
626
627 - def __init__(self, namespacepath, instancename):
628 Element.__init__(self, 'INSTANCEPATH')
629 self.appendChild(namespacepath)
630 self.appendChild(instancename)
631
633
634 """
635 The LOCALINSTANCEPATH element defines the local path to a CIM
636 Instance. It is comprised of a local Namespace path and an
637 Instance Name (model path).
638
639 <!ELEMENT LOCALINSTANCEPATH (LOCALNAMESPACEPATH, INSTANCENAME)>
640 """
641
642 - def __init__(self, localpath, instancename):
643 Element.__init__(self, 'LOCALINSTANCEPATH')
644 self.appendChild(localpath)
645 self.appendChild(instancename)
646
648
649 """
650 The INSTANCENAME element defines the location of a CIM Instance
651 within a Namespace (it is referred to in the CIM Specification
652 as a Model Path). It is comprised of a class name and a key
653 binding information.
654
655 If the Class has a single key property, then a single KEYVALUE or
656 VALUE.REFERENCE subelement may be used to describe the
657 (necessarily) unique key value without a key name. Alternatively a
658 single KEYBINDING subelement may be used instead.
659
660 If the Class has more than one key property, then a KEYBINDING
661 subelement MUST appear for each key.
662
663 If there are no key-bindings specified, the instance is assumed to
664 be a singleton instance of a keyless Class.
665
666 <!ELEMENT INSTANCENAME (KEYBINDING* | KEYVALUE? | VALUE.REFERENCE?)>
667 <!ATTLIST INSTANCENAME
668 %ClassName;>
669 """
670
672 Element.__init__(self, 'INSTANCENAME')
673 self.setAttribute('CLASSNAME', classname)
674 if data is not None:
675 if type(data) == list:
676 self.appendChildren(data)
677 else:
678 self.appendChild(data)
679
681
682 """
683 The OBJECTPATH element is used to define a full path to a single
684 CIM Object (Class or Instance).
685
686 <!ELEMENT OBJECTPATH (INSTANCEPATH | CLASSPATH)>
687 """
688
690 Element.__init__(self, 'OBJECTPATH')
691 self.appendChild(data)
692
694
695 """
696 The KEYBINDING element defines a single key property value binding.
697
698 <!ELEMENT KEYBINDING (KEYVALUE | VALUE.REFERENCE)>
699 <!ATTLIST KEYBINDING
700 %CIMName;>
701 """
702
704 Element.__init__(self, 'KEYBINDING')
705 self.setName(name)
706 self.appendChild(data)
707
709
710 """
711 The KEYVALUE element defines a single property key value when the
712 key property is a non-reference type.
713
714 <!ELEMENT KEYVALUE (#PCDATA)>
715 <!ATTLIST KEYVALUE
716 VALUETYPE (string|boolean|numeric) 'string'
717 %CIMType; #IMPLIED>
718 """
719
720 - def __init__(self, data, value_type=None, cim_type=None):
721
722 Element.__init__(self, 'KEYVALUE')
723
724 if value_type is None:
725 self.setAttribute('VALUETYPE', 'string')
726 else:
727 self.setAttribute('VALUETYPE', value_type)
728
729 self.setOptionalAttribute('TYPE', cim_type)
730
731 if data != None:
732 self.appendChild(_text(data))
733
734
735
737
738 """
739 The CLASS element defines a single CIM Class.
740
741 <!ELEMENT CLASS (QUALIFIER*, (PROPERTY | PROPERTY.ARRAY |
742 PROPERTY.REFERENCE)*, METHOD*)>
743 <!ATTLIST CLASS
744 %CIMName;
745 %SuperClass;>
746 """
747
748 - def __init__(self, classname, properties=[], methods=[],
749 qualifiers=[], superclass=None):
754
756
757 """
758 The INSTANCE element defines a single CIM Instance of a CIM Class.
759
760 <!ELEMENT INSTANCE (QUALIFIER*, (PROPERTY | PROPERTY.ARRAY |
761 PROPERTY.REFERENCE)*)>
762 <!ATTLIST INSTANCE
763 %ClassName;
764 xml:lang NMTOKEN #IMPLIED>
765 """
766 - def __init__(self, classname, properties=[], qualifiers=[],
767 xml_lang=None):
772
774
775 """
776 The QUALIFIER element defines a single CIM Qualifier. If the
777 Qualifier has a non-array type, it contains a single VALUE element
778 representing the value of the Qualifier. If the Qualifier has an
779 array type, it contains a single VALUE.ARRAY element to represent
780 the value.
781
782 If the Qualifier has no assigned value then the VALUE element MUST
783 be absent.
784
785 <!ELEMENT QUALIFIER ((VALUE | VALUE.ARRAY)?)>
786 <!ATTLIST QUALIFIER
787 %CIMName;
788 %CIMType; #REQUIRED
789 %Propagated;
790 %QualifierFlavor;
791 xml:lang NMTOKEN #IMPLIED>
792 """
793
794 - def __init__(self, name, type, value=None, propagated=None,
795 overridable=None, tosubclass=None, toinstance=None,
796 translatable=None, xml_lang=None):
797
798 Element.__init__(self, 'QUALIFIER')
799
800 self.setName(name)
801 self.setAttribute('TYPE', type)
802
803 if propagated is not None:
804 self.setAttribute('PROPAGATED', str(propagated).lower())
805
806 if overridable is not None:
807 self.setAttribute('OVERRIDABLE', str(overridable).lower())
808 if tosubclass is not None:
809 self.setAttribute('TOSUBCLASS', str(tosubclass).lower())
810 if toinstance is not None:
811 self.setAttribute('TOINSTANCE', str(toinstance).lower())
812 if translatable is not None:
813 self.setAttribute('TRANSLATABLE', str(translatable).lower())
814
815 self.setOptionalAttribute('xml:lang', xml_lang)
816
817 self.appendOptionalChild(value)
818
820
821 """
822 The PROPERTY element defines a single (non-array) CIM Property
823 that is not a reference. It contains a single VALUE element
824 representing the value of the Property.
825
826 If the Property has no assigned value then the VALUE element MUST be
827 absent.
828
829 CIM Reference Properties are described using the
830 PROPERTY.REFERENCE element.
831
832 <!ELEMENT PROPERTY (QUALIFIER*, VALUE?)>
833 <!ATTLIST PROPERTY
834 %CIMName;
835 %ClassOrigin;
836 %Propagated;
837 %CIMType; #REQUIRED
838 xml:lang NMTOKEN #IMPLIED>
839 """
840
841 - def __init__(self, name, type, value=None, class_origin=None,
842 propagated=None, qualifiers=[], xml_lang=None,
843 embedded_object=None):
876
878
879 """
880 The PROPERTY.ARRAY element defines a single CIM Property with an
881 array type. It contains a single VALUE.ARRAY element representing
882 the value of the Property.
883
884 If the Property has no assigned value then the VALUE.ARRAY element
885 MUST be absent.
886
887 There is no element to model a Property that contains an array of
888 references as this is not a valid Property type according to CIM.
889
890 <!ELEMENT PROPERTY.ARRAY (QUALIFIER*, VALUE.ARRAY?)>
891 <!ATTLIST PROPERTY.ARRAY
892 %CIMName;
893 %CIMType; #REQUIRED
894 %ArraySize;
895 %ClassOrigin;
896 %Propagated;
897 xml:lang NMTOKEN #IMPLIED>
898 """
899
900 - def __init__(self, name, type, value_array=None, array_size=None,
901 class_origin=None, propagated=None, qualifiers=[],
902 xml_lang=None, embedded_object=None):
903
904 Element.__init__(self, 'PROPERTY.ARRAY')
905
906 self.setName(name)
907 self.setAttribute('TYPE', type)
908
909 if array_size is not None:
910 self.setAttribute('ARRAYSIZE', str(array_size))
911 self.setOptionalAttribute('CLASSORIGIN', class_origin)
912 self.setOptionalAttribute('EmbeddedObject', embedded_object)
913
914
915 if propagated is not None:
916 self.setAttribute('PROPAGATED', str(propagated).lower())
917
918 self.setOptionalAttribute('xml:lang', xml_lang)
919
920 self.appendChildren(qualifiers)
921 self.appendOptionalChild(value_array)
922
924
925 """
926 The PROPERTY.REFERENCE element models a single CIM Property with
927 reference semantics. In future the features of XML Linking may
928 be used to identify linking elements within the XML Document; as
929 XML Linking is currently only at Working Draft status no explicit
930 dependencies have been made at this point.
931
932 <!ELEMENT PROPERTY.REFERENCE (QUALIFIER*, VALUE.REFERENCE?)>
933 <!ATTLIST PROPERTY.REFERENCE
934 %CIMName;
935 %ReferenceClass;
936 %ClassOrigin;
937 %Propagated;>
938 """
939
940 - def __init__(self, name, value_reference=None, reference_class=None,
941 class_origin=None, propagated=None, qualifiers=[]):
955
957
958 """
959 The METHOD element defines a single CIM Method. It may have
960 Qualifiers, and zero or more parameters.
961
962 The order of the PARAMETER, PARAMETER.REFERENCE, PARAMETER.ARRAY
963 and PARAMETER.REFARRAY subelements is not significant.
964
965 <!ELEMENT METHOD (QUALIFIER*, (PARAMETER | PARAMETER.REFERENCE |
966 PARAMETER.ARRAY | PARAMETER.REFARRAY)*)>
967 <!ATTLIST METHOD
968 %CIMName;
969 %CIMType; #IMPLIED
970 %ClassOrigin;
971 %Propagated;>
972 """
973
974 - def __init__(self, name, parameters=[], return_type=None,
975 class_origin=None, propagated=None, qualifiers=[]):
988
990
991 """
992 The PARAMETER element defines a single (non-array, non-reference)
993 Parameter to a CIM Method. The parameter MAY have zero or more
994 Qualifiers.
995
996 <!ELEMENT PARAMETER (QUALIFIER*)>
997 <!ATTLIST PARAMETER
998 %CIMName;
999 %CIMType; #REQUIRED>
1000 """
1001
1002 - def __init__(self, name, type, qualifiers=[]):
1007
1009
1010 """
1011 The PARAMETER.REFERENCE element defines a single reference
1012 Parameter to a CIM Method. The parameter MAY have zero or more
1013 Qualifiers.
1014
1015 <!ELEMENT PARAMETER.REFERENCE (QUALIFIER*)>
1016 <!ATTLIST PARAMETER.REFERENCE
1017 %CIMName;
1018 %ReferenceClass;>
1019 """
1020
1021 - def __init__(self, name, reference_class=None, qualifiers=[]):
1026
1028
1029 """
1030 The PARAMETER.ARRAY element defines a single Parameter to a CIM
1031 Method that has an array type. The parameter MAY have zero or more
1032 Qualifiers.
1033
1034 <!ELEMENT PARAMETER.ARRAY (QUALIFIER*)>
1035 <!ATTLIST PARAMETER.ARRAY
1036 %CIMName;
1037 %CIMType; #REQUIRED
1038 %ArraySize;>
1039 """
1040
1041 - def __init__(self, name, type, array_size=None, qualifiers=[]):
1042 Element.__init__(self, 'PARAMETER.ARRAY')
1043 self.setName(name)
1044 self.setAttribute('TYPE', type)
1045 if array_size is not None:
1046 self.setAttribute('ARRAYSIZE', str(array_size))
1047 self.appendChildren(qualifiers)
1048
1050
1051 """
1052 The PARAMETER.REFARRAY element defines a single Parameter to a CIM
1053 Method that has an array of references type. The parameter MAY
1054 have zero or more Qualifiers.
1055
1056 <!ELEMENT PARAMETER.REFARRAY (QUALIFIER*)>
1057 <!ATTLIST PARAMETER.REFARRAY
1058 %CIMName;
1059 %ReferenceClass;
1060 %ArraySize;>
1061 """
1062
1063 - def __init__(self, name, reference_class=None, array_size=None,
1064 qualifiers=[]):
1065 Element.__init__(self, 'PARAMETER.REFARRAY')
1066 self.setName(name)
1067 self.setOptionalAttribute('REFERENCECLASS', reference_class)
1068 if array_size is not None:
1069 self.setAttribute('ARRAYSIZE', str(array_size))
1070 self.appendChildren(qualifiers)
1071
1073
1074 """
1075 The TABLECELL.DECLARATION element describes a TABLECELL that is
1076 not a reference or an array of references.
1077
1078
1079 <!ELEMENT TABLECELL.DECLARATION EMPTY>
1080 <!ATTLIST TABLECELL.DECLARATION
1081 %CIMName;
1082 %CIMType; #REQUIRED
1083 ISARRAY (true|false) "false"
1084 %ARRAYSIZE;
1085 CELLPOS CDATA #REQUIRED
1086 SORTPOS CDATA #IMPLIED
1087 SORTDIR (ASC|DESC) #IMPLIED>
1088 """
1089
1091
1092 """
1093
1094 The TABLECELL.REFERENCE element defines a TABLECELL that contains
1095 reference or reference array values.
1096
1097 <!ELEMENT TABLECELL.REFERENCE EMPTY>
1098 <!ATTLIST TABLECELL.REFERENCE
1099 %CIMName;
1100 %ReferenceClass; #REQUIRED
1101 ISARRAY (true|false) "false"
1102 %ARRAYSIZE;
1103 CELLPOS CDATA #REQUIRED
1104 SORTPOS CDATA #IMPLIED
1105 SORTDIR (ASC|DESC) #IMPLIED>
1106 """
1107
1109
1110 """
1111
1112 The TABLEROW.DECLARATION element contains a definition for each
1113 TABLECELL in the TABLEROW.
1114
1115 <!ELEMENT TABLEROW.DECLARATION (TABLECELL.DECLARATION
1116 | TABLECELL.REFERENCE)*>
1117 """
1118
1119 -class TABLE(CIMElement):
1120
1121 """
1122 The TABLE element defines the result of a CIM Query. A TABLE
1123 element consists of a TABLEROW.DECLARATION followed by 0 or more
1124 rows.
1125
1126 <!ELEMENT TABLE(TABLEROW.DECLARATION,(TABLEROW)*)>
1127 """
1128
1130
1131 """
1132
1133 The TABLEROW element defines the values for a single row of a
1134 table. A value for each cell of the row MUST be specified. If a
1135 value has no assigned value, the VALUE.NULL element MUST be used.
1136
1137 <!ELEMENT TABLEROW (VALUE | VALUE.ARRAY | VALUE.REFERENCE |
1138 VALUE.REFARRAY | VALUE.NULL)*>
1139 """
1140
1141
1142
1144
1145 """
1146 The MESSAGE element models a single CIM message. This element is
1147 used as the basis for CIM Operation Messages and CIM Export
1148 Messages.
1149
1150 <!ELEMENT MESSAGE (SIMPLEREQ | MULTIREQ | SIMPLERSP | MULTIRSP |
1151 SIMPLEEXPREQ | MULTIEXPREQ | SIMPLEEXPRSP |
1152 MULTIEXPRSP)>
1153 <!ATTLIST MESSAGE
1154 ID CDATA #REQUIRED
1155 PROTOCOLVERSION CDATA #REQUIRED>
1156 """
1157
1158 - def __init__(self, data, message_id, protocol_version):
1159 Element.__init__(self, 'MESSAGE')
1160 self.setAttribute('ID', message_id)
1161 self.setAttribute('PROTOCOLVERSION', protocol_version)
1162 self.appendChild(data)
1163
1165
1166 """
1167 The MULTIREQ element defines a Multiple CIM Operation request. It
1168 contains two or more subelements defining the SIMPLEREQ elements
1169 that make up this multiple request.
1170
1171 <!ELEMENT MULTIREQ (SIMPLEREQ, SIMPLEREQ+)>
1172 """
1173
1177
1179
1180 """
1181 The MULTIEXPREQ element defines a Multiple CIM Export request. It
1182 contains two or more subelements defining the SIMPLEEXPREQ
1183 elements that make up this multiple request.
1184
1185 <!ELEMENT MULTIEXPREQ (SIMPLEEXPREQ, SIMPLEEXPREQ+)>
1186 """
1187
1191
1193
1194 """
1195 The SIMPLEREQ element defines a Simple CIM Operation request. It
1196 contains either a METHODCALL (extrinsic method) element or an
1197 IMETHODCALL (intrinsic method) element.
1198
1199 <!ELEMENT SIMPLEREQ (IMETHODCALL | METHODCALL)>
1200 """
1201
1203 Element.__init__(self, 'SIMPLEREQ')
1204 self.appendChild(data)
1205
1207
1208 """
1209 The SIMPLEEXPREQ element defines a Simple CIM Export request. It
1210 contains an EXPMETHODCALL (export method).
1211
1212 <!ELEMENT SIMPLEEXPREQ (EXPMETHODCALL)>
1213 """
1214
1216 Element.__init__(self, 'SIMPLEEXPREQ')
1217 self.appendChild(data)
1218
1220
1221 """
1222 The IMETHODCALL element defines a single intrinsic method
1223 invocation. It specifies the target local namespace, followed by
1224 zero or more IPARAMVALUE subelements as the parameter values to be
1225 passed to the method. If the RESPONSEDESTINATION element is
1226 specified, the intrinsic method call MUST be interpreted as an
1227 asynchronous method call.
1228
1229 <!ELEMENT IMETHODCALL (LOCALNAMESPACEPATH, IPARAMVALUE*,
1230 RESPONSEDESTINATION?)>
1231 <!ATTLIST IMETHODCALL
1232 %CIMName;>
1233 """
1234
1235 - def __init__(self, name, localnamespacepath, iparamvalues=[],
1236 responsedestination=None):
1242
1244
1245 """
1246 The METHODCALL element defines a single method invocation on a
1247 Class or Instance. It specifies the local path of the target
1248 Class or Instance, followed by zero or more PARAMVALUE subelements
1249 as the parameter values to be passed to the method. If the
1250 RESPONSEDESTINATION element is specified, the method call MUST be
1251 interpreted as an asynchronous method call.
1252
1253 <!ELEMENT METHODCALL ((LOCALINSTANCEPATH | LOCALCLASSPATH), PARAMVALUE*,
1254 RESPONSEDESTINATION?)>
1255 <!ATTLIST METHODCALL
1256 %CIMName;>
1257 """
1258
1259 - def __init__(self, name, localpath, paramvalues=[],
1260 responsedestination=None):
1266
1268
1269 """
1270 The EXPMETHODCALL element defines a single export method
1271 invocation. It specifies zero or more <EXPPARAMVALUE>
1272 subelements as the parameter values to be passed to the method.
1273
1274 <!ELEMENT EXPMETHODCALL (EXPPARAMVALUE*)>
1275 <!ATTLIST EXPMETHODCALL
1276 %CIMName;>
1277 """
1278
1283
1285
1286 """
1287 The PARAMVALUE element defines a single extrinsic method named
1288 parameter value. If no subelement is present this indicates that
1289 no value has been supplied for this parameter.
1290
1291 <!ELEMENT PARAMVALUE (VALUE | VALUE.REFERENCE | VALUE.ARRAY |
1292 VALUE.REFARRAY)?>
1293 <!ATTLIST PARAMVALUE
1294 %CIMName;
1295 %ParamType; #IMPLIED>
1296 """
1297
1298 - def __init__(self, name, data=None, paramtype=None,
1299 embedded_object=None):
1306
1308
1309 """
1310 The IPARAMVALUE element defines a single intrinsic method named
1311 parameter value. If no subelement is present this indicates that
1312 no value has been supplied for this parameter.
1313
1314 <!ELEMENT IPARAMVALUE (VALUE | VALUE.ARRAY | VALUE.REFERENCE |
1315 INSTANCENAME | CLASSNAME | QUALIFIER.DECLARATION |
1316 CLASS | INSTANCE | VALUE.NAMEDINSTANCE)?>
1317 <!ATTLIST IPARAMVALUE
1318 %CIMName;>
1319 """
1320
1325
1327
1328 """
1329 The EXPPARAMVALUE element defines a single export method named
1330 parameter value. If no subelement is present this indicates that
1331 no value has been supplied for this parameter.
1332
1333 <!ELEMENT EXPPARAMVALUE (INSTANCE? | VALUE? | METHODRESPONSE? |
1334 IMETHODRESPONSE?)>
1335 <!ATTLIST EXPPARAMVALUE
1336 %CIMName;
1337 %ParamType; #IMPLIED>
1338 """
1339
1340 - def __init__(self, name, data=None, param_type=None):
1345
1347
1348 """
1349 The MULTIRSP element defines a Multiple CIM Operation response.
1350 It contains two or more subelements defining the SIMPLERSP
1351 elements that make up this multiple response.
1352
1353 <!ELEMENT MULTIRSP (SIMPLERSP, SIMPLERSP+)>
1354 """
1355
1359
1361
1362 """
1363 The MULTIEXPRSP element defines a Multiple CIM Export response.
1364 It contains two or more subelements defining the SIMPLEEXPRSP
1365 elements that make up this multiple response.
1366
1367 <!ELEMENT MULTIEXPRSP (SIMPLEEXPRSP, SIMPLEEXPRSP+)>
1368 """
1369
1373
1375
1376 """
1377 The SIMPLERSP element defines a Simple CIM Operation response. It
1378 contains either a METHODRESPONSE (for extrinsic methods),
1379 IMETHODRESPONSE (for intrinsic methods) or a SIMPLEREQACK
1380 subelement.
1381
1382 <!ELEMENT SIMPLERSP (METHODRESPONSE | IMETHODRESPONSE | SIMPLEREQACK)>
1383 """
1384
1386 Element.__init__(self, 'SIMPLERSP')
1387 self.appendChild(data)
1388
1390
1391 """
1392 The SIMPLEEXPRSP element defines a Simple CIM Export response. It
1393 contains either a EXPMETHODRESPONSE (for export methods)
1394 subelement.
1395
1396 <!ELEMENT SIMPLEEXPRSP (EXPMETHODRESPONSE)>
1397 """
1398
1400 Element.__init__(self, 'SIMPLEEXPRSP')
1401 self.appendChild(data)
1402
1404
1405 """
1406 The METHODRESPONSE defines the response to a single CIM extrinsic
1407 method invocation. It contains either an ERROR subelement (to
1408 report a fundamental error which prevented the method from
1409 executing), or a combination of an optional return value and zero
1410 or more out parameter values.
1411
1412 <!ELEMENT METHODRESPONSE (ERROR | (RETURNVALUE?, PARAMVALUE*))>
1413 <!ATTLIST METHODRESPONSE
1414 %CIMName;>
1415 """
1416
1418 Element.__init__(self, 'METHODRESPONSE')
1419 self.setName(name)
1420 if data is not None:
1421 if type(data) == tuple or type(data) == list:
1422 self.appendChildren(data)
1423 else:
1424 self.appendChild(data)
1425
1427
1428 """
1429 The EXPMETHODRESPONSE defines the response to a single export
1430 method invocation. It contains either an ERROR subelement (to
1431 report a fundamental error which prevented the method from
1432 executing), or an optional return value.
1433
1434 <!ELEMENT EXPMETHODRESPONSE (ERROR | IRETURNVALUE?)>
1435 <!ATTLIST EXPMETHODRESPONSE
1436 %CIMName;>
1437 """
1438
1443
1445
1446 """
1447 The IMETHODRESPONSE defines the response to a single intrinsic CIM
1448 method invocation. It contains either an ERROR subelement (to
1449 report a fundamental error which prevented the method from
1450 executing), or an optional return value.
1451
1452 <!ELEMENT IMETHODRESPONSE (ERROR | IRETURNVALUE?)>
1453 <!ATTLIST IMETHODRESPONSE
1454 %CIMName;>
1455 """
1456
1461
1462 -class ERROR(CIMElement):
1463
1464 """
1465 The ERROR element is used to define a fundamental error which
1466 prevented a method from executing normally. It consists of a
1467 status code, an optional description and zero or more instances
1468 containing detailed information about the error.
1469
1470 <!ELEMENT ERROR (INSTANCE*)>
1471 <!ATTLIST ERROR
1472 CODE CDATA #REQUIRED
1473 DESCRIPTION CDATA #IMPLIED>
1474 """
1475
1476 - def __init__(self, code, description=None, instances=[]):
1481
1483
1484 """
1485 The RETURNVALUE element specifies the value returned from an
1486 extrinsic method call.
1487
1488 <!ELEMENT RETURNVALUE (VALUE | VALUE.REFERENCE)>
1489 <!ATTLIST RETURNVALUE
1490 %ParamType; #IMPLIED>
1491 """
1492
1493 - def __init__(self, data, param_type=None):
1497
1499
1500 """
1501 The IRETURNVALUE element specifies the value returned from an
1502 intrinsic method call.
1503
1504 <!ELEMENT IRETURNVALUE (CLASSNAME* | INSTANCENAME* | VALUE* |
1505 VALUE.OBJECTWITHPATH* |
1506 VALUE.OBJECTWITHLOCALPATH* | VALUE.OBJECT* |
1507 OBJECTPATH* | QUALIFIER.DECLARATION* |
1508 VALUE.ARRAY? | VALUE.REFERENCE? | CLASS* |
1509 INSTANCE* | VALUE.NAMEDINSTANCE*)>
1510 """
1511
1515
1517
1518 """
1519 The RESPONSEDESTINATION element contains an instance that
1520 describes the desired destination for the response.
1521
1522 <!ELEMENT RESPONSEDESTINATON (INSTANCE)>
1523 """
1524
1526 Element.__init__(self, 'RESPONSEDESTINATON')
1527 self.appendChild(data);
1528
1530
1531 """
1532 The SIMPLEREQACK defines the acknowledgement response to a Simple
1533 CIM Operation asynchronous request. The ERROR subelement is used
1534 to report a fundamental error which prevented the asynchronous
1535 request from being initiated.
1536
1537 <!ELEMENT SIMPLEREQACK (ERROR?)>
1538 <!ATTLIST SIMPLEREQACK
1539 INSTANCEID CDATA #REQUIRED>
1540 """
1541
1546