version 1.3, 2007/02/09 18:34:46
|
version 1.27, 2012/09/05 12:16:25
|
|
|
//%2006//////////////////////////////////////////////////////////////////////// |
//%LICENSE//////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// Licensed to The Open Group (TOG) under one or more contributor license |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
// agreements. Refer to the OpenPegasusNOTICE.txt file distributed with |
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; |
// this work for additional information regarding copyright ownership. |
// IBM Corp.; EMC Corporation, The Open Group. |
// Each contributor licenses this file to you under the OpenPegasus Open |
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
// Source License; you may not use this file except in compliance with the |
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
// License. |
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
// |
// EMC Corporation; VERITAS Software Corporation; The Open Group. |
// Permission is hereby granted, free of charge, to any person obtaining a |
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
// copy of this software and associated documentation files (the "Software"), |
// EMC Corporation; Symantec Corporation; The Open Group. |
// to deal in the Software without restriction, including without limitation |
// |
// the rights to use, copy, modify, merge, publish, distribute, sublicense, |
// Permission is hereby granted, free of charge, to any person obtaining a copy |
// and/or sell copies of the Software, and to permit persons to whom the |
// of this software and associated documentation files (the "Software"), to |
// Software is furnished to do so, subject to the following conditions: |
// deal in the Software without restriction, including without limitation the |
// |
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
// The above copyright notice and this permission notice shall be included |
// sell copies of the Software, and to permit persons to whom the Software is |
// in all copies or substantial portions of the Software. |
// furnished to do so, subject to the following conditions: |
// |
// |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN |
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT |
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
// 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. |
|
// | // |
//============================================================================== |
////////////////////////////////////////////////////////////////////////// |
| |
| |
/////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// |
|
|
| |
| |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
|
#include <Pegasus/Common/HostAddress.h> |
#include <Pegasus/Common/PegasusVersion.h> | #include <Pegasus/Common/PegasusVersion.h> |
| |
#include <cctype> | #include <cctype> |
|
|
#include "InteropProvider.h" | #include "InteropProvider.h" |
#include "InteropProviderUtils.h" | #include "InteropProviderUtils.h" |
#include "InteropConstants.h" | #include "InteropConstants.h" |
#include "Guid.h" |
|
| |
#include <Pegasus/Common/StatisticalData.h> | #include <Pegasus/Common/StatisticalData.h> |
|
#include <Pegasus/General/Guid.h> |
| |
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
|
|
const CIMName CIMXMLCOMMMECH_PROPERTY_MULTIPLEOPERATIONSSUPPORTED( | const CIMName CIMXMLCOMMMECH_PROPERTY_MULTIPLEOPERATIONSSUPPORTED( |
"MultipleOperationsSupported"); | "MultipleOperationsSupported"); |
const CIMName CIMXMLCOMMMECH_PROPERTY_VERSION("Version"); | const CIMName CIMXMLCOMMMECH_PROPERTY_VERSION("Version"); |
|
const CIMName |
|
CIMXMLCOMMMECH_PROPERTY_CIMXMLPROTOVERSION("CIMXMLProtocolVersion"); |
const CIMName CIMXMLCOMMMECH_PROPERTY_NAMESPACETYPE("namespaceType"); | const CIMName CIMXMLCOMMMECH_PROPERTY_NAMESPACETYPE("namespaceType"); |
const CIMName CIMXMLCOMMMECH_PROPERTY_NAMESPACEACCESSPROTOCOL( | const CIMName CIMXMLCOMMMECH_PROPERTY_NAMESPACEACCESSPROTOCOL( |
"namespaceAccessProtocol"); | "namespaceAccessProtocol"); |
|
|
profileDescriptions.append("Instance Manipulation"); | profileDescriptions.append("Instance Manipulation"); |
| |
ConfigManager* configManager = ConfigManager::getInstance(); | ConfigManager* configManager = ConfigManager::getInstance(); |
if (String::equal(configManager->getCurrentValue( |
if (ConfigManager::parseBooleanValue( |
"enableAssociationTraversal"), "true")) |
configManager->getCurrentValue("enableAssociationTraversal"))) |
{ | { |
profiles.append(6); | profiles.append(6); |
profileDescriptions.append("Association Traversal"); | profileDescriptions.append("Association Traversal"); |
|
|
profiles.append(8); | profiles.append(8); |
profileDescriptions.append("Qualifier Declaration"); | profileDescriptions.append("Qualifier Declaration"); |
| |
if (String::equal(configManager->getCurrentValue( |
if (ConfigManager::parseBooleanValue( |
"enableIndicationService"), "true")) |
configManager->getCurrentValue("enableIndicationService"))) |
{ | { |
profiles.append(9); | profiles.append(9); |
profileDescriptions.append("Indications"); | profileDescriptions.append("Indications"); |
} | } |
} | } |
| |
|
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. |
|
|
PEGASUS_CLASSNAME_PG_CIMXMLCOMMUNICATIONMECHANISM.getString()); | PEGASUS_CLASSNAME_PG_CIMXMLCOMMUNICATIONMECHANISM.getString()); |
| |
// Name Property | // Name Property |
|
String nameProperty(STRLIT_ARGS("PEGASUSCOMM")); |
|
nameProperty.append(namespaceType); |
|
nameProperty.append(Char16('+')); |
|
nameProperty.append(IPAddress); |
|
|
setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_NAME, | setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_NAME, |
(String("PEGASUSCOMM") + namespaceType)); |
nameProperty); |
| |
// CommunicationMechanism Property - Force to 2. | // CommunicationMechanism Property - Force to 2. |
setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_COMMUNICATIONMECHANISM, | setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_COMMUNICATIONMECHANISM, |
|
|
setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_VERSION, | setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_VERSION, |
CIMXMLProtocolVersion); | CIMXMLProtocolVersion); |
| |
|
//Populate "required" property that's not populated. |
|
// CIMXMLProtocolVersion Property |
|
setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_CIMXMLPROTOVERSION, |
|
Uint16(1)); |
|
|
// NamespaceType Property | // NamespaceType Property |
setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_NAMESPACETYPE, | setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_NAMESPACETYPE, |
namespaceType); | namespaceType); |
|
|
| |
// AdvertiseTypes property | // AdvertiseTypes property |
Array<Uint16> advertiseTypes; | Array<Uint16> advertiseTypes; |
ConfigManager* configManager = ConfigManager::getInstance(); |
if (enableSLP) |
if (String::equal(configManager->getCurrentValue("slp"), "true")) |
|
{ | { |
advertiseTypes.append(3); // Advertised via SLP | advertiseTypes.append(3); // Advertised via SLP |
} | } |
|
|
"InteropProvider::enumCIMXMLCommunicationMechanismInstances"); | "InteropProvider::enumCIMXMLCommunicationMechanismInstances"); |
| |
ConfigManager* configManager = ConfigManager::getInstance(); | ConfigManager* configManager = ConfigManager::getInstance(); |
Boolean enableHttpConnection = String::equal( |
Boolean enableHttpConnection = ConfigManager::parseBooleanValue( |
configManager->getCurrentValue("enableHttpConnection"), "true"); |
configManager->getCurrentValue("enableHttpConnection")); |
Boolean enableHttpsConnection = String::equal( |
Boolean enableHttpsConnection = ConfigManager::parseBooleanValue( |
configManager->getCurrentValue("enableHttpsConnection"), "true"); |
configManager->getCurrentValue("enableHttpsConnection")); |
|
String listenAdd = configManager->getCurrentValue( |
|
"listenAddress"); |
| |
Array<CIMInstance> instances; | Array<CIMInstance> instances; |
Uint32 namespaceAccessProtocol; | Uint32 namespaceAccessProtocol; |
|
|
PEGASUS_NAMESPACENAME_INTEROP, | PEGASUS_NAMESPACENAME_INTEROP, |
PEGASUS_CLASSNAME_PG_CIMXMLCOMMUNICATIONMECHANISM, false, true, false); | PEGASUS_CLASSNAME_PG_CIMXMLCOMMUNICATIONMECHANISM, false, true, false); |
| |
|
Array<String> ips; |
|
|
|
if(!String::equalNoCase(listenAdd, "All")) |
|
{ |
|
ips = DefaultPropertyOwner::parseAndGetListenAddress(listenAdd); |
|
//Filter out the loopback addresses without going deeper to TCP Layer |
|
for(Uint32 i = 0, n = ips.size(); i < n; ++i) |
|
{ |
|
String add = ips[i]; |
|
if((add.size() >= 3) && |
|
((add[0] == Char16(':') && add[1] == Char16(':') && |
|
add[2] == Char16('1')) || |
|
( add[0] == Char16('1') && add[1] == Char16('2') && |
|
add[2] == Char16('7')))) |
|
{ |
|
ips.remove(i); |
|
} |
|
} |
|
|
|
} |
|
else |
|
{ |
|
#ifdef PEGASUS_ENABLE_IPV6 |
|
ips = System::getInterfaceAddrs(); |
|
#endif |
|
} |
if (enableHttpConnection) | if (enableHttpConnection) |
{ | { |
// Build the CommunicationMechanism instance for the HTTP protocol | // Build the CommunicationMechanism instance for the HTTP protocol |
namespaceAccessProtocol = 2; | namespaceAccessProtocol = 2; |
namespaceType = "http"; | namespaceType = "http"; |
String httpPort = configManager->getCurrentValue("httpPort"); |
CIMInstance instance; |
if (httpPort == String::EMPTY) |
for (Uint32 i = 0; i < ips.size() ; ++i) |
|
{ |
|
String addr = ips[i]; |
|
HostAddress tmp; |
|
tmp.setHostAddress(addr); |
|
if(tmp.getAddressType() == HostAddress::AT_IPV6) |
{ | { |
Uint32 portNumberHttp = System::lookupPort( |
addr = "[" + addr + "]"; |
WBEM_HTTP_SERVICE_NAME, WBEM_DEFAULT_HTTP_PORT); |
|
char buffer[32]; |
|
sprintf(buffer, "%u", portNumberHttp); |
|
httpPort.assign(buffer); |
|
} | } |
CIMInstance instance = |
addr.append(":"); |
|
addr.append(httpPort); |
|
|
|
instance = |
buildCIMXMLCommunicationMechanismInstance( | buildCIMXMLCommunicationMechanismInstance( |
namespaceType, | namespaceType, |
namespaceAccessProtocol, | namespaceAccessProtocol, |
|
addr, |
|
commMechClass); |
|
instances.append(instance); |
|
} |
|
// If System::getInterfaceAddrs() fails add ip4 addr here. |
|
if (!ips.size()) |
|
{ |
|
instance = buildCIMXMLCommunicationMechanismInstance( |
|
namespaceType, |
|
namespaceAccessProtocol, |
getHostAddress(hostName, namespaceAccessProtocol, httpPort), | getHostAddress(hostName, namespaceAccessProtocol, httpPort), |
commMechClass); | commMechClass); |
instances.append(instance); | instances.append(instance); |
} | } |
|
} |
| |
if (enableHttpsConnection) | if (enableHttpsConnection) |
{ | { |
// Build the CommunicationMechanism instance for the HTTPS protocol | // Build the CommunicationMechanism instance for the HTTPS protocol |
namespaceAccessProtocol = 3; | namespaceAccessProtocol = 3; |
namespaceType = "https"; | namespaceType = "https"; |
String httpsPort = configManager->getCurrentValue("httpsPort"); |
CIMInstance instance; |
if (httpsPort == String::EMPTY) |
for (Uint32 i = 0; i < ips.size() ; ++i) |
{ | { |
Uint32 portNumberHttps = System::lookupPort( |
String addr = ips[i]; |
WBEM_HTTPS_SERVICE_NAME, WBEM_DEFAULT_HTTPS_PORT); |
HostAddress tmp; |
char buffer[32]; |
tmp.setHostAddress(addr); |
sprintf(buffer, "%u", portNumberHttps); |
if(tmp.getAddressType() == HostAddress::AT_IPV6) |
httpsPort.assign(buffer); |
{ |
} |
addr = "[" + addr + "]"; |
CIMInstance instance = |
} |
|
addr.append(":"); |
|
addr.append(httpsPort); |
|
instance = |
buildCIMXMLCommunicationMechanismInstance( | buildCIMXMLCommunicationMechanismInstance( |
namespaceType, | namespaceType, |
namespaceAccessProtocol, | namespaceAccessProtocol, |
|
addr, |
|
commMechClass); |
|
instances.append(instance); |
|
} |
|
// If System::getInterfaceAddrs() fails add ip4 addr here. |
|
if (!ips.size()) |
|
{ |
|
instance = buildCIMXMLCommunicationMechanismInstance( |
|
namespaceType, |
|
namespaceAccessProtocol, |
getHostAddress(hostName, namespaceAccessProtocol, httpsPort), | getHostAddress(hostName, namespaceAccessProtocol, httpsPort), |
commMechClass); | commMechClass); |
|
|
instances.append(instance); | instances.append(instance); |
} | } |
|
} |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return instances; | return instances; |
} | } |
| |
// | // |
// 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, 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, 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); |
instance.setPath(instancePath); |
objPath.setHost(System::getHostName()); |
|
instance.setPath(objPath); |
|
|
|
_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 |
PEG_TRACE(( |
try |
TRC_CONTROLPROVIDER, |
{ |
Tracer::LEVEL3, |
repository->modifyInstance(instanceReference.getNameSpace(), |
"Interop Provider Set Statistics gathering in CIM_ObjectManager: %s", |
omInstance, false, propertyList); |
(statisticsFlag? "true" : "false"))); |
} |
|
catch(const CIMException&) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
throw; |
|
} |
|
catch(const Exception&) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
throw; |
|
} |
|
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, |
|
"Interop Provider Set Statistics gathering in CIM_ObjectManager: $0", |
|
(statisticsFlag? "true" : "false")); |
|
StatisticalData* sd = StatisticalData::current(); | StatisticalData* sd = StatisticalData::current(); |
sd->setCopyGSD(statisticsFlag); | sd->setCopyGSD(statisticsFlag); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
|
|
// 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); |
|
|
CIMClass targetClass; | CIMClass targetClass; |
CIMInstance instanceskel = buildInstanceSkeleton( | CIMInstance instanceskel = buildInstanceSkeleton( |
PEGASUS_NAMESPACENAME_INTEROP, | PEGASUS_NAMESPACENAME_INTEROP, |
PEGASUS_CLASSNAME_PG_COMMMECHANISMFORMANAGER, targetClass); |
PEGASUS_CLASSNAME_PG_COMMMECHANISMFORMANAGER, true, targetClass); |
for (Uint32 i = 0, n = commInstances.size(); i < n; ++i) | for (Uint32 i = 0, n = commInstances.size(); i < n; ++i) |
{ | { |
CIMInstance instance = instanceskel.clone(); | CIMInstance instance = instanceskel.clone(); |
|
|
return assocInstances; | return assocInstances; |
} | } |
| |
|
#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( |
|
const CIMName &className, |
|
const CIMName &propName1, |
|
const CIMObjectPath &objPath1, |
|
const CIMName &propName2, |
|
const CIMObjectPath &objPath2) |
|
{ |
|
CIMClass cimClass = repository->getClass( |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
className, |
|
false, |
|
true, |
|
true); |
|
|
|
CIMInstance instance = cimClass.buildInstance( |
|
true, |
|
true, |
|
CIMPropertyList()); |
|
|
|
instance.getProperty(instance.findProperty(propName1)).setValue(objPath1); |
|
instance.getProperty(instance.findProperty(propName2)).setValue(objPath2); |
|
instance.setPath(instance.buildPath(cimClass)); |
|
|
|
return instance; |
|
} |
|
|
|
Array<CIMInstance> InteropProvider::enumElementCapabilityInstances( |
|
const OperationContext &opContext) |
|
{ |
|
// Get CIM_IndicationServiceCapabilities instance |
|
Array<CIMObjectPath> capPaths = cimomHandle.enumerateInstanceNames( |
|
opContext, |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_CIM_INDICATIONSERVICECAPABILITIES); |
|
PEGASUS_ASSERT(capPaths.size() == 1); |
|
|
|
// Get CIM_IndicationService instance |
|
Array<CIMObjectPath> servicePaths = cimomHandle.enumerateInstanceNames( |
|
opContext, |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE); |
|
PEGASUS_ASSERT(servicePaths.size() == 1); |
|
|
|
Array<CIMInstance> instances; |
|
|
|
instances.append( |
|
buildAssociationInstance( |
|
PEGASUS_CLASSNAME_PG_ELEMENTCAPABILITIES, |
|
PROPERTY_CAPABILITIES, |
|
capPaths[0], |
|
PROPERTY_MANAGEDELEMENT, |
|
servicePaths[0])); |
|
|
|
return instances; |
|
} |
|
|
|
Array<CIMInstance> InteropProvider::enumHostedIndicationServiceInstances( |
|
const OperationContext &opContext) |
|
{ |
|
Array<CIMInstance> instances; |
|
CIMInstance cInst = getComputerSystemInstance(opContext); |
|
|
|
// Get CIM_IndicationService instance |
|
Array<CIMObjectPath> servicePaths = cimomHandle.enumerateInstanceNames( |
|
opContext, |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE); |
|
|
|
PEGASUS_ASSERT(servicePaths.size() == 1); |
|
|
|
instances.append( |
|
buildAssociationInstance( |
|
PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE, |
|
PROPERTY_ANTECEDENT, |
|
cInst.getPath(), |
|
PROPERTY_DEPENDENT, |
|
servicePaths[0])); |
|
|
|
return instances; |
|
} |
|
|
|
Array<CIMInstance> InteropProvider::enumServiceAffectsElementInstances( |
|
const OperationContext &opContext) |
|
{ |
|
Array<CIMInstance> instances; |
|
|
|
// Get CIM_IndicationService instance |
|
Array<CIMObjectPath> servicePaths = cimomHandle.enumerateInstanceNames( |
|
opContext, |
|
PEGASUS_NAMESPACENAME_INTEROP, |
|
PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE); |
|
PEGASUS_ASSERT(servicePaths.size() == 1); |
|
|
|
Array<CIMNamespaceName> namespaceNames = repository->enumerateNameSpaces(); |
|
// Get CIM_IndicationFilter and CIM_ListenerDestination instances in all |
|
// namespaces and associate them with CIM_IndicationService instance using |
|
// PG_ServiceAffectsElement instance. |
|
for (Uint32 i = 0, n = namespaceNames.size() ; i < n ; ++i) |
|
{ |
|
Array<CIMObjectPath> filterPaths; |
|
try |
|
{ |
|
// Get CIM_IndicationFilter instance names |
|
filterPaths = cimomHandle.enumerateInstanceNames( |
|
opContext, |
|
namespaceNames[i], |
|
PEGASUS_CLASSNAME_INDFILTER); |
|
} |
|
catch(CIMException &e) |
|
{ |
|
// Ignore exception with CIM_ERR_INVALID_CLASS code. This will |
|
// happen when the class CIM_IndicationFilter can not be found |
|
// in this namespace. |
|
if (e.getCode() != CIM_ERR_INVALID_CLASS) |
|
{ |
|
PEG_TRACE(( |
|
TRC_CONTROLPROVIDER, |
|
Tracer::LEVEL2, |
|
"CIMException while enumerating the " |
|
"CIM_IndicationFilter instances" |
|
" in the namespace %s: %s.", |
|
(const char*)namespaceNames[i].getString().getCString(), |
|
(const char*)e.getMessage().getCString())); |
|
} |
|
} |
|
catch(Exception &e) |
|
{ |
|
PEG_TRACE(( |
|
TRC_CONTROLPROVIDER, |
|
Tracer::LEVEL1, |
|
"Exception while enumerating the " |
|
"CIM_IndicationFilter instances" |
|
" in the namespace %s: %s.", |
|
(const char*)namespaceNames[i].getString().getCString(), |
|
(const char*)e.getMessage().getCString())); |
|
} |
|
catch(...) |
|
{ |
|
PEG_TRACE(( |
|
TRC_CONTROLPROVIDER, |
|
Tracer::LEVEL1, |
|
"Unknown error occurred while enumerating the " |
|
"CIM_IndicationFilter instances in the namespace %s.", |
|
(const char*)namespaceNames[i].getString().getCString())); |
|
} |
|
for (Uint32 f = 0, fn = filterPaths.size(); f < fn ; ++f) |
|
{ |
|
filterPaths[f].setNameSpace(namespaceNames[i]); |
|
instances.append( |
|
buildAssociationInstance( |
|
PEGASUS_CLASSNAME_PG_SERVICEAFFECTSELEMENT, |
|
PROPERTY_AFFECTEDELEMENT, |
|
filterPaths[f], |
|
PROPERTY_AFFECTINGELEMENT, |
|
servicePaths[0])); |
|
} |
|
|
|
Array<CIMObjectPath> handlerPaths; |
|
try |
|
{ |
|
// Get CIM_ListenerDestination instance names |
|
handlerPaths = cimomHandle.enumerateInstanceNames( |
|
opContext, |
|
namespaceNames[i], |
|
PEGASUS_CLASSNAME_LSTNRDST); |
|
} |
|
catch(CIMException &e) |
|
{ |
|
// Ignore exception with CIM_ERR_INVALID_CLASS code. This will |
|
// happen when the class CIM_ListenerDestination can not be found |
|
// in this namespace. |
|
if (e.getCode() != CIM_ERR_INVALID_CLASS) |
|
{ |
|
PEG_TRACE(( |
|
TRC_CONTROLPROVIDER, |
|
Tracer::LEVEL2, |
|
"CIMException while enumerating the " |
|
"CIM_ListenerDestination instances" |
|
" in the namespace %s: %s.", |
|
(const char*)namespaceNames[i].getString().getCString(), |
|
(const char*)e.getMessage().getCString())); |
|
} |
|
} |
|
catch(Exception &e) |
|
{ |
|
PEG_TRACE(( |
|
TRC_CONTROLPROVIDER, |
|
Tracer::LEVEL1, |
|
"Exception while enumerating the " |
|
"CIM_ListenerDestination instances" |
|
" in the namespace %s: %s.", |
|
(const char*)namespaceNames[i].getString().getCString(), |
|
(const char*)e.getMessage().getCString())); |
|
} |
|
catch(...) |
|
{ |
|
PEG_TRACE(( |
|
TRC_CONTROLPROVIDER, |
|
Tracer::LEVEL1, |
|
"Unknown error occurred while enumerating the " |
|
"CIM_ListenerDestination instances in the namespace %s.", |
|
(const char*)namespaceNames[i].getString().getCString())); |
|
} |
|
for (Uint32 h = 0, hn = handlerPaths.size(); h < hn ; ++h) |
|
{ |
|
handlerPaths[h].setNameSpace(namespaceNames[i]); |
|
instances.append( |
|
buildAssociationInstance( |
|
PEGASUS_CLASSNAME_PG_SERVICEAFFECTSELEMENT, |
|
PROPERTY_AFFECTEDELEMENT, |
|
handlerPaths[h], |
|
PROPERTY_AFFECTINGELEMENT, |
|
servicePaths[0])); |
|
} |
|
} |
|
return instances; |
|
} |
|
#endif |
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
| |
// END OF FILE | // END OF FILE |