version 1.1, 2006/11/01 21:51:19
|
version 1.8, 2008/05/12 09:14:52
|
|
|
// 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. |
// | // |
//============================================================================== |
//============================================================================= |
| |
| |
/////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// |
|
|
| |
| |
#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 <Pegasus/Common/StatisticalData.h> | #include <Pegasus/Common/StatisticalData.h> |
| |
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
PEGASUS_NAMESPACE_BEGIN; |
PEGASUS_NAMESPACE_BEGIN |
| |
const String CIMXMLProtocolVersion = "1.0"; | const String CIMXMLProtocolVersion = "1.0"; |
| |
|
|
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"); |
|
|
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); |
|
|
// Build the CommunicationMechanism instance for the HTTP protocol | // Build the CommunicationMechanism instance for the HTTP protocol |
namespaceAccessProtocol = 2; | namespaceAccessProtocol = 2; |
namespaceType = "http"; | namespaceType = "http"; |
Uint32 portNumberHttp; |
|
String httpPort = configManager->getCurrentValue("httpPort"); | String httpPort = configManager->getCurrentValue("httpPort"); |
if (httpPort == String::EMPTY) | if (httpPort == String::EMPTY) |
{ | { |
portNumberHttp = System::lookupPort(WBEM_HTTP_SERVICE_NAME, |
Uint32 portNumberHttp = System::lookupPort( |
WBEM_DEFAULT_HTTP_PORT); |
WBEM_HTTP_SERVICE_NAME, WBEM_DEFAULT_HTTP_PORT); |
|
char buffer[32]; |
|
sprintf(buffer, "%u", portNumberHttp); |
|
httpPort.assign(buffer); |
|
} |
|
CIMInstance instance; |
|
Array<String> ips; |
|
#ifdef PEGASUS_ENABLE_IPV6 |
|
ips = System::getInterfaceAddrs(); |
|
for (Uint32 i = 0; i < ips.size() ; ++i) |
|
{ |
|
String addr = ips[i]; |
|
if (HostAddress::isValidIPV6Address(ips[i])) |
|
{ |
|
addr = "[" + addr + "]"; |
} | } |
CIMInstance instance = |
addr.append(":"); |
|
addr.append(httpPort); |
|
|
|
instance = |
buildCIMXMLCommunicationMechanismInstance( | buildCIMXMLCommunicationMechanismInstance( |
namespaceType, | namespaceType, |
namespaceAccessProtocol, | namespaceAccessProtocol, |
getHostAddress(hostName, namespaceAccessProtocol, httpPort, |
addr, |
portNumberHttp), commMechClass); |
commMechClass); |
|
instances.append(instance); |
|
} |
|
#endif |
|
// If System::getInterfaceAddrs() fails add ip4 addr here. |
|
if (!ips.size()) |
|
{ |
|
instance = buildCIMXMLCommunicationMechanismInstance( |
|
namespaceType, |
|
namespaceAccessProtocol, |
|
getHostAddress(hostName, namespaceAccessProtocol, httpPort), |
|
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"; |
Uint32 portNumberHttps; |
|
String httpsPort = configManager->getCurrentValue("httpsPort"); | String httpsPort = configManager->getCurrentValue("httpsPort"); |
if (httpsPort == String::EMPTY) | if (httpsPort == String::EMPTY) |
{ | { |
portNumberHttps = System::lookupPort(WBEM_HTTPS_SERVICE_NAME, |
Uint32 portNumberHttps = System::lookupPort( |
WBEM_DEFAULT_HTTPS_PORT); |
WBEM_HTTPS_SERVICE_NAME, WBEM_DEFAULT_HTTPS_PORT); |
|
char buffer[32]; |
|
sprintf(buffer, "%u", portNumberHttps); |
|
httpsPort.assign(buffer); |
} | } |
CIMInstance instance = |
CIMInstance instance; |
|
Array<String> ips; |
|
#ifdef PEGASUS_ENABLE_IPV6 |
|
ips = System::getInterfaceAddrs(); |
|
for (Uint32 i = 0; i < ips.size() ; ++i) |
|
{ |
|
String addr = ips[i]; |
|
if (HostAddress::isValidIPV6Address(ips[i])) |
|
{ |
|
addr = "[" + addr + "]"; |
|
} |
|
addr.append(":"); |
|
addr.append(httpsPort); |
|
instance = |
buildCIMXMLCommunicationMechanismInstance( | buildCIMXMLCommunicationMechanismInstance( |
namespaceType, | namespaceType, |
namespaceAccessProtocol, | namespaceAccessProtocol, |
getHostAddress(hostName, namespaceAccessProtocol, httpsPort, |
addr, |
portNumberHttps), commMechClass); |
commMechClass); |
|
|
instances.append(instance); | instances.append(instance); |
} | } |
|
#endif |
|
// If System::getInterfaceAddrs() fails add ip4 addr here. |
|
if (!ips.size()) |
|
{ |
|
instance = buildCIMXMLCommunicationMechanismInstance( |
|
namespaceType, |
|
namespaceAccessProtocol, |
|
getHostAddress(hostName, namespaceAccessProtocol, httpsPort), |
|
commMechClass); |
|
instances.append(instance); |
|
} |
|
} |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return instances; | return instances; |
|
|
return; | return; |
} | } |
// Modify the instance on disk | // Modify the instance on disk |
try |
|
{ |
|
repository->modifyInstance(instanceReference.getNameSpace(), | repository->modifyInstance(instanceReference.getNameSpace(), |
omInstance, false, propertyList); | omInstance, false, propertyList); |
} |
PEG_TRACE(( |
catch(const CIMException&) |
TRC_CONTROLPROVIDER, |
{ |
Tracer::LEVEL3, |
PEG_METHOD_EXIT(); |
"Interop Provider Set Statistics gathering in CIM_ObjectManager: %s", |
throw; |
(statisticsFlag? "true" : "false"))); |
} |
|
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(); |
|
|
return assocInstances; | return assocInstances; |
} | } |
| |
PEGASUS_NAMESPACE_END; |
PEGASUS_NAMESPACE_END |
| |
// END OF FILE | // END OF FILE |