version 1.20, 2009/06/22 07:36:53
|
version 1.25, 2012/06/21 08:00:20
|
|
|
} | } |
} | } |
| |
|
String _getHostID() |
|
{ |
|
String ipAddress; |
|
int af; |
|
|
|
String hostName(System::getHostName()); |
|
if (!System::getHostIP(hostName, &af, ipAddress)) |
|
{ |
|
// There is IP address for this host. |
|
// It is not reachable from out side. |
|
ipAddress = String("localhost"); |
|
return ipAddress; |
|
} |
|
|
|
// change the dots to dashes |
|
for (Uint32 i=0; i<ipAddress.size(); i++) |
|
{ |
|
if (ipAddress[i] == Char16('.') || |
|
ipAddress[i] == Char16(':') ) |
|
{ |
|
ipAddress[i] = Char16('-'); |
|
} |
|
} |
|
return ipAddress; |
|
} |
// | // |
// Build a single instance of the CIMXMLCommunicationMechanism class using the | // Build a single instance of the CIMXMLCommunicationMechanism class using the |
// parameters provided. Builds the complete instance and sets its object path. | // parameters provided. Builds the complete instance and sets its object path. |
|
|
} | } |
| |
// | // |
// Get the instance of the CIM_ObjectManager class, creating the instance if it |
// Get the instance of the CIM_ObjectManager class, creating the instance |
// does not already exist in the repository. |
// eache time the cimserve is re-started. |
// | // |
// @param includeQualifiers Boolean | // @param includeQualifiers Boolean |
// @param includeClassOrigin Boolean | // @param includeClassOrigin Boolean |
|
|
CIMInstance InteropProvider::getObjectManagerInstance() | CIMInstance InteropProvider::getObjectManagerInstance() |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::getObjectManagerInstance"); |
"InteropProvider::getObjectManagerInstance()"); |
| |
// Try to get the instance from the repository. |
if (_CIMObjectManagerInst.isUninitialized()) |
CIMInstance instance; |
|
bool found = false; |
|
Array<CIMInstance> tmpInstances = repository->enumerateInstancesForClass( |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_OBJECTMANAGER, false, false, |
|
CIMPropertyList()); |
|
Uint32 numInstances = tmpInstances.size(); |
|
if(numInstances == 1) |
|
{ | { |
instance = tmpInstances[0]; |
PEG_TRACE_CSTRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
} |
" _CIMObjectManagerInst is to be initialized."); |
PEGASUS_ASSERT(numInstances <= 1); |
|
|
|
| |
if(instance.isUninitialized()) |
|
{ |
|
// |
|
// No instance in the repository. Build new instance and save it. |
|
// |
|
CIMClass omClass; | CIMClass omClass; |
instance = buildInstanceSkeleton(PEGASUS_NAMESPACENAME_INTEROP, |
CIMInstance instance; |
PEGASUS_CLASSNAME_PG_OBJECTMANAGER, false, omClass); |
instance = buildInstanceSkeleton( |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_PG_OBJECTMANAGER, |
|
false, |
|
omClass); |
| |
// Set the common key properties | // Set the common key properties |
setCommonKeys(instance); | setCommonKeys(instance); |
| |
setPropertyValue(instance, OM_PROPERTY_CREATIONCLASSNAME, |
setPropertyValue( |
|
instance, |
|
OM_PROPERTY_CREATIONCLASSNAME, |
PEGASUS_CLASSNAME_PG_OBJECTMANAGER.getString()); | PEGASUS_CLASSNAME_PG_OBJECTMANAGER.getString()); |
setPropertyValue(instance, OM_PROPERTY_NAME, |
setPropertyValue( |
String(PEGASUS_INSTANCEID_GLOBAL_PREFIX) + ":" + Guid::getGuid()); |
instance, |
setPropertyValue(instance, OM_PROPERTY_ELEMENTNAME, String("Pegasus")); |
OM_PROPERTY_NAME, |
|
String(PEGASUS_INSTANCEID_GLOBAL_PREFIX) + ":" + _getHostID()); |
|
setPropertyValue( |
|
instance, |
|
OM_PROPERTY_ELEMENTNAME, |
|
String(PEGASUS_PG_OBJECTMANAGER_ELEMENTNAME)); |
|
|
Array<Uint16> operationalStatus; | Array<Uint16> operationalStatus; |
operationalStatus.append(2); | operationalStatus.append(2); |
setPropertyValue(instance, OM_PROPERTY_OPERATIONALSTATUS, |
setPropertyValue( |
|
instance, |
|
OM_PROPERTY_OPERATIONALSTATUS, |
operationalStatus); | operationalStatus); |
setPropertyValue(instance, OM_PROPERTY_STARTED, |
setPropertyValue( |
|
instance, |
|
OM_PROPERTY_STARTED, |
CIMValue(Boolean(true))); | CIMValue(Boolean(true))); |
| |
// | // |
|
|
// If PEGASUS_CIMOM_DESCRIPTION is non-zero length, use it. | // If PEGASUS_CIMOM_DESCRIPTION is non-zero length, use it. |
// Otherwise build form the components below, as defined in | // Otherwise build form the components below, as defined in |
// PegasusVersion.h. | // PegasusVersion.h. |
String descriptionStatus; |
String description = String(PEGASUS_CIMOM_DESCRIPTION); |
|
if (description.size() == 0) |
|
{ |
String pegasusProductStatus(PEGASUS_PRODUCT_STATUS); | String pegasusProductStatus(PEGASUS_PRODUCT_STATUS); |
if(pegasusProductStatus.size() > 0) |
|
descriptionStatus = " " + pegasusProductStatus; |
|
| |
String description = (String(PEGASUS_CIMOM_DESCRIPTION).size() != 0) ? |
description.append(String(PEGASUS_CIMOM_GENERIC_NAME)); |
String(PEGASUS_CIMOM_DESCRIPTION) |
description.append(Char16(' ')); |
: |
description.append(String(PEGASUS_PRODUCT_NAME)); |
String(PEGASUS_CIMOM_GENERIC_NAME) + " " + |
description.append(" Version "); |
String(PEGASUS_PRODUCT_NAME) + " Version " + |
description.append(String(PEGASUS_PRODUCT_VERSION)); |
String(PEGASUS_PRODUCT_VERSION) + |
|
descriptionStatus; |
if(pegasusProductStatus.size() > 0) |
|
{ |
|
description.append(Char16(' ')); |
|
description.append(String(pegasusProductStatus)); |
|
} |
| |
|
} |
setPropertyValue(instance, OM_PROPERTY_DESCRIPTION, description); | setPropertyValue(instance, OM_PROPERTY_DESCRIPTION, description); |
| |
// Property GatherStatisticalData. Initially this is set to false | // Property GatherStatisticalData. Initially this is set to false |
// and can then be modified by a modify instance on the instance. | // and can then be modified by a modify instance on the instance. |
Boolean gatherStatDataFlag = false; | Boolean gatherStatDataFlag = false; |
setPropertyValue(instance, OM_PROPERTY_GATHERSTATISTICALDATA, |
setPropertyValue( |
|
instance, |
|
OM_PROPERTY_GATHERSTATISTICALDATA, |
gatherStatDataFlag); | gatherStatDataFlag); |
| |
// Set the statistics property into the Statisticaldata class so that | // Set the statistics property into the Statisticaldata class so that |
|
|
sd->setCopyGSD(gatherStatDataFlag); | sd->setCopyGSD(gatherStatDataFlag); |
#endif | #endif |
| |
// write instance to the repository |
// build the instance path and set into instance |
CIMObjectPath instancePath = repository->createInstance( |
CIMObjectPath objPath = instance.buildPath(omClass); |
PEGASUS_NAMESPACENAME_INTEROP, instance); |
objPath.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP); |
// Get an updated copy of the instance that was saved |
objPath.setHost(System::getHostName()); |
instance = repository->getInstance( |
instance.setPath(objPath); |
PEGASUS_NAMESPACENAME_INTEROP, instancePath); |
|
instance.setPath(instancePath); |
_CIMObjectManagerInst = instance; |
} | } |
| |
CIMObjectPath currentPath = instance.getPath(); |
|
currentPath.setHost(hostName); |
|
currentPath.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP); |
|
instance.setPath(currentPath); |
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return instance; |
return _CIMObjectManagerInst; |
|
|
} | } |
| |
// | // |
|
|
const CIMPropertyList& propertyList) | const CIMPropertyList& propertyList) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::modifyObjectManagerInstance"); |
"InteropProvider::modifyObjectManagerInstance()"); |
| |
// Modification only allowed when Performance staticistics are active | // Modification only allowed when Performance staticistics are active |
#ifndef PEGASUS_DISABLE_PERFINST | #ifndef PEGASUS_DISABLE_PERFINST |
Uint32 propListSize = propertyList.size(); | Uint32 propListSize = propertyList.size(); |
if(propListSize == 0 && !propertyList.isNull()) | if(propListSize == 0 && !propertyList.isNull()) |
|
{ |
|
PEG_METHOD_EXIT(); |
return; | return; |
|
} |
| |
if(propertyList.size() != 1 || | if(propertyList.size() != 1 || |
propertyList[0] != OM_PROPERTY_GATHERSTATISTICALDATA) | propertyList[0] != OM_PROPERTY_GATHERSTATISTICALDATA) |
{ | { |
|
PEG_METHOD_EXIT(); |
throw CIMNotSupportedException(String("Only modification of ") + | throw CIMNotSupportedException(String("Only modification of ") + |
OM_PROPERTY_GATHERSTATISTICALDATA.getString() + " allowed"); | OM_PROPERTY_GATHERSTATISTICALDATA.getString() + " allowed"); |
} | } |
|
|
omInstance = getObjectManagerInstance(); | omInstance = getObjectManagerInstance(); |
if(omInstance.isUninitialized()) | if(omInstance.isUninitialized()) |
{ | { |
|
PEG_METHOD_EXIT(); |
throw CIMObjectNotFoundException(instanceReference.toString()); | throw CIMObjectNotFoundException(instanceReference.toString()); |
} | } |
statisticsFlag = getPropertyValue(modifiedIns, | statisticsFlag = getPropertyValue(modifiedIns, |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return; | return; |
} | } |
// Modify the instance on disk |
|
repository->modifyInstance(instanceReference.getNameSpace(), |
|
omInstance, false, propertyList); |
|
PEG_TRACE(( | PEG_TRACE(( |
TRC_CONTROLPROVIDER, | TRC_CONTROLPROVIDER, |
Tracer::LEVEL3, | Tracer::LEVEL3, |
|
|
// Get an instance of the PG_ComputerSystem class produced by the | // Get an instance of the PG_ComputerSystem class produced by the |
// ComputerSystem provider in the root/cimv2 namespace. | // ComputerSystem provider in the root/cimv2 namespace. |
// | // |
// @param includeQualifiers Boolean |
// @param opContext Operation context. |
// @param includeClassOrigin Boolean |
|
// @param propertylist CIMPropertyList |
|
// | // |
// @return CIMInstance of PG_ComputerSystem class. | // @return CIMInstance of PG_ComputerSystem class. |
// | // |
// @exception ObjectNotFound exception if a ComputerSystem instance cannot | // @exception ObjectNotFound exception if a ComputerSystem instance cannot |
// be retrieved. | // be retrieved. |
// | // |
CIMInstance InteropProvider::getComputerSystemInstance() |
CIMInstance InteropProvider::getComputerSystemInstance( |
|
const OperationContext &opContext) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::getComputerSystemInstance"); | "InteropProvider::getComputerSystemInstance"); |
|
|
CIMInstance instance; | CIMInstance instance; |
AutoMutex mut(interopMut); | AutoMutex mut(interopMut); |
Array<CIMInstance> tmpInstances = cimomHandle.enumerateInstances( | Array<CIMInstance> tmpInstances = cimomHandle.enumerateInstances( |
OperationContext(), |
opContext, |
PEGASUS_NAMESPACENAME_CIMV2, | PEGASUS_NAMESPACENAME_CIMV2, |
PEGASUS_CLASSNAME_PG_COMPUTERSYSTEM, true, false, false, false, | PEGASUS_CLASSNAME_PG_COMPUTERSYSTEM, true, false, false, false, |
CIMPropertyList()); | CIMPropertyList()); |
|
|
// Returns an instance of the HostedObjectManager association linking the | // Returns an instance of the HostedObjectManager association linking the |
// ObjectManager and ComputerSystem instances managed by this provider. | // ObjectManager and ComputerSystem instances managed by this provider. |
// | // |
CIMInstance InteropProvider::getHostedObjectManagerInstance() |
CIMInstance InteropProvider::getHostedObjectManagerInstance( |
|
const OperationContext &opContext) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::getHostedObjectManagerInstance"); | "InteropProvider::getHostedObjectManagerInstance"); |
|
|
CIMInstance instance; | CIMInstance instance; |
bool found = false; | bool found = false; |
| |
CIMObjectPath csPath = getComputerSystemInstance().getPath(); |
CIMObjectPath csPath = getComputerSystemInstance(opContext).getPath(); |
CIMObjectPath omPath = getObjectManagerInstance().getPath(); | CIMObjectPath omPath = getObjectManagerInstance().getPath(); |
String csPathString = csPath.toString(); | String csPathString = csPath.toString(); |
String omPathString = omPath.toString(); | String omPathString = omPath.toString(); |
|
|
// instances for this CIMOM. One will be produced for every instance of | // instances for this CIMOM. One will be produced for every instance of |
// CIMXMLCommunicatiomMechanism managed by this provider. | // CIMXMLCommunicatiomMechanism managed by this provider. |
// | // |
Array<CIMInstance> InteropProvider::enumHostedAccessPointInstances() |
Array<CIMInstance> InteropProvider::enumHostedAccessPointInstances( |
|
const OperationContext &opContext) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::enumHostedAccessPointInstance"); | "InteropProvider::enumHostedAccessPointInstance"); |
Array<CIMInstance> instances; | Array<CIMInstance> instances; |
| |
CIMObjectPath csPath = getComputerSystemInstance().getPath(); |
CIMObjectPath csPath = getComputerSystemInstance(opContext).getPath(); |
Array<CIMInstance> commMechs = enumCIMXMLCommunicationMechanismInstances(); | Array<CIMInstance> commMechs = enumCIMXMLCommunicationMechanismInstances(); |
CIMClass hapClass = repository->getClass(PEGASUS_NAMESPACENAME_INTEROP, | CIMClass hapClass = repository->getClass(PEGASUS_NAMESPACENAME_INTEROP, |
PEGASUS_CLASSNAME_PG_HOSTEDACCESSPOINT, false, true, false); | PEGASUS_CLASSNAME_PG_HOSTEDACCESSPOINT, false, true, false); |
|
|
| |
#ifdef PEGASUS_ENABLE_DMTF_INDICATION_PROFILE_SUPPORT | #ifdef PEGASUS_ENABLE_DMTF_INDICATION_PROFILE_SUPPORT |
| |
|
Array<CIMInstance> InteropProvider::enumIndicationServiceInstances( |
|
const OperationContext &opContext) |
|
{ |
|
Array<CIMInstance> instances = cimomHandle.enumerateInstances( |
|
opContext, |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE, |
|
true, |
|
false, |
|
true, |
|
true, |
|
CIMPropertyList()); |
|
PEGASUS_ASSERT(instances.size() == 1); |
|
|
|
return instances; |
|
} |
|
|
CIMInstance InteropProvider::buildAssociationInstance( | CIMInstance InteropProvider::buildAssociationInstance( |
const CIMName &className, | const CIMName &className, |
const CIMName &propName1, | const CIMName &propName1, |
|
|
const OperationContext &opContext) | const OperationContext &opContext) |
{ | { |
Array<CIMInstance> instances; | Array<CIMInstance> instances; |
CIMInstance cInst = getComputerSystemInstance(); |
CIMInstance cInst = getComputerSystemInstance(opContext); |
| |
// Get CIM_IndicationService instance | // Get CIM_IndicationService instance |
Array<CIMObjectPath> servicePaths = cimomHandle.enumerateInstanceNames( | Array<CIMObjectPath> servicePaths = cimomHandle.enumerateInstanceNames( |