summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorkarl <karl>2005-08-07 18:19:51 +0000
committerkarl <karl>2005-08-07 18:19:51 +0000
commitcab213422b9ce9b006d197f475b39d49b6f4fc1b (patch)
treec9423c0082aa5aad94b5d7b4cf36348495427e94 /src
parenta553a103af97b85a74c57d9f4ce0865ee303d816 (diff)
downloadtog-pegasus-cab213422b9ce9b006d197f475b39d49b6f4fc1b.zip
tog-pegasus-cab213422b9ce9b006d197f475b39d49b6f4fc1b.tar.gz
tog-pegasus-cab213422b9ce9b006d197f475b39d49b6f4fc1b.tar.xz
BUG#: 1857
TITLE: Error SLP in acquiring http/http port numberrs DESCRIPTION: Error was in InterpProvider. Corrected by matching CIMServer algorithm for getting port number.
Diffstat (limited to 'src')
-rw-r--r--src/Pegasus/ControlProviders/InteropProvider/InteropProvider.cpp71
-rw-r--r--src/Pegasus/ControlProviders/InteropProvider/tests/interop.cpp210
2 files changed, 239 insertions, 42 deletions
diff --git a/src/Pegasus/ControlProviders/InteropProvider/InteropProvider.cpp b/src/Pegasus/ControlProviders/InteropProvider/InteropProvider.cpp
index 6f3bfda..87073cd 100644
--- a/src/Pegasus/ControlProviders/InteropProvider/InteropProvider.cpp
+++ b/src/Pegasus/ControlProviders/InteropProvider/InteropProvider.cpp
@@ -84,7 +84,7 @@
3. Review the key parameters on create, etc. to be sort out which are
required from user and which we can supply. I think we are asking too
much of the user right now.
- 4. Review deletion of _buildObjectPath, _reference, etc.
+
*/
#include <Pegasus/Common/Config.h>
@@ -445,16 +445,23 @@ Boolean _getPropertyValue(const CIMInstance& instance, const CIMName& propertyNa
If everything fails, gets the definition normally
used for localhost (127.0.0.1).
- @param hostName String with the name of the host
+ @param hostName String with the name of the host. Allows
+ String:EMPTY and in that case, gets it directly from system.
@param namespaceType - Uint32 representing the
access protocol for this request. This is exactly
the definition in the PG_CIMXMLCommunicationMechanism
mof for the property namespaceAccessProtocol.
+ @param port String defining the port to be used. If
+ String::EMPTY, it is not valid and the defaultPortNumber
+ is to be inserted.
+ @param defaultPortNumber Uint32 defining a default port
+ number to be used if port string is not provided.
@return String with the IP address to be used. This must
be the complete address sufficient to access the
IP address. Therefore, it includes the port number.
*/
-String _getHostAddress(String & hostName, Uint32 namespaceType)
+String _getHostAddress(String & hostName, Uint32 namespaceType,
+ const String & port, const Uint32 defaultPortNumber)
{
String ipAddress;
@@ -468,36 +475,20 @@ String _getHostAddress(String & hostName, Uint32 namespaceType)
}
// Question: is there a case where we leave off the port number.
// Code to get the property service_location_tcp ( which is equivalent to "IP address:5988")
- // Need to tie these two together.
- Uint32 portNumber;
-
- /********************** Drop this
- ConfigManager* configManager = ConfigManager::getInstance();
- Boolean enableHttpConnection = String::equal(
- configManager->getCurrentValue("enableHttpConnection"), "true");
- Boolean enableHttpsConnection = String::equal(
- configManager->getCurrentValue("enableHttpsConnection"), "true");
- ***********************/
-
- // ATTN: The following is incorrect and must be modified as part
- // of bug 1857 and possibly other bug reports. KS. This is 2.5 mustfix.
-
- // Match the protocol and port number from internal information.
- if (namespaceType == 3)
- portNumber = System::lookupPort(WBEM_HTTPS_SERVICE_NAME,
- WBEM_DEFAULT_HTTPS_PORT);
- else if (namespaceType == 2)
+
+ // if port is valid port number, we use it. Else use
+ // the default portnumber provided.
+ // One or the other MUST not be zero.
+ ipAddress.append(":");
+ if (port == String::EMPTY)
{
- portNumber = System::lookupPort(WBEM_HTTP_SERVICE_NAME,
- WBEM_DEFAULT_HTTP_PORT);
+ // convert portNumber to ascii
+ char buffer[32];
+ sprintf(buffer, "%u", defaultPortNumber);
+ ipAddress.append(buffer);
}
else
- portNumber = 0;
- // convert portNumber to ascii
- char buffer[32];
- sprintf(buffer, ":%u", portNumber);
- if (portNumber != 0)
- ipAddress.append(buffer);
+ ipAddress.append(port);
// now fillout the serviceIDAttribute from the object manager instance name property.
// This is a key field so must have a value.
@@ -1010,10 +1001,6 @@ Array<CIMInstance> InteropProvider::_buildInstancesPGCIMXMLCommunicationMechanis
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
"InteropProvider::_buildInstancesPGCIMXMLCommunicationMechanism");
- // This is a temporary hack to get the multiple connections.
- // This is based on the configmanager being the source of what
- // protocols are available, http and https.
-
ConfigManager* configManager = ConfigManager::getInstance();
Boolean enableHttpConnection = String::equal(
configManager->getCurrentValue("enableHttpConnection"), "true");
@@ -1030,12 +1017,18 @@ Array<CIMInstance> InteropProvider::_buildInstancesPGCIMXMLCommunicationMechanis
{
namespaceAccessProtocol = 2;
namespaceType = "http";
+ Uint32 portNumberHttp;
+ String httpPort = configManager->getCurrentValue("httpPort");
+ if (httpPort == String::EMPTY)
+ {
+ portNumberHttp = System::lookupPort(WBEM_HTTP_SERVICE_NAME, WBEM_DEFAULT_HTTP_PORT);
+ }
CIMInstance instance =
_buildInstancePGCIMXMLCommunicationMechanism(
objectPath,
namespaceType,
namespaceAccessProtocol,
- _getHostAddress(hostName, namespaceAccessProtocol));
+ _getHostAddress(hostName, namespaceAccessProtocol, httpPort, portNumberHttp));
instances.append(instance);
}
@@ -1043,12 +1036,18 @@ Array<CIMInstance> InteropProvider::_buildInstancesPGCIMXMLCommunicationMechanis
{
namespaceAccessProtocol = 3;
namespaceType = "https";
+ Uint32 portNumberHttps;
+ String httpsPort = configManager->getCurrentValue("httpsPort");
+ if (httpsPort == String::EMPTY)
+ {
+ portNumberHttps = System::lookupPort(WBEM_HTTPS_SERVICE_NAME, WBEM_DEFAULT_HTTPS_PORT);
+ }
CIMInstance instance =
_buildInstancePGCIMXMLCommunicationMechanism(
objectPath,
namespaceType,
namespaceAccessProtocol,
- _getHostAddress(hostName, namespaceAccessProtocol));
+ _getHostAddress(hostName, namespaceAccessProtocol, httpsPort, portNumberHttps));
instances.append(instance);
}
diff --git a/src/Pegasus/ControlProviders/InteropProvider/tests/interop.cpp b/src/Pegasus/ControlProviders/InteropProvider/tests/interop.cpp
index e23ed52..0221553 100644
--- a/src/Pegasus/ControlProviders/InteropProvider/tests/interop.cpp
+++ b/src/Pegasus/ControlProviders/InteropProvider/tests/interop.cpp
@@ -241,7 +241,16 @@ public:
void setStatisticsState(const Boolean flag);
Boolean getStatisticsPropertyState(
- CIMInstance & objMgrInstance);
+ CIMInstance & objMgrInstance);
+
+ String getCurrentConfigProperty(
+ const CIMName& propName);
+
+ Boolean getCurrentBoolConfigProperty(
+ const CIMName& propName);
+
+ Uint32 getCurrentValueConfigProperty(
+ const CIMName& propName);
Boolean getStatisticsState();
@@ -283,7 +292,96 @@ private:
CIMClient _client;
CIMInstance objectManagerInstance;
};
+/**
+ Get property values for the specified configuration property from
+ the CIM Server.
+*/
+
+static const CIMName PROPERTY_NAME = CIMName ("PropertyName");
+
+String InteropTest::getCurrentConfigProperty(
+ const CIMName& propertyName)
+{
+ // The following assumes localconnect.
+ String _hostName;
+ _hostName.assign(System::getHostName());
+
+ CIMProperty prop;
+ Array<CIMKeyBinding> kbArray;
+ CIMKeyBinding kb;
+
+ kb.setName(PROPERTY_NAME);
+ kb.setValue(propertyName.getString());
+ kb.setType(CIMKeyBinding::STRING);
+
+ kbArray.append(kb);
+
+ String propertyNameValue;
+ String currentValue;
+ //String defaultValue;
+ //String plannedValue;
+ try
+ {
+ CIMObjectPath reference(
+ _hostName, PEGASUS_NAMESPACENAME_CONFIG,
+ PEGASUS_CLASSNAME_CONFIGSETTING, kbArray);
+
+ CIMInstance cimInstance =
+ _client.getInstance(PEGASUS_NAMESPACENAME_CONFIG, reference);
+
+ Uint32 pos = cimInstance.findProperty(PROPERTY_NAME);
+ prop = (CIMProperty)cimInstance.getProperty(pos);
+ propertyNameValue = prop.getValue().toString();
+
+ pos = cimInstance.findProperty(CIMName ("CurrentValue"));
+ prop = (CIMProperty)cimInstance.getProperty(pos);
+ currentValue = prop.getValue().toString();
+
+ //pos = cimInstance.findProperty(CIMName ("DefaultValue"));
+ //prop = (CIMProperty)cimInstance.getProperty(pos);
+ //defaultValue = prop.getValue().toString();
+
+ //pos = cimInstance.findProperty(CIMName ("PlannedValue"));
+ //prop = (CIMProperty)cimInstance.getProperty(pos);
+ //plannedValue = prop.getValue().toString();
+
+ if (verbose)
+ {
+ cout << " Config return: "
+ << " Requested Name: " << propertyName.getString()
+ << " Returned Name: " << propertyNameValue
+ //<< " Default: " << defaultValue
+ //<< " planned: " << plannedValue
+ << " current: " << currentValue << endl;
+ }
+ }
+ catch(const CIMException& e)
+ {
+ cout << "CIM Exception during get Config " << e.getMessage() << endl;
+ return(String::EMPTY);
+ }
+
+ return (currentValue);
+}
+Boolean InteropTest::getCurrentBoolConfigProperty(
+ const CIMName& propName)
+{
+ return (getCurrentConfigProperty(propName) == "true")?
+ true : false;
+}
+
+Uint32 InteropTest::getCurrentValueConfigProperty(
+ const CIMName& propName)
+{
+ String strValue = getCurrentConfigProperty(propName);
+
+ long longValue;
+ if (!sscanf(strValue.getCString(), "%ld", &longValue))
+ return 0;
+
+ return (Uint32)longValue;
+}
/** Test a single class to assure that the returned reference
names from an enumerateInstanceNames and the paths in
the instances match. Then get all classes and test against
@@ -2148,6 +2246,7 @@ void InteropTest::testCommunicationClass()
assert (instancesCommMech[i].findProperty("CreationClassName") != PEG_NOT_FOUND);
assert (instancesCommMech[i].findProperty("Name") != PEG_NOT_FOUND);
assert (instancesCommMech[i].findProperty("SystemCreationClassName") != PEG_NOT_FOUND);
+ assert (instancesCommMech[i].findProperty("FunctionalProfilesSupported") != PEG_NOT_FOUND);
assert (instancesCommMech[i].findProperty("FunctionalProfileDescriptions") != PEG_NOT_FOUND);
assert (instancesCommMech[i].findProperty("MultipleOperationsSupported") != PEG_NOT_FOUND);
assert (instancesCommMech[i].findProperty("AuthenticationMechanismsSupported") != PEG_NOT_FOUND);
@@ -2160,8 +2259,8 @@ void InteropTest::testCommunicationClass()
assert (instancePath.getClassName() == PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME );
}
+ // Repeat with deepInheritance = true.
deepInheritance = true;
- // Repeat with deepInheritance = true.
instancesCommMech = _client.enumerateInstances(
PEGASUS_NAMESPACENAME_INTEROP,
CIM_OBJECTMANAGERCOMMUNICATIONMECHANISM_CLASSNAME,
@@ -2183,6 +2282,8 @@ void InteropTest::testCommunicationClass()
assert(instancesCommMech.size() > 0);
#endif
+ // Test the properties in each comm mechanism instance. This tests for existence and
+ // correct information as much as possible.
for (Uint32 i = 0 ; i < instancesCommMech.size() ; i++)
{
assert (instancesCommMech[i].findProperty("SystemCreationClassName") != PEG_NOT_FOUND);
@@ -2190,9 +2291,69 @@ void InteropTest::testCommunicationClass()
assert (instancesCommMech[i].findProperty("CreationClassName") != PEG_NOT_FOUND);
assert (instancesCommMech[i].findProperty("Name") != PEG_NOT_FOUND);
assert (instancesCommMech[i].findProperty("SystemCreationClassName") != PEG_NOT_FOUND);
+ assert (instancesCommMech[i].findProperty("FunctionalProfilesSupported") != PEG_NOT_FOUND);
assert (instancesCommMech[i].findProperty("FunctionalProfileDescriptions") != PEG_NOT_FOUND);
+
+ // testing of characteristics of FunctionalProfile properties
+ {
+ // get and test FunctionalProfileDescriptions property to determine if correct.
+ Uint32 pos = instancesCommMech[i].findProperty("FunctionalProfilesSupported");
+ CIMProperty p = instancesCommMech[i].getProperty(pos);
+ CIMValue v1 = p.getValue();
+ Array<Uint16> functionalProfile;
+ v1.get(functionalProfile);
+
+ // Build an array of entries to test against
+ Array<Uint16> testFunctionalProfile;
+ testFunctionalProfile.append(2);
+ testFunctionalProfile.append(3);
+ testFunctionalProfile.append(4);
+ testFunctionalProfile.append(5);
+ // Optional profile based on config param "enableAssociationTraversal"
+ if (getCurrentBoolConfigProperty("enableAssociationTraversal"))
+ testFunctionalProfile.append(6);
+
+ // ExecQuery capability is a compile option.
+#ifndef PEGASUS_DISABLE_EXECQUERY
+ testFunctionalProfile.append(7);
+#endif
+ testFunctionalProfile.append(8);
+
+ // enableIndicationService is a config option
+ if (getCurrentBoolConfigProperty("enableIndicationService"))
+ testFunctionalProfile.append(9);
+
+ assert(testFunctionalProfile.size() == functionalProfile.size());
+
+ // clone so we can sort to do an identical test on the array.
+ Array<Uint16> fpTemp;
+ v1.get(fpTemp);
+ BubbleSort(fpTemp);
+ BubbleSort(testFunctionalProfile);
+
+ assert(fpTemp == testFunctionalProfile);
+
+ // get the functionalProfileDescription to test against profile property.
+ pos = instancesCommMech[i].findProperty("FunctionalProfileDescriptions");
+ p = instancesCommMech[i].getProperty(pos);
+ v1 = p.getValue();
+
+ Array<String> functionalProfileDescription;
+ v1.get(functionalProfileDescription);
+
+ // assert that we have same number descriptions as profiles
+ assert(functionalProfileDescription.size() == functionalProfile.size());
+ // NOTE: We do not test for correct strings.
+ if (verbose)
+ for (Uint32 i = 0 ; i < functionalProfile.size() ; i++)
+ cout << functionalProfile[i] << " " <<
+ functionalProfileDescription[i] << endl;
+ }
+
assert (instancesCommMech[i].findProperty("MultipleOperationsSupported") != PEG_NOT_FOUND);
assert (instancesCommMech[i].findProperty("AuthenticationMechanismsSupported") != PEG_NOT_FOUND);
+
+ // The following tests are only for PG_CIMXML... Instances
if (instancesCommMech[i].getClassName() == PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME)
{
Uint32 pos;
@@ -2201,10 +2362,10 @@ void InteropTest::testCommunicationClass()
assert ((pos = instancesCommMech[i].findProperty("IPAddress")) != PEG_NOT_FOUND);
CIMProperty p = instancesCommMech[i].getProperty(pos);
CIMValue v1 = p.getValue();
- String getIPAddress;
- v1.get(getIPAddress);
+ String IPAddress;
+ v1.get(IPAddress);
// test to assure that the port number ss part of the value
- assert(getIPAddress.find(':'));
+ assert(IPAddress.find(':'));
// test namespaceAccessProtocol property to determine if correct
assert ((pos = instancesCommMech[i].findProperty("namespaceAccessProtocol")) != PEG_NOT_FOUND);
@@ -2213,6 +2374,7 @@ void InteropTest::testCommunicationClass()
CIMValue v2 = p.getValue();
Uint16 accessProtocolValue;
v2.get(accessProtocolValue);
+
// test to assure that this is a 2 or 3 (http or https)
assert(accessProtocolValue == 2 || accessProtocolValue == 3);
@@ -2228,7 +2390,43 @@ void InteropTest::testCommunicationClass()
if (accessProtocolValue ==3)
assert(namespaceTypeValue == "https");
- // TBD Test agains the valuemap. KS may 05
+ if (accessProtocolValue == 2)
+ {
+ // Test the received IP address. We do this by
+ // connecting to the cim server and then
+ // disconnecting.
+ CIMClient testClient;
+ Uint32 ipAddressBreak = IPAddress.find(':');
+ Uint32 portNumber = 5988;
+ String ipaddress = IPAddress.subString(0,ipAddressBreak);
+ String portString = IPAddress.subString((ipAddressBreak + 1),
+ (IPAddress.size() - ipAddressBreak));
+
+ char* end = 0;
+ CString portCString = portString.getCString();
+ portNumber = strtol(portCString, &end, 10);
+ if(!(end != 0 && *end == '\0'))
+ {
+ TERMINATE("Invalid http port value in CIMXML Comm object " + portString);
+ }
+
+ // Try to connect to the server.
+ try{
+ testClient.connect(ipaddress, portNumber, String::EMPTY, String::EMPTY);
+ testClient.disconnect();
+ }
+
+ catch(CIMException& e)
+ {
+ TERMINATE(" Cim Exception Error Comm class IP Address: " << IPAddress << " " << e.getMessage());
+ }
+ catch(Exception& e)
+ {
+ TERMINATE("Exception Error Comm class IP Address: " << IPAddress << " " << e.getMessage());
+ }
+ }
+
+ // ATTN: TODO Test against the valuemap. KS may 05
}
}
}