-
Notifications
You must be signed in to change notification settings - Fork 1
/
cim_xml.js
1548 lines (1317 loc) · 46.2 KB
/
cim_xml.js
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
/*
* Copyright (c) 2011 runner.mei
*
* derived from pywbem, written by Tim Potter <tpot@hp.com>, Martin Pool <mbp@hp.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
*
* Functions to create XML documens and elements conforming to the DMTF
* standard DSP0201, Representation of CIM in XML, v2.3.1.
*
* 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.3.1 of the
* DTD:
*
* http://www.dmtf.org/standards/wbem/CIM_DTD_V23.dtd
*
* There should be one function for each element described in the DTD. The
* constructors take builtin Python types, or other cim_xml classes where
* child elements are required.
*
* Every function is a subclass of the Element function 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.
*/
var dom = require("dom-js"),
util = require("util");
(function(){
exports._ = _ = {};
// Is a given array, string, or object empty?
// An "empty" object has no enumerable own-properties.
_.isEmpty = function(obj) {
if (_.isArray(obj) || _.isString(obj)) return obj.length === 0;
for (var key in obj) if (hasOwnProperty.call(obj, key)) return false;
return true;
};
// Is a given value a DOM element?
_.isElement = function(obj) {
return !!(obj && obj.nodeType == 1);
};
// Is a given value an array?
// Delegates to ECMA5's native Array.isArray
_.isArray = util.isArray;
// Is a given variable an object?
_.isObject = function(obj) {
return obj === Object(obj);
};
// Is a given variable an arguments object?
_.isArguments = function(obj) {
return toString.call(obj) == '[object Arguments]';
};
if (!_.isArguments(arguments)) {
_.isArguments = function(obj) {
return !!(obj && hasOwnProperty.call(obj, 'callee'));
};
}
// Is a given value a function?
_.isFunction = function(obj) {
return toString.call(obj) == '[object Function]';
};
// Is a given value a string?
_.isString = function(obj) {
return toString.call(obj) == '[object String]';
};
// Is a given value a number?
_.isNumber = function(obj) {
return toString.call(obj) == '[object Number]';
};
// Is the given value `NaN`?
_.isNaN = function(obj) {
// `NaN` is the only value for which `===` is not reflexive.
return obj !== obj;
};
// Is a given value a boolean?
_.isBoolean = function(obj) {
return obj === true || obj === false || toString.call(obj) == '[object Boolean]';
};
// Is a given value a date?
_.isDate = util.isDate;
// Is the given value a regular expression?
_.isRegExp = util.isRegExp;
// Is the given value a Error?
_.isError = util.isError;
// Is a given value equal to null?
_.isNull = function(obj) {
return obj === null;
};
// Is a given variable undefined?
_.isUndefined = function(obj) {
return obj === void 0;
};
// Return the first value which passes a truth test. Aliased as `detect`.
_.find = _.detect = function(obj, iterator, context) {
var item, i, l;
for(i = 0, l = obj.length; i < l; i++) {
item = obj[i];
if (iterator.call(context, item, i, obj)) {
return item;
}
}
};
_.exists = function(obj, value) {
var item, i, l;
for(i = 0, l = obj.length; i < l; i++) {
item = obj[i];
if (item === value) {
return true;
}
}
return false;
};
// Return the results of applying the iterator to each element.
// Delegates to **ECMAScript 5**'s native `map` if available.
_.map = function(obj, iterator, context) {
var results = [], item, i, l;
if (obj == null) return results;
for(i = 0, l = obj.length; i < l; i++) {
item = obj[i];
results.push(iterator.call(context, item, i, obj));
}
return results;
};
}).call(this);
/* A base function that has a few bonus helper methods. */
exports.CIMElement = CIMElement = function(name){
dom.Element.call(this, name);
/* Set the NAME attribute of the element. */
this.text = function(txt) {
if(!(txt instanceof dom.Text)){
txt = new dom.Text(txt);
}
this.children = [];
this.children.push(txt);
}
/* Set the NAME attribute of the element. */
this.name = function(name) {
this.attributes["NAME"] = name;
}
/* Set an attribute if the value is not nil.*/
this.attribute = function(name, value) {
this.attributes[name] = value;
};
/* Append a child element which can be nil. */
this.element = function(child) {
this.children.push(child);
};
/** Append a array of children. */
this.elements = function() {
for(var i = 0; i < arguments.length; ++ i) {
if(util.isArray(arguments[i])) {
this.children = this.children.concat(arguments[i]);
} else {
this.children.push(arguments[i]);
}
}
};
};
util.inherits(CIMElement, dom.Element);
/**
* 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>
*/
exports.CIM = CIM = function(data, cim_version, dtd_version) {
CIMElement.call(this, 'CIM');
this.attribute('CIMVERSION', cim_version);
this.attribute('DTDVERSION', dtd_version);
this.element(data);
};
util.inherits(CIM, CIMElement);
/**************************************************
Object declaration elements
**************************************************/
/**
* 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)+>
*/
exports.DECLARATION = DECLARATION = function(data) {
CIMElement.call(this, 'DECLARATION');
this.elements(data);
};
util.inherits(DECLARATION, 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*)>
*/
exports.DECLGROUP = DECLGROUP = function(data) {
CIMElement.call(this, 'DECLGROUP');
this.elements(data);
};
util.inherits(DECLGROUP, CIMElement);
/**
* 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*)>
*/
exports.DECLGROUP_WITHNAME = DECLGROUP_WITHNAME = function(data){
CIMElement.call(this, 'DECLGROUP.WITHNAME');
this.elements(data);
};
util.inherits(DECLGROUP_WITHNAME, CIMElement);
/**
* 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)*>
*/
exports.DECLGROUP_WITHPATH = DECLGROUP_WITHPATH = function(data) {
CIMElement.call(this, 'DECLGROUP.WITHPATH');
this.elements(data);
};
util.inherits(DECLGROUP_WITHPATH, CIMElement);
/**
* 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;>
*/
function QUALIFIER_DECLARATION(name, type, value, is_array,
array_size, qualifier_scopes,
overridable, tosubclass
toinstance, translatable) {
CIMElement.call(this, 'QUALIFIER.DECLARATION');
this.name(name);
this.attribute('TYPE', type);
if(is_array) {
this.attribute('ISARRAY', is_array.toString().toLowerCase());
}
if(array_size) {
this.attribute('ARRAYSIZE', array_size.toString());
}
if(overridable) {
this.attribute('OVERRIDABLE', overridable.toString().toLowerCase());
}
if(tosubclass) {
this.attribute('TOSUBCLASS', tosubclass.toString().toLowerCase());
}
if(toinstance) {
this.attribute('TOINSTANCE', toinstance.toString().toLowerCase());
}
if(translatable) {
this.attribute('TRANSLATABLE', translatable.toString().toLowerCase());
}
this.elements(value);
};
util.inherits(QUALIFIER_DECLARATION, 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'>
*/
exports.SCOPE = SCOPE = function(scopes) {
CIMElement.call(this, 'SCOPE');
if(scopes['any']) {
scopes = {'CLASS': true,
'ASSOCIATION': true,
'REFERENCE': true,
'PROPERTY': true,
'METHOD': true,
'PARAMETER': true,
'INDICATION': true};
}
for(var key in scopes) {
this.attribute(k, scopes[k].toString()).toLowerCase());
}
};
util.inherits(SCOPE, CIMElement);
/*************************************************
Object Value elements
**************************************************/
/**
* 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)>
*/
exports.VALUE = VALUE = function(pcdata) {
CIMElement.call(this, 'VALUE');
this.text(pcdata);
};
util.inherits(VALUE, CIMElement);
/**
* 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*)>
*/
exports.VALUE_ARRAY = VALUE_ARRAY = function(values) {
CIMElement.call(this, 'VALUE.ARRAY');
this.texts(values);
};
util.inherits(VALUE_ARRAY, CIMElement);
/**
* The VALUE.REFERENCE element is used to define a single CIM
* reference Property value.
*
* <!ELEMENT VALUE.REFERENCE (CLASSPATH | LOCALCLASSPATH | CLASSNAME |
* INSTANCEPATH | LOCALINSTANCEPATH |
* INSTANCENAME)>
*/
exports.VALUE_REFERENCE = VALUE_REFERENCE = function(data) {
CIMElement.call(this, 'VALUE.REFERENCE');
this.element(data);
};
util.inherits(VALUE_REFERENCE, CIMElement);
/**
* The VALUE.REFARRAY element is used to represent the value of an
* array of CIM references.
*
* <!ELEMENT VALUE.REFARRAY (VALUE.REFERENCE | VALUE.NULL)*>
*/
exports.VALUE_REFARRAY = VALUE_REFARRAY = function(data) {
CIMElement.call(this, 'VALUE.REFARRAY');
this.elements(data);
};
util.inherits(VALUE_REFARRAY, CIMElement);
/**
* 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)>
*/
exports.VALUE_OBJECT = VALUE_OBJECT = function(data) {
CIMElement.call(this, 'VALUE.OBJECT');
this.element(data);
};
util.inherits(VALUE_OBJECT, CIMElement);
/**
* 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)>
*/
exports.VALUE_NAMEDINSTANCE = VALUE_NAMEDINSTANCE = function(instancename, instance) {
CIMElement.call(this, 'VALUE.NAMEDINSTANCE');
this.element(instancename);
this.element(instance);
};
util.inherits(VALUE_NAMEDINSTANCE, CIMElement);
/**
* 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))>
*/
exports.VALUE_NAMEDOBJECT = VALUE_NAMEDOBJECT = function(data):
CIMElement.call(this, 'VALUE.NAMEDOBJECT');
this.elements(data);
};
util.inherits(VALUE_NAMEDOBJECT, CIMElement);
/**
* 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))>
*/
exports.VALUE_OBJECTWITHLOCALPATH = VALUE_OBJECTWITHLOCALPATH = function(data1, data2) {
CIMElement.call(this, 'VALUE.OBJECTWITHLOCALPATH');
this.element(data1);
this.element(data2);
};
util.inherits(VALUE_OBJECTWITHLOCALPATH, CIMElement);
/**
* 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))>
*/
exports.VALUE_OBJECTWITHPATH = VALUE_OBJECTWITHPATH = function(data1, data2):
CIMElement.call(this, 'VALUE.OBJECTWITHPATH');
this.element(data1);
this.element(data2);
};
util.inherits(VALUE_OBJECTWITHPATH, CIMElement);
/**
* The VALUE.NULL element is used to represent a TABLECELL that has
* no assigned value.
*
* <!ELEMENT VALUE.NULL EMPTY>
*/
exports.VALUE_NULL = VALUE_NULL = function() {
CIMElement.call(this, 'VALUE.NULL');
};
util.inherits(VALUE_NULL, CIMElement);
/**************************************************
Object naming and locating elements
**************************************************/
/**
* The NAMESPACEPATH element is used to define a Namespace Path. It
* consists of a HOST element and a LOCALNAMESPACE element.
*
* <!ELEMENT NAMESPACEPATH (HOST, LOCALNAMESPACEPATH)>
*/
exports.NAMESPACEPATH = NAMESPACEPATH = function(host, localnamespacepath) {
CIMElement.call(this, 'NAMESPACEPATH');
this.element(host);
this.element(localnamespacepath);
};
util.inherits(NAMESPACEPATH, CIMElement);
/**
* 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+)>
*/
exports.LOCALNAMESPACEPATH = LOCALNAMESPACEPATH = function(namespaces):
CIMElement.call(this, 'LOCALNAMESPACEPATH');
this.elements(arguments);
};
util.inherits(LOCALNAMESPACEPATH, CIMElement);
/**
* 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)>
*/
exports.HOST = HOST = function(pcdata) {
CIMElement.call(this, 'HOST');
this.text(pcdata);
};
util.inherits(HOST, CIMElement);
/**
* The NAMESPACE element is used to define a single Namespace
* component of a Namespace path.
*
* <!ELEMENT NAMESPACE EMPTY>
* <!ATTLIST NAMESPACE
* %CIMName;>
*/
exports.NAMESPACE = NAMESPACE = function(name) {
CIMElement.call(this, 'NAMESPACE');
this.name(name);
};
util.inherits(NAMESPACE, CIMElement);
/**
* 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)>
*/
exports.CLASSPATH = CLASSPATH = function(namespacepath, classname) {
CIMElement.call(this, 'CLASSPATH');
this.element(namespacepath);
this.element(classname);
};
util.inherits(CLASSPATH, CIMElement);
/**
* 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)>
*/
exports.LOCALCLASSPATH = LOCALCLASSPATH = function(localnamespacepath, classname) {
CIMElement.call(this, 'LOCALCLASSPATH');
this.element(localnamespacepath);
this.element(classname);
};
util.inherits(LOCALCLASSPATH, CIMElement);
/**
* The CLASSNAME element defines the qualifying name of a CIM Class.
*
* <!ELEMENT CLASSNAME EMPTY>
* <!ATTLIST CLASSNAME
* %CIMName;>
*/
exports.CLASSNAME = CLASSNAME = function(classname) {
CIMElement.call(this, 'CLASSNAME');
this.name(classname);
};
util.inherits(CLASSNAME, CIMElement);
/**
* 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)>
*/
exports.INSTANCEPATH = INSTANCEPATH = function(namespacepath, instancename) {
CIMElement.call(this, 'INSTANCEPATH');
this.element(namespacepath);
this.element(instancename);
};
util.inherits(INSTANCEPATH, CIMElement);
/**
* 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)>
*/
exports.LOCALINSTANCEPATH = LOCALINSTANCEPATH = function(localpath, instancename) {
CIMElement.call(this, 'LOCALINSTANCEPATH');
this.element(localpath);
this.element(instancename);
};
util.inherits(LOCALINSTANCEPATH, CIMElement);
/**
* 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 function 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;>
*/
exports.INSTANCENAME = INSTANCENAME = function(classname, data) {
CIMElement.call(this, 'INSTANCENAME');
this.attribute('CLASSNAME', classname);
this.elements(data);
};
util.inherits(INSTANCENAME, CIMElement);
/**
* The OBJECTPATH element is used to define a full path to a single
* CIM Object (Class or Instance).
*
* <!ELEMENT OBJECTPATH (INSTANCEPATH | CLASSPATH)>
*/
exports.OBJECTPATH = OBJECTPATH = function( data) {
CIMElement.call(this, 'OBJECTPATH');
this.element(data);
};
util.inherits(OBJECTPATH, CIMElement);
/**
* The KEYBINDING element defines a single key property value binding.
*
* <!ELEMENT KEYBINDING (KEYVALUE | VALUE.REFERENCE)>
* <!ATTLIST KEYBINDING
* %CIMName;>
*/
exports.KEYBINDING = KEYBINDING = function(name, data) {
CIMElement.call(this, 'KEYBINDING');
this.name(name);
this.element(data);
};
util.inherits(KEYBINDING, CIMElement);
/**
* 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>
*/
exports.KEYVALUE = KEYVALUE = function(data, value_type = None, cim_type = None) {
CIMElement.call(this, 'KEYVALUE')
if(value_type) {
this.attribute('VALUETYPE', value_type);
} else {
this.attribute('VALUETYPE', 'string');
}
this.attribute('TYPE', cim_type);
if(data) {
this.text(data);
}
};
util.inherits(KEYVALUE, CIMElement);
/**************************************************
Object definition elements
**************************************************/
/**
* The CLASS element defines a single CIM Class.
*
* <!ELEMENT CLASS (QUALIFIER*, (PROPERTY | PROPERTY.ARRAY |
* PROPERTY.REFERENCE)*, METHOD*)>
* <!ATTLIST CLASS
* %CIMName;
* %SuperClass;>
*/
function CLASS(classname, properties, methods,
qualifiers, superclass) {
CIMElement.call(this, 'CLASS');
this.name(classname);
this.attribute('SUPERCLASS', superclass);
this.elements(qualifiers, properties, methods);
};
util.inherits(CLASS, CIMElement);
/**
* 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>
*/
function INSTANCE(classname, properties, qualifiers ,
xml_lang) {
CIMElement.call(this, 'INSTANCE');
this.attribute('CLASSNAME', classname);
this.attribute('xml:lang', xml_lang);
this.elements(qualifiers, properties);
};
util.inherits(INSTANCE, CIMElement);
/**
* 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>
*/
function QUALIFIER(name, type, value, propagated,
overridable, tosubclass, toinstance,
translatable, xml_lang):
CIMElement.call(this, 'QUALIFIER');
this.name(name);
this.attribute('TYPE', type);
if(propagated) {
this.attribute('PROPAGATED', propagated.toString().toLowerCase());
}
if(overridable) {
this.attribute('OVERRIDABLE', overridable.toString().toLowerCase());
}
if(tosubclass) {
this.attribute('TOSUBCLASS', tosubclass.toString().toLowerCase());
}
if(toinstance) {
this.attribute('TOINSTANCE', toinstance.toString().toLowerCase());
}
if(translatable) {
this.attribute('TRANSLATABLE', translatable.toString().toLowerCase());
}
this.attribute('xml:lang', xml_lang);
this.element(value);
};
util.inherits(QUALIFIER, CIMElement);
/**
* 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;
* %EmbeddedObject;
* %CIMType; #REQUIRED
* xml:lang NMTOKEN #IMPLIED>
*/
function PROPERTY(name, type, value, class_origin,
propagated, qualifiers, xml_lang,
embedded_object) {
CIMElement.call(this, 'PROPERTY');
this.name(name);
this.attribute('TYPE', type);
this.attribute('CLASSORIGIN', class_origin);
if(propagated){
this.attribute('PROPAGATED', propagated.toString().toLowerCase());
}
this.attribute('xml:lang', xml_lang);
this.attribute('EmbeddedObject', embedded_object);
this.elements(qualifiers);
this.element(value);
};
util.inherits(PROPERTY, CIMElement);
/**
* 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;
* %EmbeddedObject;
* xml:lang NMTOKEN #IMPLIED>
*/
function PROPERTY_ARRAY(name, type, value_array, array_size,
class_origin, propagated, qualifiers,
xml_lang, embedded_object) {
CIMElement.call(this, 'PROPERTY.ARRAY');
this.name(name);
this.attribute('TYPE', type);
if(array_size) {
this.attribute('ARRAYSIZE', array_size.toString());
}
this.attribute('CLASSORIGIN', class_origin);
this.attribute('EmbeddedObject', embedded_object);
if(propagated){
this.attribute('PROPAGATED', propagated.toString().toLowerCase());
}
this.attribute('xml:lang', xml_lang);
this.elements(qualifiers);
this.element(value_array);
};
util.inherits(PROPERTY_ARRAY, CIMElement);
/**
* 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;>
*/
function PROPERTY_REFERENCE(name, value_reference, reference_class,
class_origin, propagated, qualifiers) {
CIMElement.call(this, 'PROPERTY.REFERENCE');
this.name(name);
this.attribute('REFERENCECLASS', reference_class);
this.attribute('CLASSORIGIN', class_origin);
if(propagated) {
this.attribute('PROPAGATED', propagated.toString().toLowerCase());
}
this.elements(qualifiers);
this.element(value_reference);
};
util.inherits(PROPERTY_REFERENCE, CIMElement);
/**
* 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;>
*/
function METHOD(name, parameters, return_type,
class_origin, propagated, qualifiers) {