version 1.64, 2006/11/01 21:51:19
|
version 1.72, 2008/02/20 14:00:31
|
|
|
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
// | // |
//============================================================================== |
//============================================================================= |
|
// |
|
//%//////////////////////////////////////////////////////////////////////////// |
| |
/////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// |
// Interop Provider - This provider services those classes from the | // Interop Provider - This provider services those classes from the |
|
|
#include <Pegasus/Common/StatisticalData.h> | #include <Pegasus/Common/StatisticalData.h> |
| |
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
PEGASUS_NAMESPACE_BEGIN; |
PEGASUS_NAMESPACE_BEGIN |
| |
/***************************************************************************** | /***************************************************************************** |
* | * |
|
|
// Constructor for the InteropProvider control provider | // Constructor for the InteropProvider control provider |
// | // |
InteropProvider::InteropProvider(CIMRepository * rep) : repository(rep), | InteropProvider::InteropProvider(CIMRepository * rep) : repository(rep), |
hostName(System::getHostName())//, namespacesInitialized(false) |
hostName(System::getHostName()), providerInitialized(false), |
|
profileIds(Array<String>()), conformingElements(Array<CIMNameArray>()), |
|
elementNamespaces(Array<CIMNamespaceArray>()) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,"InteropProvider::InteropProvider"); | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,"InteropProvider::InteropProvider"); |
| |
// |
#ifndef PEGASUS_DISABLE_PERFINST |
// 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 or not 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. This is needed in order to implement |
|
// the cross-namespace ElementConformsToProfile association in both |
|
// directions. |
|
// |
|
//if(!namespacesInitialized) |
|
{ |
|
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(...) |
|
{ |
|
} |
|
try | try |
{ | { |
tmpPgProfileClass = repository->getClass(currentNamespace, |
initProvider(); |
PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE); |
|
} |
|
catch(...) |
|
{ |
|
// 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()) |
catch(const Exception &) |
{ | { |
CIMObjectPath newPath = conformsClass.getPath(); |
// Provider initialization may fail if the repository is not |
newPath.setNameSpace(currentNamespace); |
// populated |
conformsClass.setPath(newPath); |
|
repository->createClass(currentNamespace, |
|
profileClass); |
|
} |
|
} |
|
} | } |
|
#endif |
| |
//namespacesInitialized = true; - currently unused |
|
} |
|
|
|
// Now cache the Registration info used for ElementConformsToProfile assoc |
|
cacheProfileRegistrationInfo(); |
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
| |
|
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::localGetInstance"); | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::localGetInstance"); |
| |
Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
"%s getInstance. instanceName= %s , PropertyList= %s", | "%s getInstance. instanceName= %s , PropertyList= %s", |
thisProvider, | thisProvider, |
(const char *)instanceName.toString().getCString(), | (const char *)instanceName.toString().getCString(), |
(const char *)propertyListToString(propertyList).getCString()); |
(const char *)propertyListToString(propertyList).getCString())); |
| |
// Test if we're looking for something outside of our namespace. This will | // Test if we're looking for something outside of our namespace. This will |
// happen during associators calls from PG_RegisteredProfile instances | // happen during associators calls from PG_RegisteredProfile instances |
|
|
opClass != PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE) | opClass != PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE) |
{ | { |
AutoMutex mut(interopMut); | AutoMutex mut(interopMut); |
return cimomHandle.getInstance(context, opNamespace, |
CIMInstance gotInstance = cimomHandle.getInstance( |
instanceName, false, false, false, propertyList); |
context, |
|
opNamespace, |
|
instanceName, |
|
false, |
|
false, |
|
false, |
|
propertyList); |
|
PEG_METHOD_EXIT(); |
|
return gotInstance; |
} | } |
| |
// Create reference from host, namespace, class components of | // Create reference from host, namespace, class components of |
|
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::localEnumerateInstances()"); | "InteropProvider::localEnumerateInstances()"); |
const CIMName & className = ref.getClassName(); | const CIMName & className = ref.getClassName(); |
Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
"%s enumerateInstances. referenc= %s , PropertyList= %s", | "%s enumerateInstances. referenc= %s , PropertyList= %s", |
thisProvider, | thisProvider, |
(const char *)className.getString().getCString(), | (const char *)className.getString().getCString(), |
(const char *)propertyListToString(propertyList).getCString()); |
(const char *)propertyListToString(propertyList).getCString())); |
| |
// Verify that ClassName is correct and get its enum value | // Verify that ClassName is correct and get its enum value |
TARGET_CLASS classEnum = translateClassInput(className); | TARGET_CLASS classEnum = translateClassInput(className); |
|
|
ref.getNameSpace()); | ref.getNameSpace()); |
break; | break; |
} | } |
|
case PG_ELEMENTCONFORMSTOPROFILE_RP_RP: |
|
{ |
|
instances = enumElementConformsToProfileRPRPInstances( |
|
context, |
|
ref.getNameSpace()); |
|
break; |
|
} |
case PG_SUBPROFILEREQUIRESPROFILE: | case PG_SUBPROFILEREQUIRESPROFILE: |
{ | { |
instances = enumSubProfileRequiresProfileInstances(); | instances = enumSubProfileRequiresProfileInstances(); |
|
|
// role and resultRole parameter of an associators/associatorNames operation. | // role and resultRole parameter of an associators/associatorNames operation. |
// | // |
bool InteropProvider::validAssocClassForObject( | bool InteropProvider::validAssocClassForObject( |
const CIMName & assocClass, const CIMName & originClass, |
const OperationContext & context, |
|
const CIMName & assocClass, |
|
const CIMObjectPath & objectName, |
const CIMNamespaceName & opNamespace, | const CIMNamespaceName & opNamespace, |
String & originProperty, String & targetProperty) |
String & originProperty, |
|
String & targetProperty) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::validAssocClassForObject()"); | "InteropProvider::validAssocClassForObject()"); |
TARGET_CLASS assocClassEnum = translateClassInput(assocClass); | TARGET_CLASS assocClassEnum = translateClassInput(assocClass); |
TARGET_CLASS originClassEnum; | TARGET_CLASS originClassEnum; |
|
CIMName originClass = objectName.getClassName(); |
// If the association class is PG_ElementConformsToProfile, we'll have to | // If the association class is PG_ElementConformsToProfile, we'll have to |
// do some special processing in case the origin instance for the operation | // do some special processing in case the origin instance for the operation |
// is managed by another provider. | // is managed by another provider. |
|
|
} | } |
| |
if(!found) | if(!found) |
|
{ |
|
PEG_METHOD_EXIT(); |
return false; | return false; |
} | } |
} | } |
|
} |
else | else |
{ | { |
// Otherwise, just get the enum value representing the origin class | // Otherwise, just get the enum value representing the origin class |
|
|
CIMName expectedTargetRole; | CIMName expectedTargetRole; |
CIMName expectedOriginRole; | CIMName expectedOriginRole; |
| |
|
Array<CIMName> propNames; |
|
String profileName; |
|
CIMPropertyList propertyList; |
|
CIMInstance tmpInstance; |
|
Uint32 index; |
|
propNames.clear(); |
|
|
// | // |
// Set the target and origin role values. Note that if these values are | // Set the target and origin role values. Note that if these values are |
// not set following the switch block, that implies that the origin class | // not set following the switch block, that implies that the origin class |
|
|
ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT; | ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT; |
} | } |
break; | break; |
|
case PG_ELEMENTCONFORMSTOPROFILE_RP_RP: |
|
propNames.append(CIMName("RegisteredName")); |
|
propertyList = CIMPropertyList(propNames); |
|
tmpInstance = localGetInstance( |
|
context, |
|
objectName, |
|
propertyList); |
|
index = tmpInstance.findProperty("RegisteredName"); |
|
if (index != PEG_NOT_FOUND) |
|
{ |
|
const CIMValue &tmpVal = |
|
tmpInstance.getProperty(index).getValue(); |
|
if (!tmpVal.isNull()) |
|
{ |
|
tmpVal.get(profileName); |
|
} |
|
} |
|
if (String::compareNoCase(profileName, String("SMI-S")) == 0) |
|
{ |
|
expectedTargetRole = |
|
ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT; |
|
expectedOriginRole = |
|
ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD; |
|
} |
|
else |
|
{ |
|
expectedTargetRole = |
|
ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD; |
|
expectedOriginRole = |
|
ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT; |
|
} |
|
break; |
case PG_SUBPROFILEREQUIRESPROFILE: | case PG_SUBPROFILEREQUIRESPROFILE: |
if(originClassEnum == PG_REGISTEREDPROFILE) | if(originClassEnum == PG_REGISTEREDPROFILE) |
{ | { |
|
|
expectedOriginRole = PROPERTY_DEPENDENT; | expectedOriginRole = PROPERTY_DEPENDENT; |
} | } |
break; | break; |
|
case PG_REFERENCEDPROFILE: |
|
if (originClassEnum == PG_REGISTEREDSUBPROFILE) |
|
{ |
|
expectedTargetRole = PROPERTY_ANTECEDENT; |
|
expectedOriginRole = PROPERTY_DEPENDENT; |
|
} |
|
else if (originClassEnum == PG_REGISTEREDPROFILE) |
|
{ |
|
if ((targetProperty.size() != 0) && |
|
(originProperty.size() != 0) && |
|
String::equalNoCase(targetProperty, originProperty)) |
|
{ |
|
return false; |
|
} |
|
if (targetProperty.size() != 0) |
|
{ |
|
if (!(String::equalNoCase(targetProperty, "Antecedent") || |
|
String::equalNoCase(targetProperty, "Dependent") )) |
|
{ |
|
return false; |
|
} |
|
} |
|
if (originProperty.size() != 0) |
|
{ |
|
if (!(String::equalNoCase(originProperty, "Antecedent") || |
|
String::equalNoCase(originProperty, "Dependent") )) |
|
{ |
|
return false; |
|
} |
|
} |
|
if (String::equalNoCase(originProperty, "Antecedent") && |
|
targetProperty.size() == 0) |
|
{ |
|
targetProperty = String("Dependent"); |
|
} |
|
if (String::equalNoCase(originProperty, "Dependent") && |
|
targetProperty.size() == 0) |
|
{ |
|
targetProperty = String("Antecedent"); |
|
} |
|
if (String::equalNoCase(targetProperty, "Antecedent") && |
|
originProperty.size() == 0) |
|
{ |
|
originProperty = String("Dependent"); |
|
} |
|
if (String::equalNoCase(targetProperty, "Dependent") && |
|
originProperty.size() == 0) |
|
{ |
|
originProperty = String("Antecedent"); |
|
} |
|
return true; |
|
} |
|
break; |
case PG_ELEMENTSOFTWAREIDENTITY: | case PG_ELEMENTSOFTWAREIDENTITY: |
if(originClassEnum == PG_SOFTWAREIDENTITY) | if(originClassEnum == PG_SOFTWAREIDENTITY) |
{ | { |
|
|
CIMNamespaceName originNamespace(objectName.getNameSpace()); | CIMNamespaceName originNamespace(objectName.getNameSpace()); |
| |
// Check that the association traversal request is valid | // Check that the association traversal request is valid |
if(validAssocClassForObject(assocClass, objectName.getClassName(), |
if (validAssocClassForObject( |
originNamespace, originProperty, targetProperty)) |
context, |
|
assocClass, |
|
objectName, |
|
originNamespace, |
|
originProperty, |
|
targetProperty)) |
{ | { |
// retrieve all of the association class instances | // retrieve all of the association class instances |
Array<CIMInstance> localInstances = localEnumerateInstances(context, | Array<CIMInstance> localInstances = localEnumerateInstances(context, |
|
|
dependencyClass); | dependencyClass); |
} | } |
| |
PEGASUS_NAMESPACE_END; |
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(); |
|
// get the PG_ElementConformstoProfile class without the qualifiers |
|
// and then add just the required ASSOCIATION qualifier, so that |
|
// resolveclass doesn't fail for the test/EmbeddedInstance/Dynamic |
|
// namespace, which uses the CIM25 schema that doesn't include any |
|
// of the new qualifiers added to this class in later versions of |
|
// the CIMSchema. |
|
CIMClass conformsClass = repository->getClass( |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE, true, false); |
|
conformsClass.addQualifier(CIMQualifier(CIMName("ASSOCIATION"), |
|
CIMValue(true))); |
|
CIMClass profileClass = repository->getClass( |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE, true, false); |
|
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()) |
|
{ |
|
CIMClass newclass = conformsClass.clone(); |
|
CIMObjectPath newPath = conformsClass.getPath(); |
|
newPath.setNameSpace(currentNamespace); |
|
newclass.setPath(newPath); |
|
repository->createClass(currentNamespace, |
|
newclass); |
|
} |
|
if(tmpPgProfileClass.isUninitialized()) |
|
{ |
|
CIMClass newclass = profileClass.clone(); |
|
CIMObjectPath newPath = profileClass.getPath(); |
|
newPath.setNameSpace(currentNamespace); |
|
newclass.setPath(newPath); |
|
repository->createClass(currentNamespace, |
|
newclass); |
|
} |
|
} |
|
} |
|
|
|
// Now cache the Registration info used for ElementConformsToProfile |
|
cacheProfileRegistrationInfo(); |
|
|
|
providerInitialized = true; |
|
} |
|
|
|
PEG_METHOD_EXIT(); |
|
} |
| |
|
PEGASUS_NAMESPACE_END |
// END OF FILE | // END OF FILE |