version 1.2.14.1, 2006/07/27 23:12:03
|
version 1.7, 2007/06/29 17:43:11
|
|
|
// | // |
//============================================================================== | //============================================================================== |
// | // |
// Author: Yi Zhou, Hewlett-Packard Company (Yi.Zhou@hp.com) |
|
// |
|
// Modified By: |
|
// |
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#include <Pegasus/Common/PegasusAssert.h> | #include <Pegasus/Common/PegasusAssert.h> |
|
|
#include <Pegasus/Common/FileSystem.h> | #include <Pegasus/Common/FileSystem.h> |
#include <Pegasus/Common/Stopwatch.h> | #include <Pegasus/Common/Stopwatch.h> |
#include <Pegasus/Client/CIMClient.h> | #include <Pegasus/Client/CIMClient.h> |
|
#include <Pegasus/Common/HostAddress.h> |
| |
PEGASUS_USING_PEGASUS; | PEGASUS_USING_PEGASUS; |
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
| |
const CIMNamespaceName INTEROP_NAMESPACE = CIMNamespaceName ("root/PG_InterOp"); |
// Interop namespace used with PEGASUS_NAMESPACENAME_INTEROP in Constants.h |
const CIMNamespaceName SOURCE_NAMESPACE = | const CIMNamespaceName SOURCE_NAMESPACE = |
CIMNamespaceName ("root/SampleProvider"); | CIMNamespaceName ("root/SampleProvider"); |
| |
|
|
const String FILTER_NAME = String ("IPFilter01"); | const String FILTER_NAME = String ("IPFilter01"); |
| |
enum SNMPVersion {_SNMPV1_TRAP = 2, _SNMPV2C_TRAP = 3}; | enum SNMPVersion {_SNMPV1_TRAP = 2, _SNMPV2C_TRAP = 3}; |
enum TargetHostFormat {_HOST_NAME = 2, _IPV4_ADDRESS = 3}; |
enum TargetHostFormat {_HOST_NAME = 2, _IPV4_ADDRESS = 3, _IPV6_ADDRESS = 4}; |
| |
#define PORT_NUMBER 2006 | #define PORT_NUMBER 2006 |
| |
|
|
// | // |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
| |
class T_Parms{ |
class T_Parms |
|
{ |
public: | public: |
AutoPtr<CIMClient> client; | AutoPtr<CIMClient> client; |
Uint32 indicationSendCount; | Uint32 indicationSendCount; |
|
|
| |
/////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////// |
| |
CIMObjectPath _getFilterObjectPath |
CIMObjectPath _getFilterObjectPath(const String & name) |
(const String & name) |
|
{ | { |
Array<CIMKeyBinding> keyBindings; | Array<CIMKeyBinding> keyBindings; |
keyBindings.append (CIMKeyBinding ("SystemCreationClassName", | keyBindings.append (CIMKeyBinding ("SystemCreationClassName", |
|
|
PEGASUS_CLASSNAME_INDFILTER, keyBindings)); | PEGASUS_CLASSNAME_INDFILTER, keyBindings)); |
} | } |
| |
CIMObjectPath _getHandlerObjectPath |
CIMObjectPath _getHandlerObjectPath(const String & name) |
(const String & name) |
|
{ | { |
Array<CIMKeyBinding> keyBindings; | Array<CIMKeyBinding> keyBindings; |
keyBindings.append (CIMKeyBinding ("SystemCreationClassName", | keyBindings.append (CIMKeyBinding ("SystemCreationClassName", |
|
|
PEGASUS_CLASSNAME_INDHANDLER_SNMP, keyBindings)); | PEGASUS_CLASSNAME_INDHANDLER_SNMP, keyBindings)); |
} | } |
| |
CIMObjectPath _getSubscriptionObjectPath |
CIMObjectPath _getSubscriptionObjectPath( |
(const String & filterName, |
const String & filterName, |
const String & handlerName) | const String & handlerName) |
{ | { |
CIMObjectPath filterObjectPath = _getFilterObjectPath(filterName); | CIMObjectPath filterObjectPath = _getFilterObjectPath(filterName); |
|
|
PEGASUS_CLASSNAME_INDSUBSCRIPTION, subscriptionKeyBindings)); | PEGASUS_CLASSNAME_INDSUBSCRIPTION, subscriptionKeyBindings)); |
} | } |
| |
CIMObjectPath _createHandlerInstance |
CIMObjectPath _createHandlerInstance( |
(CIMClient & client, |
CIMClient & client, |
const String & name, | const String & name, |
const String & targetHost, | const String & targetHost, |
const String & securityName, | const String & securityName, |
|
|
handlerInstance.addProperty (CIMProperty (CIMName ("PortNumber"), | handlerInstance.addProperty (CIMProperty (CIMName ("PortNumber"), |
CIMValue ((Uint32) PORT_NUMBER))); | CIMValue ((Uint32) PORT_NUMBER))); |
| |
return(client.createInstance (INTEROP_NAMESPACE, handlerInstance)); |
return client.createInstance( |
|
PEGASUS_NAMESPACENAME_INTEROP, handlerInstance); |
} | } |
| |
CIMObjectPath _createFilterInstance |
CIMObjectPath _createFilterInstance( |
(CIMClient & client, |
CIMClient & client, |
const String & name, | const String & name, |
const String & query, | const String & query, |
const String & qlang) | const String & qlang) |
|
|
filterInstance.addProperty (CIMProperty (CIMName ("SourceNamespace"), | filterInstance.addProperty (CIMProperty (CIMName ("SourceNamespace"), |
SOURCE_NAMESPACE.getString ())); | SOURCE_NAMESPACE.getString ())); |
| |
return(client.createInstance (INTEROP_NAMESPACE, filterInstance)); |
return client.createInstance(PEGASUS_NAMESPACENAME_INTEROP, filterInstance); |
} | } |
| |
CIMObjectPath _createSubscriptionInstance |
CIMObjectPath _createSubscriptionInstance( |
(CIMClient & client, |
CIMClient & client, |
const CIMObjectPath & filterPath, | const CIMObjectPath & filterPath, |
const CIMObjectPath & handlerPath) | const CIMObjectPath & handlerPath) |
{ | { |
|
|
subscriptionInstance.addProperty (CIMProperty | subscriptionInstance.addProperty (CIMProperty |
(CIMName ("SubscriptionState"), CIMValue ((Uint16) 2))); | (CIMName ("SubscriptionState"), CIMValue ((Uint16) 2))); |
| |
return(client.createInstance (INTEROP_NAMESPACE, subscriptionInstance)); |
return client.createInstance( |
|
PEGASUS_NAMESPACENAME_INTEROP, subscriptionInstance); |
} | } |
| |
void _sendTestIndication(CIMClient* client, const CIMName & methodName, |
void _sendTestIndication( |
|
CIMClient* client, |
|
const CIMName & methodName, |
Uint32 indicationSendCount) | Uint32 indicationSendCount) |
{ | { |
// | // |
|
|
PEGASUS_TEST_ASSERT (result == 0); | PEGASUS_TEST_ASSERT (result == 0); |
} | } |
| |
void _deleteSubscriptionInstance |
void _deleteSubscriptionInstance( |
(CIMClient & client, |
CIMClient & client, |
const String & filterName, | const String & filterName, |
const String & handlerName) | const String & handlerName) |
{ | { |
CIMObjectPath subscriptionObjectPath = | CIMObjectPath subscriptionObjectPath = |
_getSubscriptionObjectPath(filterName, handlerName); | _getSubscriptionObjectPath(filterName, handlerName); |
client.deleteInstance (INTEROP_NAMESPACE, subscriptionObjectPath); |
client.deleteInstance( |
|
PEGASUS_NAMESPACENAME_INTEROP, subscriptionObjectPath); |
} | } |
| |
void _deleteHandlerInstance |
void _deleteHandlerInstance( |
(CIMClient & client, |
CIMClient & client, |
const String & name) | const String & name) |
{ | { |
CIMObjectPath handlerObjectPath = _getHandlerObjectPath(name); | CIMObjectPath handlerObjectPath = _getHandlerObjectPath(name); |
client.deleteInstance (INTEROP_NAMESPACE, handlerObjectPath); |
client.deleteInstance (PEGASUS_NAMESPACENAME_INTEROP, handlerObjectPath); |
} | } |
| |
void _deleteFilterInstance |
void _deleteFilterInstance( |
(CIMClient & client, |
CIMClient & client, |
const String & name) | const String & name) |
{ | { |
CIMObjectPath filterObjectPath = _getFilterObjectPath(name); | CIMObjectPath filterObjectPath = _getFilterObjectPath(name); |
client.deleteInstance (INTEROP_NAMESPACE, filterObjectPath); |
client.deleteInstance (PEGASUS_NAMESPACENAME_INTEROP, filterObjectPath); |
} | } |
| |
void _usage () | void _usage () |
|
|
| |
try | try |
{ | { |
|
String ipAddress; |
|
int af; |
|
System::getHostIP(System::getFullyQualifiedHostName (), &af, ipAddress); |
// Create SNMPv2 trap handler | // Create SNMPv2 trap handler |
snmpv2HandlerObjectPath = _createHandlerInstance (client, | snmpv2HandlerObjectPath = _createHandlerInstance (client, |
SNMPV2C_HANDLER_NAME, | SNMPV2C_HANDLER_NAME, |
System::getHostIP(System::getFullyQualifiedHostName ()), |
ipAddress, |
"public", | "public", |
_IPV4_ADDRESS, |
af == AF_INET ? _IPV4_ADDRESS : _IPV6_ADDRESS, |
_SNMPV2C_TRAP); | _SNMPV2C_TRAP); |
} | } |
catch (CIMException& e) | catch (CIMException& e) |
|
|
} | } |
catch (Exception & e) | catch (Exception & e) |
{ | { |
cerr << "----- sendTestIndication failed: " << e.getMessage () << endl; |
cerr << "----- sendTestIndication failed: " << e.getMessage () << |
|
endl; |
exit (-1); | exit (-1); |
} | } |
elapsedTime.stop(); | elapsedTime.stop(); |
|
|
| |
Uint32 iterations = 0; | Uint32 iterations = 0; |
| |
// Wait until snmptrapd startted |
// Wait until snmptrapd started |
while (iterations < MAX_ITERATIONS) | while (iterations < MAX_ITERATIONS) |
{ | { |
iterations++; | iterations++; |
|
|
} | } |
} | } |
| |
void _receiveExpectedTraps(CIMClient& workClient, |
void _receiveExpectedTraps( |
|
CIMClient& workClient, |
Uint32 indicationSendCount, | Uint32 indicationSendCount, |
Uint32 runClientThreadCount) | Uint32 runClientThreadCount) |
{ | { |
|
|
CIMClient * clientConnections = new CIMClient[runClientThreadCount]; | CIMClient * clientConnections = new CIMClient[runClientThreadCount]; |
| |
// determine total number of indication send count | // determine total number of indication send count |
|
|
| |
#define MSG_PER_SEC 4 | #define MSG_PER_SEC 4 |
| |
Uint32 testTimeout = 20000+(indicationSendCountTotal/MSG_PER_SEC)*1000; |
Uint32 testTimeout = PEGASUS_DEFAULT_CLIENT_TIMEOUT_MILLISECONDS |
|
+ (indicationSendCountTotal/MSG_PER_SEC)*1000; |
| |
// connect the clients | // connect the clients |
for(Uint32 i = 0; i < runClientThreadCount; i++) | for(Uint32 i = 0; i < runClientThreadCount; i++) |