📄 interopprovider.cpp
字号:
CIMObjectPath(hostName, originNamespace, assocClass)); // Filter the association class instances based on the origin instance // and other input parameters. for(Uint32 i = 0, n = localInstances.size(); i < n; ++i) { CIMInstance & currentInstance = localInstances[i]; CIMObjectPath originPath = getRequiredValue<CIMObjectPath>( currentInstance, originProperty); originPath.setNameSpace(objectName.getNameSpace()); originPath.setHost(objectName.getHost()); // Only include instances where the origin instance is present in // the association. if(originPath.identical(objectName)) { if(!targetClass.isNull()) { // Have to check if the target reference is of the // targetClass type. We first must determine all the // possible subclasses of the targetClass in the target // namespace. CIMObjectPath targetPath = getRequiredValue<CIMObjectPath>( currentInstance, targetProperty); CIMNamespaceName targetNamespace( targetPath.getNameSpace()); if(targetNamespace.isNull()) { targetNamespace = originNamespace; targetPath.setNameSpace(targetNamespace); } if(targetNamespace != lastTargetNamespace) { try { targetSubclasses = repository->enumerateClassNames( targetNamespace, targetClass, true); } catch(...) { // If an exception was thrown during enumeration, // then the base class didn't exist in the // namespace, so the target instance retrieved // must not match the targetClass parameter. continue; } targetSubclasses.append(targetClass); lastTargetNamespace = targetNamespace; } // Try to find the targetPath's class in the search space CIMName targetPathClass = targetPath.getClassName(); for(Uint32 j = 0, m = targetSubclasses.size(); j < m; ++j) { if(targetPathClass == targetSubclasses[j]) { instances.append(currentInstance); break; } } } else { instances.append(currentInstance); } } } } PEG_METHOD_EXIT(); return instances;}//// Builds an instance of the class named className. Gets Class defintion and// fills in the correct properties from the class. This requires a repository// getClass request for each instance built. The skeleton is built by// creating the instance and copying qualifiers and properties from// the class. Finally the instance is cloned to separate it from the// original objects.// NOTE: This is very inefficient for anything larger than a few instances.// We should separate the get from the createSkeleton.// @param className CIMName of the class for which the instance is to be built// @return CIMInstance of this class with properties complete.// @exception passes on any exceptions received from the repository request.//CIMInstance InteropProvider::buildInstanceSkeleton( const CIMNamespaceName & nameSpace, const CIMName& className, CIMClass& returnedClass){ PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::_buildInstanceSkeleton()"); // get class with lo = false, qualifier = true classorig = true returnedClass = repository->getClass(nameSpace, className, false, true, true); CIMInstance skeleton = returnedClass.buildInstance(true,true, CIMPropertyList()); PEG_METHOD_EXIT(); return skeleton;}CIMInstance InteropProvider::buildDependencyInstance( const String & antecedentId, const CIMName & antecedentClass, const String & dependentId, const CIMName & dependentClass, const CIMClass & dependencyClass){ Array<CIMKeyBinding> dependentKeys; dependentKeys.append(CIMKeyBinding( COMMON_PROPERTY_INSTANCEID, dependentId,CIMKeyBinding::STRING)); return buildDependencyInstanceFromPaths( buildDependencyReference(hostName, antecedentId, antecedentClass), buildDependencyReference(hostName, dependentId, dependentClass), dependencyClass);}void InteropProvider::initProvider(){ if(providerInitialized) return; // Placed METHOD_ENTER trace statement after checking whether the // provider is initialized because this method will be called for every // operation through the InteropProvider, and this method is only // interesting the first time it is successfully run. PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::initProvider()"); AutoMutex lock(interopMut); if(!providerInitialized) { // // Initialize the object manager instance for the CIM Server, and // retrieve the object manager's name property. This is retrieved once // and stored for use in constructing other instances requiring its // value. // CIMInstance objectManager = getObjectManagerInstance(); objectManager.getProperty(objectManager.findProperty( OM_PROPERTY_NAME)).getValue().get(objectManagerName); // // Determine whether the CIMOM should be gathering statistical data // based on the GatherStatisticalData property in the object manager. // Uint32 gatherDataIndex = objectManager.findProperty( OM_PROPERTY_GATHERSTATISTICALDATA); if(gatherDataIndex != PEG_NOT_FOUND) { CIMConstProperty gatherDataProp = objectManager.getProperty(gatherDataIndex); if (gatherDataProp.getType() == CIMTYPE_BOOLEAN) { CIMValue gatherDataVal = gatherDataProp.getValue(); if (!gatherDataVal.isNull()) { Boolean gatherData; gatherDataVal.get(gatherData); if (gatherData == true) { StatisticalData* sd = StatisticalData::current(); sd->setCopyGSD(true); } } } } // Cache this class definition for use later. profileCapabilitiesClass = repository->getClass( PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PG_PROVIDERPROFILECAPABILITIES, false, true, false); providerClassifications.append(Uint16(5)); // "Instrumentation" // // Initialize the namespaces so that all namespaces with the // CIM_ElementConformsToProfile class also have the // PG_ElementConformsToProfile class. Needed in order to implement // the cross-namespace ElementConformsToProfile association in both // directions. // Array<CIMNamespaceName> namespaceNames = repository->enumerateNameSpaces(); CIMClass conformsClass = repository->getClass( PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE); CIMClass profileClass = repository->getClass( PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE); for(Uint32 i = 0, n = namespaceNames.size(); i < n; ++i) { // Check if the PG_ElementConformsToProfile class is present CIMNamespaceName & currentNamespace = namespaceNames[i]; CIMClass tmpCimClass; CIMClass tmpPgClass; CIMClass tmpPgProfileClass; try { // Look for these classes in the same try-block since the // second depends on the first tmpCimClass = repository->getClass(currentNamespace, PEGASUS_CLASSNAME_CIM_ELEMENTCONFORMSTOPROFILE); tmpPgClass = repository->getClass(currentNamespace, PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE); } catch(const Exception &) { } try { tmpPgProfileClass = repository->getClass(currentNamespace, PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE); } catch(const Exception &) { // Note: if any of the above three classes aren't found, // an exception will be thrown, which we can ignore since it's // an expected case // TBD: Log trace message? } // If the CIM_ElementConformsToProfile class is present, but // the PG_ElementConformsToProfile or PG_RegisteredProfile // class is not, then add it to that namespace. // // Note that we don't have to check for the // CIM_RegisteredProfile class because if the // CIM_ElementConformsToProfile class is present, the // CIM_RegisteredProfile class must also be present. if(!tmpCimClass.isUninitialized()) { if(tmpPgClass.isUninitialized()) { CIMObjectPath newPath = conformsClass.getPath(); newPath.setNameSpace(currentNamespace); conformsClass.setPath(newPath); repository->createClass(currentNamespace, conformsClass); } if(tmpPgProfileClass.isUninitialized()) { CIMObjectPath newPath = conformsClass.getPath(); newPath.setNameSpace(currentNamespace); conformsClass.setPath(newPath); repository->createClass(currentNamespace, profileClass); } } } // Now cache the Registration info used for ElementConformsToProfile cacheProfileRegistrationInfo(); providerInitialized = true; } PEG_METHOD_EXIT();}PEGASUS_NAMESPACE_END// END OF FILE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -