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