(file) Return to InteropProvider.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ControlProviders / InteropProvider

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2