📄 subscription.cpp
字号:
_addStringProperty (filter05, "QueryLanguage", qlang); _addStringProperty (filter05, "SourceNamespace", SOURCENAMESPACE.getString ()); path = client.createInstance (PEGASUS_NAMESPACENAME_INTEROP, filter05); _checkFilterOrHandlerPath (path, PEGASUS_CLASSNAME_INDFILTER, "Filter05"); retrievedInstance = client.getInstance (PEGASUS_NAMESPACENAME_INTEROP, path); _checkStringProperty (retrievedInstance, "SystemCreationClassName", System::getSystemCreationClassName ()); _checkStringProperty (retrievedInstance, "SystemName", System::getFullyQualifiedHostName ()); _checkStringProperty (retrievedInstance, "CreationClassName", PEGASUS_CLASSNAME_INDFILTER.getString ()); _checkStringProperty (retrievedInstance, "Name", "Filter05"); _checkStringProperty (retrievedInstance, "SourceNamespace", SOURCENAMESPACE.getString ()); _checkStringProperty (retrievedInstance, "Query", query); _checkStringProperty (retrievedInstance, "QueryLanguage", qlang); // // Create filter that selects all properties from CIM_AlertIndication // and has a where clause condition // CIMInstance filter06 (PEGASUS_CLASSNAME_INDFILTER); query = "SELECT * FROM CIM_AlertIndication WHERE AlertType = 5"; _addStringProperty (filter06, "Name", "Filter06"); _addStringProperty (filter06, "Query", query); _addStringProperty (filter06, "QueryLanguage", qlang); _addStringProperty (filter06, "SourceNamespace", SOURCENAMESPACE.getString ()); path = client.createInstance (PEGASUS_NAMESPACENAME_INTEROP, filter06); _checkFilterOrHandlerPath (path, PEGASUS_CLASSNAME_INDFILTER, "Filter06"); retrievedInstance = client.getInstance (PEGASUS_NAMESPACENAME_INTEROP, path); _checkStringProperty (retrievedInstance, "SystemCreationClassName", System::getSystemCreationClassName ()); _checkStringProperty (retrievedInstance, "SystemName", System::getFullyQualifiedHostName ()); _checkStringProperty (retrievedInstance, "CreationClassName", PEGASUS_CLASSNAME_INDFILTER.getString ()); _checkStringProperty (retrievedInstance, "Name", "Filter06"); _checkStringProperty (retrievedInstance, "SourceNamespace", SOURCENAMESPACE.getString ()); _checkStringProperty (retrievedInstance, "Query", query); _checkStringProperty (retrievedInstance, "QueryLanguage", qlang); // // Create persistent CIMXML handler // CIMInstance handler01 (PEGASUS_CLASSNAME_INDHANDLER_CIMXML); _addStringProperty (handler01, "SystemCreationClassName", System::getSystemCreationClassName ()); _addStringProperty (handler01, "SystemName", System::getFullyQualifiedHostName ()); _addStringProperty (handler01, "CreationClassName", PEGASUS_CLASSNAME_INDHANDLER_CIMXML.getString ()); _addStringProperty (handler01, "Name", "Handler01"); _addStringProperty (handler01, "Owner", "an owner"); _addUint16Property (handler01, "PersistenceType", 2); _addStringProperty (handler01, "OtherPersistenceType", String::EMPTY, true); _addStringProperty (handler01, "Destination", "localhost/CIMListener/test1"); path = client.createInstance (PEGASUS_NAMESPACENAME_INTEROP, handler01); _checkFilterOrHandlerPath (path, PEGASUS_CLASSNAME_INDHANDLER_CIMXML, "Handler01"); retrievedInstance = client.getInstance (PEGASUS_NAMESPACENAME_INTEROP, path); _checkStringProperty (retrievedInstance, "SystemCreationClassName", System::getSystemCreationClassName ()); _checkStringProperty (retrievedInstance, "SystemName", System::getFullyQualifiedHostName ()); _checkStringProperty (retrievedInstance, "CreationClassName", PEGASUS_CLASSNAME_INDHANDLER_CIMXML.getString ()); _checkStringProperty (retrievedInstance, "Name", "Handler01"); _checkStringProperty (retrievedInstance, "Owner", "an owner"); _checkUint16Property (retrievedInstance, "PersistenceType", 2); _checkStringProperty (retrievedInstance, "OtherPersistenceType", String::EMPTY, true); _checkStringProperty (retrievedInstance, "Destination", "localhost/CIMListener/test1"); // // Enumerate handlers // instances = client.enumerateInstances (PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_INDHANDLER_CIMXML); PEGASUS_TEST_ASSERT (instances.size () == 1); _checkStringProperty (instances [0], "SystemCreationClassName", System::getSystemCreationClassName ()); _checkStringProperty (instances [0], "SystemName", System::getFullyQualifiedHostName ()); _checkStringProperty (instances [0], "CreationClassName", PEGASUS_CLASSNAME_INDHANDLER_CIMXML.getString ()); _checkStringProperty (instances [0], "Name", "Handler01"); _checkStringProperty (instances [0], "Owner", "an owner"); _checkUint16Property (instances [0], "PersistenceType", 2); _checkStringProperty (instances [0], "OtherPersistenceType", String::EMPTY, true); _checkStringProperty (instances [0], "Destination", "localhost/CIMListener/test1"); // // Create transient CIMXML handler // CIMInstance handler02 (PEGASUS_CLASSNAME_INDHANDLER_CIMXML); _addStringProperty (handler02, "Name", "Handler02"); _addUint16Property (handler02, "PersistenceType", 3); _addStringProperty (handler02, "Destination", "localhost/CIMListener/test2"); path = client.createInstance (PEGASUS_NAMESPACENAME_INTEROP, handler02); _checkFilterOrHandlerPath (path, PEGASUS_CLASSNAME_INDHANDLER_CIMXML, "Handler02"); retrievedInstance = client.getInstance (PEGASUS_NAMESPACENAME_INTEROP, path); _checkStringProperty (retrievedInstance, "SystemCreationClassName", System::getSystemCreationClassName ()); _checkStringProperty (retrievedInstance, "SystemName", System::getFullyQualifiedHostName ()); _checkStringProperty (retrievedInstance, "CreationClassName", PEGASUS_CLASSNAME_INDHANDLER_CIMXML.getString ()); _checkStringProperty (retrievedInstance, "Name", "Handler02"); _checkUint16Property (retrievedInstance, "PersistenceType", 3); _checkStringProperty (retrievedInstance, "Destination", "localhost/CIMListener/test2"); // // Create persistent SNMP handler // CIMInstance handler03 (PEGASUS_CLASSNAME_INDHANDLER_SNMP); _addStringProperty (handler03, "SystemCreationClassName", System::getSystemCreationClassName ()); _addStringProperty (handler03, "SystemName", System::getFullyQualifiedHostName ()); _addStringProperty (handler03, "CreationClassName", PEGASUS_CLASSNAME_INDHANDLER_SNMP.getString ()); _addStringProperty (handler03, "Name", "Handler03"); _addStringProperty (handler03, "Owner", "an owner"); _addUint16Property (handler03, "PersistenceType", 2); _addStringProperty (handler03, "OtherPersistenceType", String::EMPTY, true); _addStringProperty (handler03, "TargetHost", "localhost"); _addUint16Property (handler03, "TargetHostFormat", 2); _addUint32Property (handler03, "PortNumber", 162); _addUint16Property (handler03, "SNMPVersion", 3); _addStringProperty (handler03, "SNMPSecurityName", "a name"); _addStringProperty (handler03, "SNMPEngineID", "an ID"); path = client.createInstance (PEGASUS_NAMESPACENAME_INTEROP, handler03); _checkFilterOrHandlerPath (path, PEGASUS_CLASSNAME_INDHANDLER_SNMP, "Handler03"); retrievedInstance = client.getInstance (PEGASUS_NAMESPACENAME_INTEROP, path); _checkStringProperty (retrievedInstance, "SystemCreationClassName", System::getSystemCreationClassName ()); _checkStringProperty (retrievedInstance, "SystemName", System::getFullyQualifiedHostName ()); _checkStringProperty (retrievedInstance, "CreationClassName", PEGASUS_CLASSNAME_INDHANDLER_SNMP.getString ()); _checkStringProperty (retrievedInstance, "Name", "Handler03"); _checkStringProperty (retrievedInstance, "Owner", "an owner"); _checkUint16Property (retrievedInstance, "PersistenceType", 2); _checkStringProperty (retrievedInstance, "OtherPersistenceType", String::EMPTY, true); _checkStringProperty (retrievedInstance, "TargetHost", "localhost"); _checkUint16Property (retrievedInstance, "TargetHostFormat", 2); _checkUint32Property (retrievedInstance, "PortNumber", 162); _checkUint16Property (retrievedInstance, "SNMPVersion", 3); _checkStringProperty (retrievedInstance, "SNMPSecurityName", "a name"); _checkStringProperty (retrievedInstance, "SNMPEngineID", "an ID"); // // Enumerate handlers // instances = client.enumerateInstances (PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_INDHANDLER_SNMP); PEGASUS_TEST_ASSERT (instances.size () == 1); _checkStringProperty (instances [0], "SystemCreationClassName", System::getSystemCreationClassName ()); _checkStringProperty (instances [0], "SystemName", System::getFullyQualifiedHostName ()); _checkStringProperty (instances [0], "CreationClassName", PEGASUS_CLASSNAME_INDHANDLER_SNMP.getString ()); _checkStringProperty (instances [0], "Name", "Handler03"); _checkStringProperty (instances [0], "Owner", "an owner"); _checkUint16Property (instances [0], "PersistenceType", 2); _checkStringProperty (instances [0], "OtherPersistenceType", String::EMPTY, true); _checkStringProperty (instances [0], "TargetHost", "localhost"); _checkUint16Property (instances [0], "TargetHostFormat", 2); _checkUint32Property (instances [0], "PortNumber", 162); _checkUint16Property (instances [0], "SNMPVersion", 3); _checkStringProperty (instances [0], "SNMPSecurityName", "a name"); _checkStringProperty (instances [0], "SNMPEngineID", "an ID"); // // Create persistent CIMXML listener destination // CIMInstance listenerdestination01 (PEGASUS_CLASSNAME_LSTNRDST_CIMXML); _addStringProperty (listenerdestination01, "SystemCreationClassName", System::getSystemCreationClassName ()); _addStringProperty (listenerdestination01, "SystemName", System::getFullyQualifiedHostName ()); _addStringProperty (listenerdestination01, "CreationClassName", PEGASUS_CLASSNAME_LSTNRDST_CIMXML.getString ()); _addStringProperty (listenerdestination01, "Name", "ListenerDestination01"); _addUint16Property (listenerdestination01, "PersistenceType", 2); _addStringProperty (listenerdestination01, "OtherPersistenceType", String::EMPTY, true); _addStringProperty (listenerdestination01, "Destination", "localhost/CIMListener/test3"); path = client.createInstance (PEGASUS_NAMESPACENAME_INTEROP, listenerdestination01); _checkFilterOrHandlerPath (path, PEGASUS_CLASSNAME_LSTNRDST_CIMXML, "ListenerDestination01"); retrievedInstance = client.getInstance (PEGASUS_NAMESPACENAME_INTEROP, path); _checkStringProperty (retrievedInstance, "SystemCreationClassName", System::getSystemCreationClassName ()); _checkStringProperty (retrievedInstance, "SystemName", System::getFullyQualifiedHostName ()); _checkStringProperty (retrievedInstance, "CreationClassName", PEGASUS_CLASSNAME_LSTNRDST_CIMXML.getString ()); _checkStringProperty (retrievedInstance, "Name", "ListenerDestination01"); _checkUint16Property (retrievedInstance, "PersistenceType", 2); _checkStringProperty (retrievedInstance, "OtherPersistenceType", String::EMPTY, true); _checkStringProperty (retrievedInstance, "Destination", "localhost/CIMListener/test3"); // // Enumerate listener destinations // instances = client.enumerateInstances (PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_LSTNRDST_CIMXML); PEGASUS_TEST_ASSERT (instances.size () == 1); _checkStringProperty (instances [0], "SystemCreationClassName", System::getSystemCreationClassName ()); _checkStringProperty (instances [0], "SystemName", System::getFullyQualifiedHostName ()); _checkStringProperty (instances [0], "CreationClassName", PEGASUS_CLASSNAME_LSTNRDST_CIMXML.getString ()); _checkStringProperty (instances [0], "Name", "ListenerDestination01"); _checkUint16Property (instances [0], "PersistenceType", 2); _checkStringProperty (instances [0], "OtherPersistenceType", String::EMPTY, true); _checkStringProperty (instances [0], "Destination", "localhost/CIMListener/test3"); // // Create subscriptions // CIMInstance subscription01 = _buildSubscriptionInstance (_buildFilterOrHandlerPath (PEGASUS_CLASSNAME_INDFILTER, "Filter01"), PEGASUS_CLASSNAME_INDHANDLER_CIMXML, _buildFilterOrHandlerPath (PEGASUS_CLASSNAME_INDHANDLER_CIMXML, "Handler01")); _addUint16Property (subscription01, "OnFatalErrorPolicy", 2); _addStringProperty (subscription01, "OtherOnFatalErrorPolicy", String::EMPTY, true); _addUint64Property (subscription01, "FailureTriggerTimeInterval", 60); _addUint16Property (subscription01, "SubscriptionState", 2); _addStringProperty (subscription01, "OtherSubscriptionState", String::EMPTY, true); _addUint64Property (subscription01, "SubscriptionDuration", PEGASUS_UINT64_LITERAL(60000000000)); _addUint16Property (subscription01, "RepeatNotificationPolicy", 1); _addStringProperty (subscription01, "OtherRepeatNotificationPolicy", "another policy"); _addUint64Property (subscription01, "RepeatNotificationInterval", 60); _addUint64Property (subscription01, "RepeatNotificationGap", 30); _addUint16Property (subscription01, "RepeatNotificationCount", 5); path = client.createInstance (PEGASUS_NAMESPACENAME_INTEROP, subscription01); _checkSubscriptionPath (path, "Filter01", PEGASUS_CLASSNAME_INDHANDLER_CIMXML, "Handler01"); retrievedInstance = client.getInstance (PEGASUS_NAMESPACENAME_INTEROP, path); _checkUint16Property (retrievedInstance, "OnFatalErrorPolicy", 2); _checkStringProperty (retrievedInstance, "OtherOnFatalErrorPolicy", String::EMPTY, true); _checkUint64Property (retrievedInstance, "FailureTriggerTimeInterval", 60); _checkUint16Property (retrievedInstance, "SubscriptionState", 2); _checkStringProperty (retrievedInstance, "OtherSubscriptionState", String::EMPTY, true); _checkUint64Property (retrievedInstance, "SubscriptionDuration", PEGASUS_UINT64_LITERAL(60000000000)); _checkUint16Property (retrievedInstance, "RepeatNotificationPolicy", 1); _checkStringProperty (retrievedInstance, "OtherRepeatNotificationPolicy", "another policy"); _checkUint64Property (retrievedInstance, "RepeatNotificationInterval", 60); _checkUint64Property (retrievedInstance, "RepeatNotificationGap", 30); _checkUint16Property (retrievedInstance, "RepeatNotificationCount", 5); // // Enumerate subscriptions // instances = client.enumerateInstances (PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_INDSUBSCRIPTION); PEGASUS_TEST_ASSERT (instances.size () == 1); _checkUint16Property (instances [0], "OnFatalErrorPolicy", 2); _checkStringProperty (instances [0], "OtherOnFatalErrorPolicy", String::EMPTY, true); _checkUint64Property (instances [0], "FailureTriggerTimeInterval", 60); _checkUint16Property (instances [0], "SubscriptionState", 2); _checkStringProperty (instances [0], "OtherSubscriptionState", String::EMPTY, true); _checkUint64Property (instances [0], "SubscriptionDuration", PEGASUS_UINT64_LITERAL(60000000000)); _checkUint16Property (instances [0], "RepeatNotificationPolicy", 1); _checkStringProperty (instances [0], "OtherRepeatNotificationPolicy", "another policy"); _checkUint64Property (instances [0], "RepeatNotificationInterval", 60); _checkUint64Property (instances [0], "RepeatNotificationGap", 30); _checkUint16Property (instances [0], "RepeatNotificationCount", 5); paths = client.enumerateInstanceNames (PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_INDSUBSCRIPTION); PEGASUS_TEST_ASSERT (paths.size () == 1); _checkSubscriptionPath (path, "Filter01", PEGASUS_CLASSNAME_INDHANDLER_CIMXML, "Handler01"); CIMInstance subscription02 = _buildSubscriptionInstance (_buildFilterOrHandlerPath (PEGASUS_CLASSNAME_INDFILTER, "Filter02"),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -