-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcim_xml.py
1410 lines (1135 loc) · 44.8 KB
/
cim_xml.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#
# (C) Copyright 2003-2006 Hewlett-Packard Development Company, L.P.
# (C) Copyright 2006-2007 Novell, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Author: Tim Potter <[email protected]>
# Bart Whiteley <[email protected]>
"""
Functions to create XML documens and elements conforming to the DMTF
standard DSP0201, Representation of CIM in XML, v2.2.
http://www.dmtf.org/standards/wbem/DSP201.html
http://www.dmtf.org/standards/published_documents/DSP201.pdf
Elements generated by this module should conform to version 2.2 of the
DTD:
http://www.dmtf.org/standards/wbem/CIM_DTD_V22.dtd
There should be one class for each element described in the DTD. The
constructors take builtin Python types, or other cim_xml classes where
child elements are required.
Every class is a subclass of the Element class and so shares the same
attributes and methods, and can be used with the built-in Python XML
handling routines. In particular you can call the toxml() and
toprettyxml() methods to generate XML.
Note that converting using toprettyxml() inserts whitespace which may
corrupt the data in the XML (!!) so you should only do this when
displaying to humans who can ignore it, and never for computers. XML
always passes through all non-markup whitespace.
"""
import sys
import xml.dom.minidom
from xml.dom.minidom import Element
def Text(data):
# pylint: disable=invalid-name
"""Grr. The API for the minidom text node function has changed in
Python 2.3. This function allows the code to run under older
versions of the intepreter."""
t = xml.dom.minidom.Text()
t.data = data
return t
class CIMElement(Element):
"""A base class that has a few bonus helper methods."""
ownerDocument = None
def setName(self, name):
"""Set the NAME attribute of the element."""
self.setAttribute('NAME', name)
def setOptionalAttribute(self, name, value):
"""Set an attribute if the value parameter is not None."""
if value is not None:
self.setAttribute(name, value)
def appendOptionalChild(self, child):
"""Append a child element which can be None."""
if child is not None:
self.appendChild(child)
def appendChildren(self, children):
"""Append a list or tuple of children."""
[self.appendChild(child) for child in children]
# Root element
class CIM(CIMElement):
"""
The CIM element is the root element of every XML Document that is
valid with respect to this schema.
Each document takes one of two forms; it either contains a single
MESSAGE element defining a CIM message (to be used in the HTTP
mapping), or it contains a DECLARATION element used to declare a
set of CIM objects.
<!ELEMENT CIM (MESSAGE | DECLARATION)>
<!ATTLIST CIM
CIMVERSION CDATA #REQUIRED
DTDVERSION CDATA #REQUIRED>
"""
def __init__(self, data, cim_version, dtd_version):
Element.__init__(self, 'CIM')
self.setAttribute('CIMVERSION', cim_version)
self.setAttribute('DTDVERSION', dtd_version)
self.appendChild(data)
# Object declaration elements
class DECLARATION(CIMElement):
"""
The DECLARATION element defines a set of one or more declarations
of CIM objects. These are partitioned into logical declaration
subsets.
<!ELEMENT DECLARATION (DECLGROUP | DECLGROUP.WITHNAME |
DECLGROUP.WITHPATH)+>
"""
def __init__(self, data):
Element.__init__(self, 'DECLARATION')
self.appendChildren(data)
class DECLGROUP(CIMElement):
"""
The DECLGROUP element defines a logical set of CIM Class, Instance
and Qualifier declarations. It MAY optionally include a
NAMESPACEPATH or LOCALNAMESPACEPATH element which, if present,
defines the common namespace in which all objects within the group
are declared.
<!ELEMENT DECLGROUP ((LOCALNAMESPACEPATH | NAMESPACEPATH)?,
QUALIFIER.DECLARATION*, VALUE.OBJECT*)>
"""
def __init__(self, data):
Element.__init__(self, 'DECLGROUP')
self.appendChildren(data)
class DECLGROUP_WITHNAME(CIMElement):
# pylint: disable=invalid-name
"""
The DECLGROUP.WITHNAME element defines a logical set of CIM Class,
Instance and Qualifier declarations. It MAY optionally include a
NAMESPACEPATH or LOCALNAMESPACEPATH element which, if present,
defines the common namespace in which all objects within the group
are declared.
<!ELEMENT DECLGROUP.WITHNAME ((LOCALNAMESPACEPATH | NAMESPACEPATH)?,
QUALIFIER.DECLARATION*, VALUE.NAMEDOBJECT*)>
"""
def __init__(self, data):
Element.__init__(self, 'DECLGROUP.WITHNAME')
self.appendChildren(data)
class DECLGROUP_WITHPATH(CIMElement):
# pylint: disable=invalid-name
"""
The DECLGROUP.WITHPATH element defines a logical set of CIM Class
and Instance declarations. Each object is declared with its own
independent naming and location information.
<!ELEMENT DECLGROUP.WITHPATH (VALUE.OBJECTWITHPATH |
VALUE.OBJECTWITHLOCALPATH)*>
"""
def __init__(self, data):
Element.__init__(self, 'DECLGROUP.WITHPATH')
self.appendChildren(data)
class QUALIFIER_DECLARATION(CIMElement):
# pylint: disable=invalid-name
"""
The QUALIFIER.DECLARATION element defines a single CIM Qualifier
declaration.
<!ELEMENT QUALIFIER.DECLARATION (SCOPE?, (VALUE | VALUE.ARRAY)?)>
<!ATTLIST QUALIFIER.DECLARATION
%CIMName;
%CIMType; #REQUIRED
ISARRAY (true|false) #IMPLIED
%ArraySize;
%QualifierFlavor;>
"""
def __init__(self, name, type, value, is_array=None,
array_size=None, qualifier_scopes={},
overridable=None, tosubclass=None,
toinstance=None, translatable=None):
Element.__init__(self, 'QUALIFIER.DECLARATION')
self.setName(name)
self.setAttribute('TYPE', type)
if is_array is not None:
self.setOptionalAttribute('ISARRAY', str(is_array).lower())
if array_size is not None:
self.setAttribute('ARRAYSIZE', str(array_size))
if overridable is not None:
self.setAttribute('OVERRIDABLE', str(overridable).lower())
if tosubclass is not None:
self.setAttribute('TOSUBCLASS', str(tosubclass).lower())
if toinstance is not None:
self.setAttribute('TOINSTANCE', str(toinstance).lower())
if translatable is not None:
self.setAttribute('TRANSLATABLE', str(translatable).lower())
if qualifier_scopes:
scope = SCOPE(qualifier_scopes)
self.appendOptionalChild(scope)
if value is not None:
if is_array:
xval = VALUE_ARRAY(value)
else:
xval = VALUE(value)
self.appendOptionalChild(xval)
class SCOPE(CIMElement):
"""
The SCOPE element defines the scope of a QUALIFIER.DECLARATION in
the case that there are restrictions on the scope of the Qualifier
declaration.
<!ELEMENT SCOPE EMPTY>
<!ATTLIST SCOPE
CLASS (true|false) 'false'
ASSOCIATION (true|false) 'false'
REFERENCE (true|false) 'false'
PROPERTY (true|false) 'false'
METHOD (true|false) 'false'
PARAMETER (true|false) 'false'
INDICATION (true|false) 'false'>
"""
def __init__(self, scopes={}):
Element.__init__(self, 'SCOPE')
if 'any' in scopes and scopes['any']:
scopes = {'CLASS': True,
'ASSOCIATION': True,
'REFERENCE': True,
'PROPERTY': True,
'METHOD': True,
'PARAMETER': True,
'INDICATION': True}
for k, v in scopes.items():
self.setOptionalAttribute(k, str(v).lower())
# Object value elements
class VALUE(CIMElement):
"""
The VALUE element is used to define a single (non-array and
non-reference) CIM Property value, CIM Qualifier value, or a CIM
Method Parameter value.
<!ELEMENT VALUE (#PCDATA)>
"""
def __init__(self, pcdata):
Element.__init__(self, 'VALUE')
if pcdata is not None:
self.appendChild(Text(pcdata))
class VALUE_ARRAY(CIMElement):
# pylint: disable=invalid-name
"""
The VALUE.ARRAY element is used to represent the value of a CIM
Property or Qualifier that has an array type.
<!ELEMENT VALUE.ARRAY (VALUE*)>
"""
def __init__(self, values):
Element.__init__(self, 'VALUE.ARRAY')
self.appendChildren(values)
class VALUE_REFERENCE(CIMElement):
# pylint: disable=invalid-name
"""
The VALUE.REFERENCE element is used to define a single CIM
reference Property value.
<!ELEMENT VALUE.REFERENCE (CLASSPATH | LOCALCLASSPATH | CLASSNAME |
INSTANCEPATH | LOCALINSTANCEPATH |
INSTANCENAME)>
"""
def __init__(self, data):
Element.__init__(self, 'VALUE.REFERENCE')
self.appendChild(data)
class VALUE_REFARRAY(CIMElement):
# pylint: disable=invalid-name
"""
The VALUE.REFARRAY element is used to represent the value of an
array of CIM references.
<!ELEMENT VALUE.REFARRAY (VALUE.REFERENCE*)>
"""
def __init__(self, data):
Element.__init__(self, 'VALUE.REFARRAY')
self.appendChildren(data)
class VALUE_OBJECT(CIMElement):
# pylint: disable=invalid-name
"""
The VALUE.OBJECT element is used to define a value which is
comprised of a single CIM Class or Instance definition.
<!ELEMENT VALUE.OBJECT (CLASS | INSTANCE)>
"""
def __init__(self, data):
Element.__init__(self, 'VALUE.OBJECT')
self.appendChild(data)
class VALUE_NAMEDINSTANCE(CIMElement):
# pylint: disable=invalid-name
"""
The VALUE.NAMEDINSTANCE element is used to define a value which
is comprised of a single named CIM Instance definition.
<!ELEMENT VALUE.NAMEDINSTANCE (INSTANCENAME, INSTANCE)>
"""
def __init__(self, instancename, instance):
Element.__init__(self, 'VALUE.NAMEDINSTANCE')
self.appendChild(instancename)
self.appendChild(instance)
class VALUE_NAMEDOBJECT(CIMElement):
# pylint: disable=invalid-name
"""
The VALUE.NAMEDOBJECT element is used to define a value which
is comprised of a single named CIM Class or Instance definition.
<!ELEMENT VALUE.NAMEDOBJECT (CLASS | (INSTANCENAME, INSTANCE))>
"""
def __init__(self, data):
Element.__init__(self, 'VALUE.NAMEDOBJECT')
if type(data) == tuple or type(data) == list:
self.appendChildren(data)
else:
self.appendChild(data)
class VALUE_OBJECTWITHLOCALPATH(CIMElement):
# pylint: disable=invalid-name
"""
The VALUE.OBJECTWITHLOCALPATH element is used to define a value
which is comprised of a single CIM Object (Class or Instance)
definition with additional information that defines the local path
to that Object.
<!ELEMENT VALUE.OBJECTWITHLOCALPATH ((LOCALCLASSPATH, CLASS) |
(LOCALINSTANCEPATH, INSTANCE))>
"""
def __init__(self, data1, data2):
Element.__init__(self, 'VALUE.OBJECTWITHLOCALPATH')
self.appendChild(data1)
self.appendChild(data2)
class VALUE_OBJECTWITHPATH(CIMElement):
# pylint: disable=invalid-name
"""
The VALUE.OBJECTWITHPATH element is used to define a value
which is comprised of a single CIM Object (Class or Instance)
definition with additional information that defines the absolute
path to that Object.
<!ELEMENT VALUE.OBJECTWITHPATH ((CLASSPATH, CLASS) |
(INSTANCEPATH, INSTANCE))>
"""
def __init__(self, data1, data2):
Element.__init__(self, 'VALUE.OBJECTWITHPATH')
self.appendChild(data1)
self.appendChild(data2)
class VALUE_NULL(CIMElement):
# pylint: disable=invalid-name
"""
The VALUE.NULL element is used to represent a TABLECELL that has
no assigned value.
<!ELEMENT VALUE.NULL EMPTY>
"""
def __init__(self):
Element.__init__(self, 'VALUE.NULL')
# Object naming and location elements
class NAMESPACEPATH(CIMElement):
# pylint: disable=invalid-name
"""
The NAMESPACEPATH element is used to define a Namespace Path. It
consists of a HOST element and a LOCALNAMESPACE element.
<!ELEMENT NAMESPACEPATH (HOST, LOCALNAMESPACEPATH)>
"""
def __init__(self, host, localnamespacepath):
Element.__init__(self, 'NAMESPACEPATH')
self.appendChild(host)
self.appendChild(localnamespacepath)
class LOCALNAMESPACEPATH(CIMElement):
# pylint: disable=invalid-name
"""
The LOCALNAMESPACEPATH element is used to define a local Namespace
path (one without a Host component). It consists of one or more
NAMESPACE elements (one for each namespace in the path).
<!ELEMENT LOCALNAMESPACEPATH (NAMESPACE+)>
"""
def __init__(self, namespaces):
Element.__init__(self, 'LOCALNAMESPACEPATH')
self.appendChildren(namespaces)
class HOST(CIMElement):
# pylint: disable=invalid-name
"""
The HOST element is used to define a single Host. The element
content MUST specify a legal value for a hostname in accordance
with the CIM specification.
<!ELEMENT HOST (#PCDATA)>
"""
def __init__(self, pcdata):
Element.__init__(self, 'HOST')
self.appendChild(Text(pcdata))
class NAMESPACE(CIMElement):
# pylint: disable=invalid-name
"""
The NAMESPACE element is used to define a single Namespace
component of a Namespace path.
<!ELEMENT NAMESPACE EMPTY>
<!ATTLIST NAMESPACE
%CIMName;>
"""
def __init__(self, name):
Element.__init__(self, 'NAMESPACE')
self.setName(name)
class CLASSPATH(CIMElement):
# pylint: disable=invalid-name
"""
The CLASSPATH element defines the absolute path to a CIM Class. It
is formed from a namespace path and Class name.
<!ELEMENT CLASSPATH (NAMESPACEPATH, CLASSNAME)>
"""
def __init__(self, namespacepath, classname):
Element.__init__(self, 'CLASSPATH')
self.appendChild(namespacepath)
self.appendChild(classname)
class LOCALCLASSPATH(CIMElement):
# pylint: disable=invalid-name
"""
The LOCALCLASSPATH element defines the a local path to a CIM
Class. It is formed from a local namespace path and Class name.
<!ELEMENT LOCALCLASSPATH (LOCALNAMESPACEPATH, CLASSNAME)>
"""
def __init__(self, localnamespacepath, classname):
Element.__init__(self, 'LOCALCLASSPATH')
self.appendChild(localnamespacepath)
self.appendChild(classname)
class CLASSNAME(CIMElement):
# pylint: disable=invalid-name
"""
The CLASSNAME element defines the qualifying name of a CIM Class.
<!ELEMENT CLASSNAME EMPTY>
<!ATTLIST CLASSNAME
%CIMName;>
"""
def __init__(self, classname):
Element.__init__(self, 'CLASSNAME')
self.setName(classname)
class INSTANCEPATH(CIMElement):
# pylint: disable=invalid-name
"""
The INSTANCEPATH element defines the absolute path to a CIM
Instance. It is comprised of a Namespace path and an Instance Name
(model path).
<!ELEMENT INSTANCEPATH (NAMESPACEPATH, INSTANCENAME)>
"""
def __init__(self, namespacepath, instancename):
Element.__init__(self, 'INSTANCEPATH')
self.appendChild(namespacepath)
self.appendChild(instancename)
class LOCALINSTANCEPATH(CIMElement):
# pylint: disable=invalid-name
"""
The LOCALINSTANCEPATH element defines the local path to a CIM
Instance. It is comprised of a local Namespace path and an
Instance Name (model path).
<!ELEMENT LOCALINSTANCEPATH (LOCALNAMESPACEPATH, INSTANCENAME)>
"""
def __init__(self, localpath, instancename):
Element.__init__(self, 'LOCALINSTANCEPATH')
self.appendChild(localpath)
self.appendChild(instancename)
class INSTANCENAME(CIMElement):
# pylint: disable=invalid-name
"""
The INSTANCENAME element defines the location of a CIM Instance
within a Namespace (it is referred to in the CIM Specification
as a Model Path). It is comprised of a class name and a key
binding information.
If the Class has a single key property, then a single KEYVALUE or
VALUE.REFERENCE subelement may be used to describe the
(necessarily) unique key value without a key name. Alternatively a
single KEYBINDING subelement may be used instead.
If the Class has more than one key property, then a KEYBINDING
subelement MUST appear for each key.
If there are no key-bindings specified, the instance is assumed to
be a singleton instance of a keyless Class.
<!ELEMENT INSTANCENAME (KEYBINDING* | KEYVALUE? | VALUE.REFERENCE?)>
<!ATTLIST INSTANCENAME
%ClassName;>
"""
def __init__(self, classname, data):
Element.__init__(self, 'INSTANCENAME')
self.setAttribute('CLASSNAME', classname)
if data is not None:
if type(data) == list:
self.appendChildren(data)
else:
self.appendChild(data)
class OBJECTPATH(CIMElement):
# pylint: disable=invalid-name
"""
The OBJECTPATH element is used to define a full path to a single
CIM Object (Class or Instance).
<!ELEMENT OBJECTPATH (INSTANCEPATH | CLASSPATH)>
"""
def __init__(self, data):
Element.__init__(self, 'OBJECTPATH')
self.appendChild(data)
class KEYBINDING(CIMElement):
# pylint: disable=invalid-name
"""
The KEYBINDING element defines a single key property value binding.
<!ELEMENT KEYBINDING (KEYVALUE | VALUE.REFERENCE)>
<!ATTLIST KEYBINDING
%CIMName;>
"""
def __init__(self, name, data):
Element.__init__(self, 'KEYBINDING')
self.setName(name)
self.appendChild(data)
class KEYVALUE(CIMElement):
# pylint: disable=invalid-name
"""
The KEYVALUE element defines a single property key value when the
key property is a non-reference type.
<!ELEMENT KEYVALUE (#PCDATA)>
<!ATTLIST KEYVALUE
VALUETYPE (string|boolean|numeric) 'string'
%CIMType; #IMPLIED>
"""
def __init__(self, data, value_type=None, cim_type=None):
Element.__init__(self, 'KEYVALUE')
if value_type is None:
self.setAttribute('VALUETYPE', 'string')
else:
self.setAttribute('VALUETYPE', value_type)
self.setOptionalAttribute('TYPE', cim_type)
if data != None:
self.appendChild(Text(data))
# Object definition elements
class CLASS(CIMElement):
# pylint: disable=invalid-name
"""
The CLASS element defines a single CIM Class.
<!ELEMENT CLASS (QUALIFIER*, (PROPERTY | PROPERTY.ARRAY |
PROPERTY.REFERENCE)*, METHOD*)>
<!ATTLIST CLASS
%CIMName;
%SuperClass;>
"""
def __init__(self, classname, properties=[], methods=[],
qualifiers=[], superclass=None):
Element.__init__(self, 'CLASS')
self.setName(classname)
self.setOptionalAttribute('SUPERCLASS', superclass)
self.appendChildren(qualifiers + properties + methods)
class INSTANCE(CIMElement):
# pylint: disable=invalid-name
"""
The INSTANCE element defines a single CIM Instance of a CIM Class.
<!ELEMENT INSTANCE (QUALIFIER*, (PROPERTY | PROPERTY.ARRAY |
PROPERTY.REFERENCE)*)>
<!ATTLIST INSTANCE
%ClassName;
xml:lang NMTOKEN #IMPLIED>
"""
def __init__(self, classname, properties=[], qualifiers=[],
xml_lang=None):
Element.__init__(self, 'INSTANCE')
self.setAttribute('CLASSNAME', classname)
self.setOptionalAttribute('xml:lang', xml_lang)
self.appendChildren(qualifiers + properties)
class QUALIFIER(CIMElement):
# pylint: disable=invalid-name
"""
The QUALIFIER element defines a single CIM Qualifier. If the
Qualifier has a non-array type, it contains a single VALUE element
representing the value of the Qualifier. If the Qualifier has an
array type, it contains a single VALUE.ARRAY element to represent
the value.
If the Qualifier has no assigned value then the VALUE element MUST
be absent.
<!ELEMENT QUALIFIER ((VALUE | VALUE.ARRAY)?)>
<!ATTLIST QUALIFIER
%CIMName;
%CIMType; #REQUIRED
%Propagated;
%QualifierFlavor;
xml:lang NMTOKEN #IMPLIED>
"""
def __init__(self, name, type, value=None, propagated=None,
overridable=None, tosubclass=None, toinstance=None,
translatable=None, xml_lang=None):
Element.__init__(self, 'QUALIFIER')
self.setName(name)
self.setAttribute('TYPE', type)
if propagated is not None:
self.setAttribute('PROPAGATED', str(propagated).lower())
if overridable is not None:
self.setAttribute('OVERRIDABLE', str(overridable).lower())
if tosubclass is not None:
self.setAttribute('TOSUBCLASS', str(tosubclass).lower())
if toinstance is not None:
self.setAttribute('TOINSTANCE', str(toinstance).lower())
if translatable is not None:
self.setAttribute('TRANSLATABLE', str(translatable).lower())
self.setOptionalAttribute('xml:lang', xml_lang)
self.appendOptionalChild(value)
class PROPERTY(CIMElement):
# pylint: disable=invalid-name
"""
The PROPERTY element defines a single (non-array) CIM Property
that is not a reference. It contains a single VALUE element
representing the value of the Property.
If the Property has no assigned value then the VALUE element MUST be
absent.
CIM Reference Properties are described using the
PROPERTY.REFERENCE element.
<!ELEMENT PROPERTY (QUALIFIER*, VALUE?)>
<!ATTLIST PROPERTY
%CIMName;
%ClassOrigin;
%Propagated;
%CIMType; #REQUIRED
xml:lang NMTOKEN #IMPLIED>
"""
def __init__(self, name, type, value=None, class_origin=None,
propagated=None, qualifiers=[], xml_lang=None,
embedded_object=None):
Element.__init__(self, 'PROPERTY')
self.setName(name)
self.setAttribute('TYPE', type)
self.setOptionalAttribute('CLASSORIGIN', class_origin)
if propagated is not None:
self.setAttribute('PROPAGATED', str(propagated).lower())
self.setOptionalAttribute('xml:lang', xml_lang)
self.setOptionalAttribute('EmbeddedObject', embedded_object)
self.appendChildren(qualifiers)
self.appendOptionalChild(value)
class PROPERTY_ARRAY(CIMElement):
# pylint: disable=invalid-name
"""
The PROPERTY.ARRAY element defines a single CIM Property with an
array type. It contains a single VALUE.ARRAY element representing
the value of the Property.
If the Property has no assigned value then the VALUE.ARRAY element
MUST be absent.
There is no element to model a Property that contains an array of
references as this is not a valid Property type according to CIM.
<!ELEMENT PROPERTY.ARRAY (QUALIFIER*, VALUE.ARRAY?)>
<!ATTLIST PROPERTY.ARRAY
%CIMName;
%CIMType; #REQUIRED
%ArraySize;
%ClassOrigin;
%Propagated;
xml:lang NMTOKEN #IMPLIED>
"""
def __init__(self, name, type, value_array=None, array_size=None,
class_origin=None, propagated=None, qualifiers=[],
xml_lang=None, embedded_object=None):
Element.__init__(self, 'PROPERTY.ARRAY')
self.setName(name)
self.setAttribute('TYPE', type)
if array_size is not None:
self.setAttribute('ARRAYSIZE', str(array_size))
self.setOptionalAttribute('CLASSORIGIN', class_origin)
self.setOptionalAttribute('EmbeddedObject', embedded_object)
if propagated is not None:
self.setAttribute('PROPAGATED', str(propagated).lower())
self.setOptionalAttribute('xml:lang', xml_lang)
self.appendChildren(qualifiers)
self.appendOptionalChild(value_array)
class PROPERTY_REFERENCE(CIMElement):
# pylint: disable=invalid-name
"""
The PROPERTY.REFERENCE element models a single CIM Property with
reference semantics. In future the features of XML Linking may
be used to identify linking elements within the XML Document; as
XML Linking is currently only at Working Draft status no explicit
dependencies have been made at this point.
<!ELEMENT PROPERTY.REFERENCE (QUALIFIER*, VALUE.REFERENCE?)>
<!ATTLIST PROPERTY.REFERENCE
%CIMName;
%ReferenceClass;
%ClassOrigin;
%Propagated;>
"""
def __init__(self, name, value_reference=None, reference_class=None,
class_origin=None, propagated=None, qualifiers=[]):
Element.__init__(self, 'PROPERTY.REFERENCE')
self.setName(name)
self.setOptionalAttribute('REFERENCECLASS', reference_class)
self.setOptionalAttribute('CLASSORIGIN', class_origin)
if propagated is not None:
self.setAttribute('PROPAGATED', str(propagated).lower());
self.appendChildren(qualifiers)
self.appendOptionalChild(value_reference)
class METHOD(CIMElement):
# pylint: disable=invalid-name
"""
The METHOD element defines a single CIM Method. It may have
Qualifiers, and zero or more parameters.
The order of the PARAMETER, PARAMETER.REFERENCE, PARAMETER.ARRAY
and PARAMETER.REFARRAY subelements is not significant.
<!ELEMENT METHOD (QUALIFIER*, (PARAMETER | PARAMETER.REFERENCE |
PARAMETER.ARRAY | PARAMETER.REFARRAY)*)>
<!ATTLIST METHOD
%CIMName;
%CIMType; #IMPLIED
%ClassOrigin;
%Propagated;>
"""
def __init__(self, name, parameters=[], return_type=None,
class_origin=None, propagated=None, qualifiers=[]):
Element.__init__(self, 'METHOD')
self.setName(name)
self.setOptionalAttribute('TYPE', return_type)
self.setOptionalAttribute('CLASSORIGIN', class_origin)
if propagated is not None:
self.setAttribute('PROPAGATED', str(propagated).lower())
self.appendChildren(qualifiers + parameters)
class PARAMETER(CIMElement):
# pylint: disable=invalid-name
"""
The PARAMETER element defines a single (non-array, non-reference)
Parameter to a CIM Method. The parameter MAY have zero or more
Qualifiers.
<!ELEMENT PARAMETER (QUALIFIER*)>
<!ATTLIST PARAMETER
%CIMName;
%CIMType; #REQUIRED>
"""
def __init__(self, name, type, qualifiers=[]):
Element.__init__(self, 'PARAMETER')
self.setName(name)
self.setAttribute('TYPE', type)
self.appendChildren(qualifiers)
class PARAMETER_REFERENCE(CIMElement):
# pylint: disable=invalid-name
"""
The PARAMETER.REFERENCE element defines a single reference
Parameter to a CIM Method. The parameter MAY have zero or more
Qualifiers.
<!ELEMENT PARAMETER.REFERENCE (QUALIFIER*)>
<!ATTLIST PARAMETER.REFERENCE
%CIMName;
%ReferenceClass;>
"""
def __init__(self, name, reference_class=None, qualifiers=[]):
Element.__init__(self, 'PARAMETER.REFERENCE')
self.setName(name)
self.setOptionalAttribute('REFERENCECLASS', reference_class)
self.appendChildren(qualifiers)
class PARAMETER_ARRAY(CIMElement):
# pylint: disable=invalid-name
"""
The PARAMETER.ARRAY element defines a single Parameter to a CIM
Method that has an array type. The parameter MAY have zero or more
Qualifiers.
<!ELEMENT PARAMETER.ARRAY (QUALIFIER*)>
<!ATTLIST PARAMETER.ARRAY
%CIMName;
%CIMType; #REQUIRED
%ArraySize;>
"""
def __init__(self, name, type, array_size=None, qualifiers=[]):
Element.__init__(self, 'PARAMETER.ARRAY')
self.setName(name)
self.setAttribute('TYPE', type)
if array_size is not None:
self.setAttribute('ARRAYSIZE', str(array_size))
self.appendChildren(qualifiers)
class PARAMETER_REFARRAY(CIMElement):
# pylint: disable=invalid-name
"""
The PARAMETER.REFARRAY element defines a single Parameter to a CIM
Method that has an array of references type. The parameter MAY
have zero or more Qualifiers.
<!ELEMENT PARAMETER.REFARRAY (QUALIFIER*)>
<!ATTLIST PARAMETER.REFARRAY
%CIMName;
%ReferenceClass;
%ArraySize;>
"""
def __init__(self, name, reference_class=None, array_size=None,
qualifiers=[]):
Element.__init__(self, 'PARAMETER.REFARRAY')
self.setName(name)
self.setOptionalAttribute('REFERENCECLASS', reference_class)
if array_size is not None:
self.setAttribute('ARRAYSIZE', str(array_size))
self.appendChildren(qualifiers)
class TABLECELL_DECLARATION(CIMElement):
# pylint: disable=invalid-name
"""
The TABLECELL.DECLARATION element describes a TABLECELL that is
not a reference or an array of references.
<!ELEMENT TABLECELL.DECLARATION EMPTY>
<!ATTLIST TABLECELL.DECLARATION
%CIMName;
%CIMType; #REQUIRED
ISARRAY (true|false) "false"
%ARRAYSIZE;
CELLPOS CDATA #REQUIRED
SORTPOS CDATA #IMPLIED
SORTDIR (ASC|DESC) #IMPLIED>
"""
class TABLECELL_REFERENCE(CIMElement):
# pylint: disable=invalid-name
"""
The TABLECELL.REFERENCE element defines a TABLECELL that contains
reference or reference array values.
<!ELEMENT TABLECELL.REFERENCE EMPTY>
<!ATTLIST TABLECELL.REFERENCE
%CIMName;
%ReferenceClass; #REQUIRED
ISARRAY (true|false) "false"
%ARRAYSIZE;
CELLPOS CDATA #REQUIRED
SORTPOS CDATA #IMPLIED
SORTDIR (ASC|DESC) #IMPLIED>
"""
class TABLEROW_DECLARATION(CIMElement):
# pylint: disable=invalid-name
"""
The TABLEROW.DECLARATION element contains a definition for each
TABLECELL in the TABLEROW.
<!ELEMENT TABLEROW.DECLARATION (TABLECELL.DECLARATION
| TABLECELL.REFERENCE)*>
"""
class TABLE(CIMElement):
# pylint: disable=invalid-name
"""
The TABLE element defines the result of a CIM Query. A TABLE
element consists of a TABLEROW.DECLARATION followed by 0 or more
rows.
<!ELEMENT TABLE(TABLEROW.DECLARATION,(TABLEROW)*)>
"""
class TABLEROW(CIMElement):
# pylint: disable=invalid-name
"""
The TABLEROW element defines the values for a single row of a
table. A value for each cell of the row MUST be specified. If a