version 1.26, 2005/03/15 16:59:21
|
version 1.34, 2005/05/19 13:56:13
|
|
|
// (carolann_graves@hp.com) | // (carolann_graves@hp.com) |
// Karl Schopmeyer - Created Cim_Namespace capabilities. | // Karl Schopmeyer - Created Cim_Namespace capabilities. |
// Karl Schopmeyer - added objectmanager and communication classes | // Karl Schopmeyer - added objectmanager and communication classes |
|
// Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) for Bug#3194 |
|
// David Dillard, VERITAS Software Corp. |
|
// (david.dillard@veritas.com) |
// | // |
//%//////////////////////////////////////////////////////////////////////////// | //%//////////////////////////////////////////////////////////////////////////// |
| |
|
|
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
//#define CDEBUG(X) |
#define CDEBUG(X) |
#define LDEBUG() | #define LDEBUG() |
#define CDEBUG(X) PEGASUS_STD(cout) << "InteropProvider " << X << PEGASUS_STD(endl) |
//#define CDEBUG(X) PEGASUS_STD(cout) << "InteropProvider " << X << PEGASUS_STD(endl) |
//#define LDEBUG(X) Logger::put (Logger::DEBUG_LOG, "InteropProvider", Logger::INFORMATION, "$0", X) | //#define LDEBUG(X) Logger::put (Logger::DEBUG_LOG, "InteropProvider", Logger::INFORMATION, "$0", X) |
// The following is attempt to use the tracer for CDEBUG. Not working. 1 sept 2004 |
|
//#include <cstring> |
|
//#include <stdcxx/stream/strstream> |
|
// This one sucks because not applicable to separate executables. |
|
// looks like we use trace for the externals. |
|
// requires using PEGASUS_USING_PEGASUS |
|
//#define CDEBUG(X) {ostrstream os; os << X; char* tmp = os.str(); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, String(tmp));delete tmp;} |
|
//#define CDEBUG(X) {stringstream os; os << X;string os_str = os.str(); const char* tmp = os_str.c_str(); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, String(tmp); } |
|
| |
//************************************************************************** | //************************************************************************** |
// | // |
|
|
CIM_COMMMECHANISMFORMANAGERASSOC=2 | CIM_COMMMECHANISMFORMANAGERASSOC=2 |
}; | }; |
| |
|
|
|
//************************************************************* |
|
// Constructor |
|
//********************************************************** |
|
InteropProvider::InteropProvider(CIMRepository* repository) |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,"InteropProvider::InteropProvider"); |
|
_repository = repository; |
|
|
|
//*********************************************** |
|
// This is a tempory fix untill there is a method created for the InteropProvider to |
|
// do it's inaliaztion work. This fix sets StatisticalData::CopyGSD, enabling the |
|
//statistical gathering function. |
|
Array<CIMInstance> instance = repository->enumerateInstances(CIMNamespaceName("root/cimv2"), CIMName ("CIM_ObjectManager")); |
|
|
|
if(instance.size() > 0) |
|
{ |
|
Boolean output = false; |
|
Uint32 pos; |
|
if ((pos = instance[0].findProperty(CIMName("GatherStatisticalData"))) != PEG_NOT_FOUND) |
|
{ |
|
CIMConstProperty p1 = instance[0].getProperty(pos); |
|
if (p1.getType() == CIMTYPE_BOOLEAN) |
|
{ |
|
CIMValue v1 = p1.getValue(); |
|
if (!v1.isNull()) |
|
{ |
|
v1.get(output); |
|
if (v1 == true) |
|
{ |
|
StatisticalData* sd = StatisticalData::current(); |
|
sd->setCopyGSD(true); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
//******************************************* end of temporary fix |
|
PEG_METHOD_EXIT(); |
|
} |
|
|
|
|
|
|
//*************************************************************** | //*************************************************************** |
// Provider Utility Functions | // Provider Utility Functions |
//*************************************************************** | //*************************************************************** |
|
|
return(x? "true" : "false"); | return(x? "true" : "false"); |
} | } |
| |
String _toStringPropertyList(const CIMPropertyList& pl) |
static String _toStringPropertyList(const CIMPropertyList& pl) |
{ | { |
String tmp; | String tmp; |
for (Uint32 i = 0; i < pl.size() ; i++) | for (Uint32 i = 0; i < pl.size() ; i++) |
|
|
return(tmp); | return(tmp); |
} | } |
| |
String _showPropertyList(const CIMPropertyList& pl) |
static String _showPropertyList(const CIMPropertyList& pl) |
{ | { |
if (pl.isNull()) | if (pl.isNull()) |
return("NULL"); | return("NULL"); |
|
|
{ | { |
return true; | return true; |
} | } |
|
|
Boolean _validateProperties(const CIMInstance& instance) | Boolean _validateProperties(const CIMInstance& instance) |
{ | { |
return true; | return true; |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return(true); | return(true); |
} | } |
|
|
Boolean _validateRequiredProperty(const CIMObjectPath& objectPath, | Boolean _validateRequiredProperty(const CIMObjectPath& objectPath, |
const CIMName& propertyName, | const CIMName& propertyName, |
const String value) | const String value) |
|
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_fixInstanceCommonKeys()"); | "InteropProvider::_fixInstanceCommonKeys()"); |
String SystemCreationClassName = System::getSystemCreationClassName (); | String SystemCreationClassName = System::getSystemCreationClassName (); |
if (SystemCreationClassName == String::EMPTY) |
|
{ |
|
//Attn: Get this globally. For now This in place because global is often Empty |
|
SystemCreationClassName = "CIM_ComputerSystem"; |
|
} |
|
| |
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME,SystemCreationClassName); | _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME,SystemCreationClassName); |
| |
// Add property SystemName | // Add property SystemName |
| |
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_SYSTEMNAME,System::getHostName()); |
_setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_SYSTEMNAME,System::getFullyQualifiedHostName()); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
| |
|
|
| |
_setPropertyValue(instance, OM_VERSION, CIMXMLProtocolVersion); | _setPropertyValue(instance, OM_VERSION, CIMXMLProtocolVersion); |
| |
// Obsolete function _setPropertyValue(instance, "namespaceType", namespaceType); |
// Obsolete function |
|
_setPropertyValue(instance, "namespaceType", namespaceType); |
| |
_setPropertyValue(instance, "IPAddress", IPAddress); | _setPropertyValue(instance, "IPAddress", IPAddress); |
| |
|
|
return(false); | return(false); |
} | } |
} | } |
catch(CIMException& e) |
catch(const CIMException&) |
{ | { |
Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION, | Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION, |
"Error. Cannot access $0 in repository", CIM_OBJECTMANAGER_CLASSNAME.getString()); | "Error. Cannot access $0 in repository", CIM_OBJECTMANAGER_CLASSNAME.getString()); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw e; |
throw; |
} | } |
catch(Exception& e) |
catch(const Exception&) |
{ | { |
Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION, | Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION, |
"Error. Cannot access $0 in repository", CIM_OBJECTMANAGER_CLASSNAME.getString()); | "Error. Cannot access $0 in repository", CIM_OBJECTMANAGER_CLASSNAME.getString()); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw e; |
throw; |
} | } |
} | } |
| |
|
|
/** build an instance of the CIM_ObjectManager class filling out | /** build an instance of the CIM_ObjectManager class filling out |
the required properties if one does not already exist in the | the required properties if one does not already exist in the |
repository. This function will either return an instance | repository. This function will either return an instance |
|
|
// Add the instance path to this if necessary ATTN ATTN: | // Add the instance path to this if necessary ATTN ATTN: |
try | try |
{ | { |
|
CDEBUG("Create Instance for CIM_ObjectManager"); |
instancePath = _repository->createInstance(_operationNamespace, | instancePath = _repository->createInstance(_operationNamespace, |
instance ); | instance ); |
} | } |
catch(CIMException& e) |
catch(const CIMException&) |
{ | { |
// ATTN: KS generate log error if this not possible | // ATTN: KS generate log error if this not possible |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw e; |
throw; |
} | } |
catch(Exception& e) |
catch(const Exception&) |
{ | { |
// ATTN: Generate log error. | // ATTN: Generate log error. |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw e; |
throw; |
} | } |
instance.setPath(instancePath); | instance.setPath(instancePath); |
} | } |
|
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_getInstancesCIMNamespace()"); | "InteropProvider::_getInstancesCIMNamespace()"); |
| |
CDEBUG("_getinstanceCIMNamespace Gets ONE only from Namespace=" << nameSpace.getString()); |
|
Array<CIMInstance> instances = _getInstancesCIMNamespace(true, true, CIMPropertyList()); | Array<CIMInstance> instances = _getInstancesCIMNamespace(true, true, CIMPropertyList()); |
| |
// search the instances for one with the name property value = input parameter. | // search the instances for one with the name property value = input parameter. |
|
|
// Everything above was commmon to CIM Namespace. The following is PG_Namespace Properties | // Everything above was commmon to CIM Namespace. The following is PG_Namespace Properties |
// | // |
// ATTN: KS Get the correct values for these entities from repository interface. | // ATTN: KS Get the correct values for these entities from repository interface. |
CDEBUG("_buildPGNS Instance get namespace attributes for namespace= " << nameSpace.getString()); |
|
CIMRepository::NameSpaceAttributes attributes; | CIMRepository::NameSpaceAttributes attributes; |
_repository->getNameSpaceAttributes(nameSpace.getString(), attributes); | _repository->getNameSpaceAttributes(nameSpace.getString(), attributes); |
String parent=""; | String parent=""; |
|
|
{ | { |
String key=i.key(); | String key=i.key(); |
String value = i.value(); | String value = i.value(); |
CDEBUG("Show Attributes. key= " << key << " value= " << value); |
|
if (String::equalNoCase(key,"shareable")) | if (String::equalNoCase(key,"shareable")) |
{ | { |
if (String::equalNoCase(value,"true")) | if (String::equalNoCase(value,"true")) |
|
|
} | } |
if (!_validateRequiredProperty(objectPath, | if (!_validateRequiredProperty(objectPath, |
CIM_NAMESPACE_PROPERTY_SYSTEMNAME, | CIM_NAMESPACE_PROPERTY_SYSTEMNAME, |
System::getHostName())) |
System::getFullyQualifiedHostName())) |
{ | { |
propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMNAME; | propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMNAME; |
valid = false; | valid = false; |
|
|
| |
if (!_completeProperty(instance, | if (!_completeProperty(instance, |
CIM_NAMESPACE_PROPERTY_SYSTEMNAME, | CIM_NAMESPACE_PROPERTY_SYSTEMNAME, |
System::getHostName())) |
System::getFullyQualifiedHostName())) |
{ | { |
propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMNAME; | propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMNAME; |
valid = false; | valid = false; |
|
|
| |
if (!_validateRequiredProperty(instance, | if (!_validateRequiredProperty(instance, |
CIM_NAMESPACE_PROPERTY_SYSTEMNAME, | CIM_NAMESPACE_PROPERTY_SYSTEMNAME, |
System::getHostName())) |
System::getFullyQualifiedHostName ())) |
{ | { |
propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMNAME; | propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMNAME; |
valid = false; | valid = false; |
|
|
return(ref); | return(ref); |
} | } |
| |
/* _isNamespace determines if the namespace in the second |
|
parameter is in the array in the first parameter. |
|
@param array of possible namespaces |
|
@param canidate namespace |
|
@return - true if found |
|
*/ |
|
static Boolean _isNamespace( |
|
Array<CIMNamespaceName>& namespaceNames, |
|
CIMNamespaceName& namespaceName) |
|
{ |
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
|
"InteropProvider::_isNamespace"); |
|
|
|
Boolean found = false; |
|
for(Uint32 i = 0; i < namespaceNames.size(); i++) |
|
{ |
|
if(namespaceNames[i].equal ( namespaceName )) |
|
return true; |
|
} |
|
|
|
PEG_METHOD_EXIT(); |
|
return false; |
|
} |
|
|
|
//************************************************************** | //************************************************************** |
// Overloaded functions to get key value with different params | // Overloaded functions to get key value with different params |
//************************************************************** | //************************************************************** |
|
|
newNamespaceName.getString(), shareable? "true" : "false", shareable? "true" : "false", parent ); | newNamespaceName.getString(), shareable? "true" : "false", shareable? "true" : "false", parent ); |
| |
} | } |
catch(CIMException& e) |
catch(const CIMException&) |
{ | { |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw e; |
throw; |
} | } |
catch(Exception& e) |
catch(const Exception&) |
{ | { |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw e; |
throw; |
} | } |
| |
// begin processing the request | // begin processing the request |
|
|
{ | { |
_repository->deleteInstance(_operationNamespace,instanceName); | _repository->deleteInstance(_operationNamespace,instanceName); |
} | } |
catch(CIMException& e) |
catch(const CIMException&) |
{ | { |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw e; |
throw; |
} | } |
} | } |
else if (classEnum == PG_NAMESPACE) | else if (classEnum == PG_NAMESPACE) |
|
|
namespaceName = _getKeyValue(instanceName, CIM_NAMESPACE_PROPERTY_NAME); | namespaceName = _getKeyValue(instanceName, CIM_NAMESPACE_PROPERTY_NAME); |
| |
// ATTN: Why this CIMNamespaceName parentNamespaceName = instanceName.getNameSpace(); | // ATTN: Why this CIMNamespaceName parentNamespaceName = instanceName.getNameSpace(); |
if (!_isNamespace(namespaceNames, namespaceName)) |
if (!Contains(namespaceNames, namespaceName)) |
{ | { |
throw CIMObjectNotFoundException("Namespace does not exist: " | throw CIMObjectNotFoundException("Namespace does not exist: " |
+ namespaceName.getString()); | + namespaceName.getString()); |
|
|
// the only allowed modification is this one property, statistical data | // the only allowed modification is this one property, statistical data |
if (modifiedIns.findProperty(OM_GATHERSTATISTICALDATA) != PEG_NOT_FOUND) | if (modifiedIns.findProperty(OM_GATHERSTATISTICALDATA) != PEG_NOT_FOUND) |
{ | { |
// ATTN: This function is a design problem. |
|
// ATTN: Should the ifdef include everything???? |
|
// the following is a temporary hack to set the value of the statistics | // the following is a temporary hack to set the value of the statistics |
// gathering function dynamically. We simply get the value from input | // gathering function dynamically. We simply get the value from input |
// and call the internal method to set it each time this object is | // and call the internal method to set it each time this object is |
// built. | // built. |
#ifndef PEGASUS_DISABLE_PERFINST | #ifndef PEGASUS_DISABLE_PERFINST |
StatisticalData* sd = StatisticalData::current(); |
|
Boolean statisticsFlag = _getPropertyValue(modifiedIns, OM_GATHERSTATISTICALDATA, false); | Boolean statisticsFlag = _getPropertyValue(modifiedIns, OM_GATHERSTATISTICALDATA, false); |
sd->setCopyGSD(statisticsFlag); |
|
CIMInstance instance; | CIMInstance instance; |
instance = _getInstanceCIMObjectManager(true, true, CIMPropertyList()); | instance = _getInstanceCIMObjectManager(true, true, CIMPropertyList()); |
| |
|
if (statisticsFlag != _getPropertyValue(instance, OM_GATHERSTATISTICALDATA, false)) |
|
{ |
|
// set the changed property into the |
_setPropertyValue(instance, OM_GATHERSTATISTICALDATA, statisticsFlag); | _setPropertyValue(instance, OM_GATHERSTATISTICALDATA, statisticsFlag); |
|
|
// Modify the object on disk | // Modify the object on disk |
try | try |
{ | { |
_repository->modifyInstance(_operationNamespace, | _repository->modifyInstance(_operationNamespace, |
instance ); | instance ); |
} | } |
catch(CIMException& e) |
catch(const CIMException&) |
{ | { |
// ATTN: KS generate log error if this not possible | // ATTN: KS generate log error if this not possible |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw e; |
throw; |
} | } |
catch(Exception& e) |
catch(const Exception&) |
{ | { |
// ATTN: Generate log error. | // ATTN: Generate log error. |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw e; |
throw; |
} | } |
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, | Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, |
"Interop Provider Set Statistics gathering in CIM_ObjectManager: $0", | "Interop Provider Set Statistics gathering in CIM_ObjectManager: $0", |
(statisticsFlag? "true" : "false")); | (statisticsFlag? "true" : "false")); |
|
StatisticalData* sd = StatisticalData::current(); |
|
sd->setCopyGSD(statisticsFlag); |
|
} |
return; | return; |
#endif | #endif |
| |