1 karl 1.59 //%2006////////////////////////////////////////////////////////////////////////
|
2 karl 1.1 //
|
3 karl 1.12 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.3 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.12 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.18 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.59 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 karl 1.1 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 karl 1.59 //
|
21 karl 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
|
30 s.manicka 1.69.4.2 //=============================================================================
|
31 kumpf 1.69 //
|
32 s.manicka 1.69.4.2 //%////////////////////////////////////////////////////////////////////////////
|
33 karl 1.1
34 ///////////////////////////////////////////////////////////////////////////////
|
35 karl 1.5 // Interop Provider - This provider services those classes from the
|
36 a.dunfey 1.64 // DMTF Interop schema in an implementation compliant with the SMI-S v1.1
37 // Server Profile
|
38 karl 1.1 //
|
39 a.dunfey 1.64 // Please see PG_ServerProfile20.mof in the directory
40 // $(PEGASUS_ROOT)/Schemas/Pegasus/InterOp/VER20 for retails regarding the
41 // classes supported by this control provider.
|
42 david.dillard 1.32 //
|
43 kumpf 1.69 // Interop forces all creates to the PEGASUS_NAMESPACENAME_INTEROP
44 // namespace. There is a test on each operation that returns
|
45 a.dunfey 1.64 // the Invalid Class CIMDError
46 // This is a control provider and as such uses the Tracer functions
47 // for data and function traces. Since we do not expect high volume
48 // use we added a number of traces to help diagnostics.
|
49 karl 1.1 ///////////////////////////////////////////////////////////////////////////////
50
51 #include <Pegasus/Common/Config.h>
52 #include <Pegasus/Common/PegasusVersion.h>
53
54 #include <cctype>
55 #include <iostream>
56
57 #include "InteropProvider.h"
|
58 a.dunfey 1.64 #include "InteropProviderUtils.h"
59 #include "InteropConstants.h"
60
|
61 karl 1.8 #include <Pegasus/Common/StatisticalData.h>
|
62 karl 1.1
63 PEGASUS_USING_STD;
|
64 a.dunfey 1.65 PEGASUS_NAMESPACE_BEGIN
|
65 karl 1.1
|
66 a.dunfey 1.64 /*****************************************************************************
67 *
68 * The following are constants representing property names for the classes
69 * managed by the Interop Provider. Where multiple classes have properties of
70 * the same name, there will be a common CIMName object defined, and a macro
71 * defined that points to the common CIMName object, but whose macro name
72 * reflects the class in which the property is used.
73 *
74 *****************************************************************************/
|
75 karl 1.1
|
76 tony 1.6 //
|
77 a.dunfey 1.64 // Constructor for the InteropProvider control provider
|
78 tony 1.6 //
|
79 a.dunfey 1.64 InteropProvider::InteropProvider(CIMRepository * rep) : repository(rep),
|
80 a.dunfey 1.65 hostName(System::getHostName()), providerInitialized(false),
81 profileIds(Array<String>()), conformingElements(Array<CIMNameArray>()),
82 elementNamespaces(Array<CIMNamespaceArray>())
|
83 a.dunfey 1.64 {
84 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,"InteropProvider::InteropProvider");
|
85 tony 1.6
|
86 a.dunfey 1.65 #ifndef PEGASUS_DISABLE_PERFINST
87 try
88 {
89 initProvider();
|
90 w.white 1.34 }
|
91 a.dunfey 1.65 catch(const Exception & e)
|
92 a.dunfey 1.64 {
|
93 a.dunfey 1.65 // Provider initialization may fail if the repository is not
94 // populated
|
95 karl 1.26 }
|
96 a.dunfey 1.65 #endif
|
97 kumpf 1.69
|
98 a.dunfey 1.64 PEG_METHOD_EXIT();
|
99 karl 1.26 }
100
|
101 a.dunfey 1.64 //
102 // Local version of getInstance to be used by other functions in the the
103 // provider. Returns a single instance. Note that it always returns an
104 // instance. If none was found, it is uninialitized.
105 //
106 CIMInstance InteropProvider::localGetInstance(
107 const OperationContext & context,
108 const CIMObjectPath & instanceName,
109 const CIMPropertyList & propertyList)
|
110 karl 1.52 {
|
111 a.dunfey 1.64 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::localGetInstance");
|
112 karl 1.40
|
113 marek 1.67 PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4,
|
114 a.dunfey 1.64 "%s getInstance. instanceName= %s , PropertyList= %s",
115 thisProvider,
116 (const char *)instanceName.toString().getCString(),
|
117 marek 1.67 (const char *)propertyListToString(propertyList).getCString()));
|
118 karl 1.40
|
119 a.dunfey 1.64 // Test if we're looking for something outside of our namespace. This will
120 // happen during associators calls from PG_RegisteredProfile instances
121 // through the PG_ElementConformsToProfile association
122 CIMNamespaceName opNamespace = instanceName.getNameSpace();
123 CIMName opClass = instanceName.getClassName();
124 if(opNamespace != PEGASUS_NAMESPACENAME_INTEROP &&
125 opClass != PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE)
126 {
127 AutoMutex mut(interopMut);
|
128 marek 1.69.4.1 CIMInstance gotInstance = cimomHandle.getInstance(
129 context,
130 opNamespace,
131 instanceName,
132 false,
133 false,
134 false,
135 propertyList);
136 PEG_METHOD_EXIT();
137 return gotInstance;
|
138 a.dunfey 1.64 }
|
139 karl 1.40
|
140 a.dunfey 1.64 // Create reference from host, namespace, class components of
141 // instance name
142 CIMObjectPath ref;
143 ref.setHost(instanceName.getHost());
144 ref.setClassName(opClass);
145 ref.setNameSpace(opNamespace);
|
146 karl 1.26
|
147 a.dunfey 1.64 // Enumerate instances for this class. Returns all instances
148 // Note that this returns paths setup and instances already
149 // filtered per the input criteria.
150 Array<CIMInstance> instances = localEnumerateInstances(
151 context,
152 ref,
153 propertyList);
|
154 karl 1.26
|
155 a.dunfey 1.64 // deliver a single instance if found.
156 CIMInstance retInstance;
|
157 karl 1.26
|
158 a.dunfey 1.64 bool found = false;
159 for(Uint32 i = 0, n = instances.size(); i < n; i++)
|
160 tony 1.6 {
|
161 a.dunfey 1.64 CIMObjectPath currentInstRef = instances[i].getPath();
162 currentInstRef.setHost(instanceName.getHost());
163 currentInstRef.setNameSpace(instanceName.getNameSpace());
164 if(instanceName == currentInstRef)
|
165 tony 1.6 {
|
166 a.dunfey 1.64 retInstance = instances[i];
167 found = true;
168 break;
|
169 tony 1.6 }
170 }
|
171 karl 1.8
|
172 a.dunfey 1.64 if(!found)
|
173 karl 1.8 {
|
174 a.dunfey 1.64 cout << "Coule not find instance: " << instanceName.toString() << endl;
|
175 karl 1.8 }
|
176 a.dunfey 1.64 PEG_METHOD_EXIT();
177 return retInstance;
|
178 tony 1.6 }
|
179 karl 1.11
|
180 a.dunfey 1.64
181 //
182 // Local version of enumerateInstances to be used by other functions in the
183 // provider. Note that this delivers instances as a group rather than one
184 // at a time. This design point may need to be revisited if this provider
185 // is used in environments such that returning segmented responses would have
186 // significant performance advantages. For now, that doesn't seem to be the
187 // case.
188 //
189 Array<CIMInstance> InteropProvider::localEnumerateInstances(
190 const OperationContext & context,
191 const CIMObjectPath & ref,
192 const CIMPropertyList& propertyList)
|
193 david.dillard 1.32 {
|
194 a.dunfey 1.64 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
195 "InteropProvider::localEnumerateInstances()");
196 const CIMName & className = ref.getClassName();
|
197 marek 1.67 PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4,
|
198 a.dunfey 1.64 "%s enumerateInstances. referenc= %s , PropertyList= %s",
199 thisProvider,
200 (const char *)className.getString().getCString(),
|
201 marek 1.67 (const char *)propertyListToString(propertyList).getCString()));
|
202 david.dillard 1.32
|
203 a.dunfey 1.64 // Verify that ClassName is correct and get its enum value
204 TARGET_CLASS classEnum = translateClassInput(className);
|
205 tony 1.6
|
206 a.dunfey 1.64 Array<CIMInstance> instances;
207 switch(classEnum)
208 {
209 case PG_OBJECTMANAGER:
210 {
211 instances.append(getObjectManagerInstance());
212 break;
213 }
214 case PG_CIMXMLCOMMUNICATIONMECHANISM:
215 {
216 instances = enumCIMXMLCommunicationMechanismInstances();
217 break;
218 }
219 case PG_NAMESPACEINMANAGER:
220 {
221 instances = enumNamespaceInManagerInstances();
222 break;
223 }
224 case PG_COMMMECHANISMFORMANAGER:
225 {
226 instances = enumCommMechanismForManagerInstances();
227 a.dunfey 1.64 break;
228 }
229 case PG_NAMESPACE:
230 {
231 instances = enumNamespaceInstances();
232 break;
233 }
234 case PG_REGISTEREDPROFILE:
235 {
236 instances = enumRegisteredProfileInstances();
237 break;
238 }
239 case PG_REGISTEREDSUBPROFILE:
240 {
241 instances = enumRegisteredSubProfileInstances();
242 break;
243 }
244 case PG_REFERENCEDPROFILE:
245 {
246 instances = enumReferencedProfileInstances();
247 break;
248 a.dunfey 1.64 }
249 case PG_ELEMENTCONFORMSTOPROFILE:
250 {
251 instances = enumElementConformsToProfileInstances(context,
252 ref.getNameSpace());
253 break;
254 }
|
255 s.manicka 1.69.4.2 case PG_ELEMENTCONFORMSTOPROFILE_RP_RP:
256 {
257 instances = enumElementConformsToProfileRPRPInstances(
258 context,
259 ref.getNameSpace());
260 break;
261 }
|
262 a.dunfey 1.64 case PG_SUBPROFILEREQUIRESPROFILE:
263 {
264 instances = enumSubProfileRequiresProfileInstances();
265 break;
266 }
267 case PG_SOFTWAREIDENTITY:
268 {
269 instances = enumSoftwareIdentityInstances();
270 break;
271 }
272 case PG_ELEMENTSOFTWAREIDENTITY:
273 {
274 instances = enumElementSoftwareIdentityInstances();
275 break;
276 }
277 case PG_INSTALLEDSOFTWAREIDENTITY:
278 {
279 instances = enumInstalledSoftwareIdentityInstances();
280 break;
281 }
282 case PG_COMPUTERSYSTEM:
283 a.dunfey 1.64 {
284 instances.append(getComputerSystemInstance());
285 break;
286 }
287 case PG_HOSTEDOBJECTMANAGER:
288 {
289 instances.append(getHostedObjectManagerInstance());
290 break;
291 }
292 case PG_HOSTEDACCESSPOINT:
293 {
294 instances = enumHostedAccessPointInstances();
295 break;
296 }
297 default:
298 PEG_METHOD_EXIT();
299 throw CIMNotSupportedException(className.getString() +
300 " not supported by Interop Provider enumerate");
301 }
|
302 karl 1.41
|
303 a.dunfey 1.64 // Filter and deliver the resulting instances
304 for (Uint32 i = 0 ; i < instances.size() ; i++)
305 {
306 normalizeInstance(instances[i], ref, false,
307 false, propertyList);
308 }
|
309 tony 1.6
|
310 a.dunfey 1.64 PEG_METHOD_EXIT();
311 return instances;
|
312 tony 1.6 }
|
313 karl 1.55
|
314 a.dunfey 1.64 //
315 // Class that determines whether or not the origin class in an association
316 // operation is valid for the given association class, and also determines
317 // the origin and target "roles". These values generally correspond to the
318 // role and resultRole parameter of an associators/associatorNames operation.
319 //
320 bool InteropProvider::validAssocClassForObject(
|
321 s.manicka 1.69.4.2 const OperationContext & context,
322 const CIMName & assocClass,
323 const CIMObjectPath & objectName,
|
324 a.dunfey 1.64 const CIMNamespaceName & opNamespace,
|
325 s.manicka 1.69.4.2 String & originProperty,
326 String & targetProperty)
|
327 a.dunfey 1.64 {
328 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
329 "InteropProvider::validAssocClassForObject()");
330 TARGET_CLASS assocClassEnum = translateClassInput(assocClass);
331 TARGET_CLASS originClassEnum;
|
332 s.manicka 1.69.4.2 CIMName originClass = objectName.getClassName();
|
333 a.dunfey 1.64 // If the association class is PG_ElementConformsToProfile, we'll have to
334 // do some special processing in case the origin instance for the operation
335 // is managed by another provider.
336 if(assocClassEnum == PG_ELEMENTCONFORMSTOPROFILE)
337 {
338 // Test if the origin is an element managed by another provider
339 // that has implemented a registered profile.
340 if(opNamespace != PEGASUS_NAMESPACENAME_INTEROP ||
341 (originClass != PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE &&
|
342 s.manicka 1.69.4.2 originClass != PEGASUS_CLASSNAME_PG_OBJECTMANAGER ))
|
343 a.dunfey 1.64 {
344 //
345 // Search the cached conformingElements list for the originClass,
346 // returning false if it is not found
347 //
348 bool found = false;
|
349 karl 1.1
|
350 a.dunfey 1.64 PEGASUS_ASSERT(conformingElements.size() ==
351 elementNamespaces.size());
352 for(Uint32 i = 0, n = conformingElements.size(); i < n; ++i)
353 {
354 CIMNameArray & elementList = conformingElements[i];
355 CIMNamespaceArray & namespaceList = elementNamespaces[i];
356 PEGASUS_ASSERT(elementList.size() == namespaceList.size());
357 for(Uint32 j = 0, m = elementList.size(); j < m; ++j)
358 {
359 CIMName & curElement = elementList[j];
360 if((curElement == originClass ||
361 curElement.getString().find(PEGASUS_DYNAMIC) == 0) &&
362 opNamespace == namespaceList[j])
363 {
364 found = true;
365 break;
366 }
367 }
368 if(found)
369 break;
370 }
|
371 karl 1.28
|
372 a.dunfey 1.64 if(!found)
|
373 marek 1.69.4.1 {
374 PEG_METHOD_EXIT();
|
375 a.dunfey 1.64 return false;
|
376 marek 1.69.4.1 }
|
377 a.dunfey 1.64 }
378 }
379 else
380 {
381 // Otherwise, just get the enum value representing the origin class
382 // for this operation
383 originClassEnum = translateClassInput(originClass);
384 }
|
385 karl 1.1
|
386 a.dunfey 1.64 CIMName expectedTargetRole;
387 CIMName expectedOriginRole;
|
388 tony 1.6
|
389 s.manicka 1.69.4.2 Array<CIMName> propNames;
390 String profileName;
391 CIMPropertyList propertyList;
392 CIMInstance tmpInstance;
393 Uint32 index;
394 propNames.clear();
395
|
396 a.dunfey 1.64 //
397 // Set the target and origin role values. Note that if these values are
398 // not set following the switch block, that implies that the origin class
399 // is not valid for the supplied association class.
400 //
401 switch(assocClassEnum)
|
402 tony 1.6 {
|
403 a.dunfey 1.64 case PG_NAMESPACEINMANAGER:
404 if(originClassEnum == PG_OBJECTMANAGER)
405 {
406 expectedTargetRole = PROPERTY_DEPENDENT;
407 expectedOriginRole = PROPERTY_ANTECEDENT;
408 }
409 else if(originClassEnum == PG_NAMESPACE)
410 {
411 expectedTargetRole = PROPERTY_ANTECEDENT;
412 expectedOriginRole = PROPERTY_DEPENDENT;
413 }
414 break;
415 case PG_COMMMECHANISMFORMANAGER:
416 if(originClassEnum == PG_OBJECTMANAGER)
417 {
418 expectedTargetRole = PROPERTY_DEPENDENT;
419 expectedOriginRole = PROPERTY_ANTECEDENT;
420 }
421 else if(originClassEnum == PG_CIMXMLCOMMUNICATIONMECHANISM)
422 {
423 expectedTargetRole = PROPERTY_ANTECEDENT;
424 a.dunfey 1.64 expectedOriginRole = PROPERTY_DEPENDENT;
425 }
426 break;
427 case PG_ELEMENTCONFORMSTOPROFILE:
428 if(originClass.equal(PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE))
429 {
430 expectedTargetRole =
431 ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT;
432 expectedOriginRole =
433 ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD;
434 }
435 else
436 {
437 expectedTargetRole =
438 ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD;
439 expectedOriginRole =
440 ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT;
441 }
442 break;
|
443 s.manicka 1.69.4.2 case PG_ELEMENTCONFORMSTOPROFILE_RP_RP:
444 propNames.append(CIMName("RegisteredName"));
445 propertyList = CIMPropertyList(propNames);
446 tmpInstance = localGetInstance(
447 context,
448 objectName,
449 propertyList);
450 index = tmpInstance.findProperty("RegisteredName");
451 if (index != PEG_NOT_FOUND)
452 {
453 const CIMValue &tmpVal =
454 tmpInstance.getProperty(index).getValue();
455 if (!tmpVal.isNull())
456 {
457 tmpVal.get(profileName);
458 }
459 }
460 if (String::compareNoCase(profileName, String("SMI-S")) == 0)
461 {
462 expectedTargetRole =
463 ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT;
464 s.manicka 1.69.4.2 expectedOriginRole =
465 ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD;
466 }
467 else
468 {
469 expectedTargetRole =
470 ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD;
471 expectedOriginRole =
472 ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT;
473 }
474 break;
|
475 a.dunfey 1.64 case PG_SUBPROFILEREQUIRESPROFILE:
476 if(originClassEnum == PG_REGISTEREDPROFILE)
477 {
478 expectedTargetRole = PROPERTY_DEPENDENT;
479 expectedOriginRole = PROPERTY_ANTECEDENT;
480 }
481 else if(originClassEnum == PG_REGISTEREDSUBPROFILE)
482 {
483 expectedTargetRole = PROPERTY_ANTECEDENT;
484 expectedOriginRole = PROPERTY_DEPENDENT;
485 }
486 break;
|
487 s.manicka 1.69.4.2 case PG_REFERENCEDPROFILE:
488 if (originClassEnum == PG_REGISTEREDSUBPROFILE)
489 {
490 expectedTargetRole = PROPERTY_ANTECEDENT;
491 expectedOriginRole = PROPERTY_DEPENDENT;
492 }
493 else if (originClassEnum == PG_REGISTEREDPROFILE)
494 {
495 if ((targetProperty.size() != 0) &&
496 (originProperty.size() != 0) &&
497 String::equalNoCase(targetProperty, originProperty))
498 {
499 return false;
500 }
501 if (targetProperty.size() != 0)
502 {
503 if (!(String::equalNoCase(targetProperty, "Antecedent") ||
504 String::equalNoCase(targetProperty, "Dependent") ))
505 {
506 return false;
507 }
508 s.manicka 1.69.4.2 }
509 if (originProperty.size() != 0)
510 {
511 if (!(String::equalNoCase(originProperty, "Antecedent") ||
512 String::equalNoCase(originProperty, "Dependent") ))
513 {
514 return false;
515 }
516 }
517 if (String::equalNoCase(originProperty, "Antecedent") &&
518 targetProperty.size() == 0)
519 {
520 targetProperty = String("Dependent");
521 }
522 if (String::equalNoCase(originProperty, "Dependent") &&
523 targetProperty.size() == 0)
524 {
525 targetProperty = String("Antecedent");
526 }
527 if (String::equalNoCase(targetProperty, "Antecedent") &&
528 originProperty.size() == 0)
529 s.manicka 1.69.4.2 {
530 originProperty = String("Dependent");
531 }
532 if (String::equalNoCase(targetProperty, "Dependent") &&
533 originProperty.size() == 0)
534 {
535 originProperty = String("Antecedent");
536 }
537 return true;
538 }
539 break;
|
540 a.dunfey 1.64 case PG_ELEMENTSOFTWAREIDENTITY:
541 if(originClassEnum == PG_SOFTWAREIDENTITY)
542 {
543 expectedTargetRole = PROPERTY_DEPENDENT;
544 expectedOriginRole = PROPERTY_ANTECEDENT;
545 }
546 else if(originClassEnum == PG_REGISTEREDPROFILE ||
547 originClassEnum == PG_REGISTEREDSUBPROFILE)
548 {
549 expectedTargetRole = PROPERTY_ANTECEDENT;
550 expectedOriginRole = PROPERTY_DEPENDENT;
551 }
552 break;
553 case PG_INSTALLEDSOFTWAREIDENTITY:
554 if(originClassEnum == PG_SOFTWAREIDENTITY)
555 {
556 expectedTargetRole = INSTALLEDSOFTWAREIDENTITY_PROPERTY_SYSTEM;
557 expectedOriginRole =
558 INSTALLEDSOFTWAREIDENTITY_PROPERTY_INSTALLEDSOFTWARE;
559 }
560 else if(originClassEnum == PG_COMPUTERSYSTEM)
561 a.dunfey 1.64 {
562 expectedTargetRole =
563 INSTALLEDSOFTWAREIDENTITY_PROPERTY_INSTALLEDSOFTWARE;
564 expectedOriginRole = INSTALLEDSOFTWAREIDENTITY_PROPERTY_SYSTEM;
565 }
566 break;
567 case PG_HOSTEDACCESSPOINT:
568 if(originClassEnum == PG_COMPUTERSYSTEM)
569 {
570 expectedTargetRole = PROPERTY_DEPENDENT;
571 expectedOriginRole = PROPERTY_ANTECEDENT;
572 }
573 else if(originClassEnum == PG_CIMXMLCOMMUNICATIONMECHANISM)
574 {
575 expectedTargetRole = PROPERTY_ANTECEDENT;
576 expectedOriginRole = PROPERTY_DEPENDENT;
577 }
578 case PG_HOSTEDOBJECTMANAGER:
579 if(originClassEnum == PG_COMPUTERSYSTEM)
580 {
581 expectedTargetRole = PROPERTY_DEPENDENT;
582 a.dunfey 1.64 expectedOriginRole = PROPERTY_ANTECEDENT;
583 }
584 else if(originClassEnum == PG_OBJECTMANAGER)
585 {
586 expectedTargetRole = PROPERTY_ANTECEDENT;
587 expectedOriginRole = PROPERTY_DEPENDENT;
588 }
589 break;
590 default:
591 break;
|
592 tony 1.6 }
|
593 a.dunfey 1.64
|
594 karl 1.5 //
|
595 a.dunfey 1.64 // The rest of this method checks to see if target role and origin roles
596 // were found for the association and origin class combination and, if
597 // found, checks against the input target and origin roles if provided.
598 // Failure for any of these tests points to an invalid association
599 // traversal request.
|
600 karl 1.5 //
|
601 a.dunfey 1.64 if(expectedTargetRole.isNull() ||
602 expectedOriginRole.isNull())
|
603 tony 1.6 {
604 PEG_METHOD_EXIT();
|
605 a.dunfey 1.64 return false;
|
606 tony 1.6 }
607
|
608 a.dunfey 1.64 if(targetProperty.size() == 0)
|
609 karl 1.5 {
|
610 a.dunfey 1.64 targetProperty = expectedTargetRole.getString();
|
611 karl 1.5 }
|
612 a.dunfey 1.64 else if(!expectedTargetRole.equal(targetProperty))
|
613 karl 1.48 {
|
614 a.dunfey 1.64 PEG_METHOD_EXIT();
615 return false;
|
616 karl 1.48 }
|
617 david.dillard 1.32
|
618 a.dunfey 1.64 if(originProperty.size() == 0)
|
619 tony 1.6 {
|
620 a.dunfey 1.64 originProperty = expectedOriginRole.getString();
|
621 tony 1.6 }
|
622 a.dunfey 1.64 else if(!expectedOriginRole.equal(originProperty))
|
623 tony 1.6 {
624 PEG_METHOD_EXIT();
|
625 a.dunfey 1.64 return false;
|
626 tony 1.6 }
|
627 kumpf 1.69
|
628 tony 1.6 PEG_METHOD_EXIT();
|
629 a.dunfey 1.64 return true;
|
630 karl 1.5 }
|
631 karl 1.28
|
632 a.dunfey 1.64 //
633 // Local version of the references operation. It validates the input
634 // parameters, setting the origin and target property values if not set
635 // already, and then performs an enumeration on the association class. It then
636 // filters the results of that enumeration to see if one of the reference
637 // properties matches the objectName parameter passed into the method. If so,
638 // then it is added to the array of association instances to be returned.
639 //
640 Array<CIMInstance> InteropProvider::localReferences(
641 const OperationContext & context,
642 const CIMObjectPath & objectName,
643 const CIMName & assocClass,
644 String & originProperty,
645 String & targetProperty,
646 const CIMPropertyList & propertyList,
647 const CIMName & targetClass)
|
648 karl 1.5 {
|
649 tony 1.6 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
|
650 a.dunfey 1.64 "InteropProvider::localReferences()");
|
651 karl 1.5
|
652 a.dunfey 1.64 Array<CIMInstance> instances;
653 CIMName originClass = objectName.getClassName();
654
655 Array<CIMName> targetSubclasses;
656 CIMNamespaceName lastTargetNamespace;
657 CIMNamespaceName originNamespace(objectName.getNameSpace());
658
659 // Check that the association traversal request is valid
|
660 s.manicka 1.69.4.2 if (validAssocClassForObject(
661 context,
662 assocClass,
663 objectName,
664 originNamespace,
665 originProperty,
666 targetProperty))
|
667 a.dunfey 1.64 {
668 // retrieve all of the association class instances
669 Array<CIMInstance> localInstances = localEnumerateInstances(context,
670 CIMObjectPath(hostName, originNamespace,
671 assocClass));
672 // Filter the association class instances based on the origin instance
673 // and other input parameters.
674 for(Uint32 i = 0, n = localInstances.size(); i < n; ++i)
675 {
676 CIMInstance & currentInstance = localInstances[i];
677 CIMObjectPath originPath = getRequiredValue<CIMObjectPath>(
678 currentInstance, originProperty);
679 originPath.setNameSpace(objectName.getNameSpace());
680 originPath.setHost(objectName.getHost());
681 // Only include instances where the origin instance is present in
682 // the association.
683 if(originPath.identical(objectName))
|
684 karl 1.5 {
|
685 a.dunfey 1.64 if(!targetClass.isNull())
|
686 karl 1.5 {
|
687 a.dunfey 1.64 // Have to check if the target reference is of the
688 // targetClass type. We first must determine all the
689 // possible subclasses of the targetClass in the target
690 // namespace.
691 CIMObjectPath targetPath = getRequiredValue<CIMObjectPath>(
692 currentInstance, targetProperty);
693
694 CIMNamespaceName targetNamespace(
695 targetPath.getNameSpace());
696 if(targetNamespace.isNull())
697 {
698 targetNamespace = originNamespace;
699 targetPath.setNameSpace(targetNamespace);
700 }
701 if(targetNamespace != lastTargetNamespace)
702 {
703 try
704 {
705 targetSubclasses = repository->enumerateClassNames(
706 targetNamespace, targetClass, true);
707 }
708 a.dunfey 1.64 catch(...)
709 {
710 // If an exception was thrown during enumeration,
711 // then the base class didn't exist in the
712 // namespace, so the target instance retrieved
713 // must not match the targetClass parameter.
714 continue;
715 }
716 targetSubclasses.append(targetClass);
717 lastTargetNamespace = targetNamespace;
718 }
|
719 david.dillard 1.32
|
720 a.dunfey 1.64 // Try to find the targetPath's class in the search space
721 CIMName targetPathClass = targetPath.getClassName();
722 for(Uint32 j = 0, m = targetSubclasses.size(); j < m; ++j)
723 {
724 if(targetPathClass == targetSubclasses[j])
725 {
726 instances.append(currentInstance);
727 break;
728 }
729 }
730 }
731 else
|
732 karl 1.46 {
|
733 a.dunfey 1.64 instances.append(currentInstance);
|
734 karl 1.46 }
|
735 tony 1.6 }
|
736 karl 1.1 }
|
737 karl 1.46 }
738
739 PEG_METHOD_EXIT();
|
740 a.dunfey 1.64 return instances;
|
741 karl 1.1 }
742
|
743 a.dunfey 1.64
744 //
745 // Builds an instance of the class named className. Gets Class defintion and
746 // fills in the correct properties from the class. This requires a repository
747 // getClass request for each instance built. The skeleton is built by
748 // creating the instance and copying qualifiers and properties from
749 // the class. Finally the instance is cloned to separate it from the
750 // original objects.
751 // NOTE: This is very inefficient for anything larger than a few instances.
752 // We should separate the get from the createSkeleton.
753 // @param className CIMName of the class for which the instance is to be built
754 // @return CIMInstance of this class with properties complete.
755 // @exception passes on any exceptions received from the repository request.
756 //
757 CIMInstance InteropProvider::buildInstanceSkeleton(
758 const CIMNamespaceName & nameSpace,
759 const CIMName& className,
760 CIMClass& returnedClass)
|
761 karl 1.1 {
|
762 tony 1.6 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
|
763 a.dunfey 1.64 "InteropProvider::_buildInstanceSkeleton()");
764 // get class with lo = false, qualifier = true classorig = true
765 returnedClass = repository->getClass(nameSpace,
766 className, false, true, true);
767 CIMInstance skeleton = returnedClass.buildInstance(true,true,
768 CIMPropertyList());
|
769 karl 1.46
770 PEG_METHOD_EXIT();
|
771 a.dunfey 1.64 return skeleton;
|
772 karl 1.1 }
773
|
774 karl 1.46
|
775 a.dunfey 1.64 CIMInstance InteropProvider::buildDependencyInstance(
776 const String & antecedentId,
777 const CIMName & antecedentClass,
778 const String & dependentId,
779 const CIMName & dependentClass,
780 const CIMClass & dependencyClass)
|
781 karl 1.1 {
|
782 a.dunfey 1.64 Array<CIMKeyBinding> dependentKeys;
|
783 karl 1.52
|
784 a.dunfey 1.64 dependentKeys.append(CIMKeyBinding(
785 COMMON_PROPERTY_INSTANCEID,
786 dependentId,CIMKeyBinding::STRING));
|
787 karl 1.46
|
788 a.dunfey 1.64 return buildDependencyInstanceFromPaths(
789 buildDependencyReference(hostName, antecedentId, antecedentClass),
790 buildDependencyReference(hostName, dependentId, dependentClass),
791 dependencyClass);
|
792 tony 1.6 }
|
793 karl 1.46
|
794 a.dunfey 1.65 void InteropProvider::initProvider()
795 {
796 if(providerInitialized)
797 return;
798 // Placed METHOD_ENTER trace statement after checking whether the
799 // provider is initialized because this method will be called for every
800 // operation through the InteropProvider, and this method is only
801 // interesting the first time it is successfully run.
802 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
803 "InteropProvider::initProvider()");
804
805 AutoMutex lock(interopMut);
806 if(!providerInitialized)
807 {
808 //
809 // Initialize the object manager instance for the CIM Server, and
810 // retrieve the object manager's name property. This is retrieved once
811 // and stored for use in constructing other instances requiring its
812 // value.
813 //
814 CIMInstance objectManager = getObjectManagerInstance();
815 a.dunfey 1.65 objectManager.getProperty(objectManager.findProperty(
816 OM_PROPERTY_NAME)).getValue().get(objectManagerName);
817
818 //
|
819 karl 1.66 // Determine whether the CIMOM should be gathering statistical data
|
820 a.dunfey 1.65 // based on the GatherStatisticalData property in the object manager.
821 //
822 Uint32 gatherDataIndex = objectManager.findProperty(
823 OM_PROPERTY_GATHERSTATISTICALDATA);
824 if(gatherDataIndex != PEG_NOT_FOUND)
825 {
826 CIMConstProperty gatherDataProp =
827 objectManager.getProperty(gatherDataIndex);
828 if (gatherDataProp.getType() == CIMTYPE_BOOLEAN)
829 {
830 CIMValue gatherDataVal = gatherDataProp.getValue();
831 if (!gatherDataVal.isNull())
832 {
833 Boolean gatherData;
834 gatherDataVal.get(gatherData);
|
835 kumpf 1.69 if (gatherData == true)
|
836 a.dunfey 1.65 {
837 StatisticalData* sd = StatisticalData::current();
838 sd->setCopyGSD(true);
839 }
840 }
841 }
842 }
843
844 // Cache this class definition for use later.
845 profileCapabilitiesClass = repository->getClass(
846 PEGASUS_NAMESPACENAME_INTEROP,
|
847 karl 1.66 PEGASUS_CLASSNAME_PG_PROVIDERPROFILECAPABILITIES,
848 false, true, false);
849
|
850 a.dunfey 1.65 providerClassifications.append(Uint16(5)); // "Instrumentation"
851
852 //
853 // Initialize the namespaces so that all namespaces with the
854 // CIM_ElementConformsToProfile class also have the
|
855 karl 1.66 // PG_ElementConformsToProfile class. Needed in order to implement
|
856 a.dunfey 1.65 // the cross-namespace ElementConformsToProfile association in both
857 // directions.
858 //
|
859 kumpf 1.69 Array<CIMNamespaceName> namespaceNames =
|
860 a.dunfey 1.65 repository->enumerateNameSpaces();
|
861 kumpf 1.69 // get the PG_ElementConformstoProfile class without the qualifiers
862 // and then add just the required ASSOCIATION qualifier, so that
863 // resolveclass doesn't fail for the test/EmbeddedInstance/Dynamic
864 // namespace, which uses the CIM25 schema that doesn't include any
865 // of the new qualifiers added to this class in later versions of
866 // the CIMSchema.
|
867 a.dunfey 1.65 CIMClass conformsClass = repository->getClass(
868 PEGASUS_NAMESPACENAME_INTEROP,
|
869 s.manicka 1.68 PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE, true, false);
870 conformsClass.addQualifier(CIMQualifier(CIMName("ASSOCIATION"),
871 CIMValue(true)));
|
872 a.dunfey 1.65 CIMClass profileClass = repository->getClass(
873 PEGASUS_NAMESPACENAME_INTEROP,
|
874 s.manicka 1.68 PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE, true, false);
|
875 a.dunfey 1.65 for(Uint32 i = 0, n = namespaceNames.size(); i < n; ++i)
876 {
877 // Check if the PG_ElementConformsToProfile class is present
878 CIMNamespaceName & currentNamespace = namespaceNames[i];
879 CIMClass tmpCimClass;
880 CIMClass tmpPgClass;
881 CIMClass tmpPgProfileClass;
882 try
883 {
884 // Look for these classes in the same try-block since the
885 // second depends on the first
886 tmpCimClass = repository->getClass(currentNamespace,
887 PEGASUS_CLASSNAME_CIM_ELEMENTCONFORMSTOPROFILE);
888 tmpPgClass = repository->getClass(currentNamespace,
889 PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE);
890 }
891 catch(const Exception &)
892 {
893 }
894 try
895 {
896 a.dunfey 1.65 tmpPgProfileClass = repository->getClass(currentNamespace,
897 PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE);
898 }
899 catch(const Exception &)
900 {
901 // Note: if any of the above three classes aren't found,
902 // an exception will be thrown, which we can ignore since it's
903 // an expected case
904 // TBD: Log trace message?
905 }
906
907 // If the CIM_ElementConformsToProfile class is present, but
908 // the PG_ElementConformsToProfile or PG_RegisteredProfile
909 // class is not, then add it to that namespace.
910 //
911 // Note that we don't have to check for the
912 // CIM_RegisteredProfile class because if the
913 // CIM_ElementConformsToProfile class is present, the
914 // CIM_RegisteredProfile class must also be present.
915 if(!tmpCimClass.isUninitialized())
916 {
917 a.dunfey 1.65 if(tmpPgClass.isUninitialized())
918 {
|
919 s.manicka 1.68 CIMClass newclass = conformsClass.clone();
|
920 a.dunfey 1.65 CIMObjectPath newPath = conformsClass.getPath();
921 newPath.setNameSpace(currentNamespace);
|
922 s.manicka 1.68 newclass.setPath(newPath);
|
923 a.dunfey 1.65 repository->createClass(currentNamespace,
|
924 s.manicka 1.68 newclass);
|
925 a.dunfey 1.65 }
926 if(tmpPgProfileClass.isUninitialized())
927 {
|
928 s.manicka 1.68 CIMClass newclass = profileClass.clone();
929 CIMObjectPath newPath = profileClass.getPath();
|
930 a.dunfey 1.65 newPath.setNameSpace(currentNamespace);
|
931 s.manicka 1.68 newclass.setPath(newPath);
|
932 a.dunfey 1.65 repository->createClass(currentNamespace,
|
933 s.manicka 1.68 newclass);
|
934 a.dunfey 1.65 }
935 }
936 }
937
938 // Now cache the Registration info used for ElementConformsToProfile
939 cacheProfileRegistrationInfo();
940
941 providerInitialized = true;
942 }
943
944 PEG_METHOD_EXIT();
945 }
946
947 PEGASUS_NAMESPACE_END
|
948 a.dunfey 1.64 // END OF FILE
|