📄 processindication.cpp
字号:
// Allow time for the indication to be received and forwarded // System::sleep (5);}void _sendTestIndicationNormal (CIMClient & client){ _sendTestIndication (client, CIMName ("SendTestIndicationNormal"));}void _sendTestIndicationSubclass (CIMClient & client){ _sendTestIndication (client, CIMName ("SendTestIndicationSubclass"));}void _sendTestIndicationMissing (CIMClient & client){ _sendTestIndication (client, CIMName ("SendTestIndicationMissingProperty"));}void _sendTestIndicationExtra (CIMClient & client){ _sendTestIndication (client, CIMName ("SendTestIndicationExtraProperty"));}void _sendTestIndicationMatching (CIMClient & client){ _sendTestIndication (client, CIMName ("SendTestIndicationMatchingInstance"));}void _sendTestIndicationUnmatchingNamespace (CIMClient & client){ _sendTestIndication (client, CIMName ("SendTestIndicationUnmatchingNamespace"));}void _sendTestIndicationUnmatchingClassName (CIMClient & client){ _sendTestIndication (client, CIMName ("SendTestIndicationUnmatchingClassName"));}void _deleteSubscriptionInstance (CIMClient & client, const String & filterName, const String & handlerName){ Array<CIMKeyBinding> filterKeyBindings; filterKeyBindings.append (CIMKeyBinding ("SystemCreationClassName", System::getSystemCreationClassName (), CIMKeyBinding::STRING)); filterKeyBindings.append (CIMKeyBinding ("SystemName", System::getFullyQualifiedHostName (), CIMKeyBinding::STRING)); filterKeyBindings.append (CIMKeyBinding ("CreationClassName", PEGASUS_CLASSNAME_INDFILTER.getString(), CIMKeyBinding::STRING)); filterKeyBindings.append (CIMKeyBinding ("Name", filterName, CIMKeyBinding::STRING)); CIMObjectPath filterPath ("", CIMNamespaceName (), PEGASUS_CLASSNAME_INDFILTER, filterKeyBindings); Array<CIMKeyBinding> handlerKeyBindings; handlerKeyBindings.append (CIMKeyBinding ("SystemCreationClassName", System::getSystemCreationClassName (), CIMKeyBinding::STRING)); handlerKeyBindings.append (CIMKeyBinding ("SystemName", System::getFullyQualifiedHostName (), CIMKeyBinding::STRING)); handlerKeyBindings.append (CIMKeyBinding ("CreationClassName", PEGASUS_CLASSNAME_INDHANDLER_CIMXML.getString(), CIMKeyBinding::STRING)); handlerKeyBindings.append (CIMKeyBinding ("Name", handlerName, CIMKeyBinding::STRING)); CIMObjectPath handlerPath ("", CIMNamespaceName (), PEGASUS_CLASSNAME_INDHANDLER_CIMXML, handlerKeyBindings); Array<CIMKeyBinding> subscriptionKeyBindings; subscriptionKeyBindings.append (CIMKeyBinding ("Filter", filterPath.toString (), CIMKeyBinding::REFERENCE)); subscriptionKeyBindings.append (CIMKeyBinding ("Handler", handlerPath.toString (), CIMKeyBinding::REFERENCE)); CIMObjectPath subscriptionPath ("", CIMNamespaceName (), PEGASUS_CLASSNAME_INDSUBSCRIPTION, subscriptionKeyBindings); client.deleteInstance (PEGASUS_NAMESPACENAME_INTEROP, subscriptionPath);}void _deleteHandlerInstance (CIMClient & client, const String & name){ Array<CIMKeyBinding> keyBindings; keyBindings.append (CIMKeyBinding ("SystemCreationClassName", System::getSystemCreationClassName (), CIMKeyBinding::STRING)); keyBindings.append (CIMKeyBinding ("SystemName", System::getFullyQualifiedHostName (), CIMKeyBinding::STRING)); keyBindings.append (CIMKeyBinding ("CreationClassName", PEGASUS_CLASSNAME_INDHANDLER_CIMXML.getString(), CIMKeyBinding::STRING)); keyBindings.append (CIMKeyBinding ("Name", name, CIMKeyBinding::STRING)); CIMObjectPath path ("", CIMNamespaceName (), PEGASUS_CLASSNAME_INDHANDLER_CIMXML, keyBindings); client.deleteInstance (PEGASUS_NAMESPACENAME_INTEROP, path);}void _deleteFilterInstance (CIMClient & client, const String & name){ Array<CIMKeyBinding> keyBindings; keyBindings.append (CIMKeyBinding ("SystemCreationClassName", System::getSystemCreationClassName (), CIMKeyBinding::STRING)); keyBindings.append (CIMKeyBinding ("SystemName", System::getFullyQualifiedHostName (), CIMKeyBinding::STRING)); keyBindings.append (CIMKeyBinding ("CreationClassName", PEGASUS_CLASSNAME_INDFILTER.getString(), CIMKeyBinding::STRING)); keyBindings.append (CIMKeyBinding ("Name", name, CIMKeyBinding::STRING)); CIMObjectPath path ("", CIMNamespaceName (), PEGASUS_CLASSNAME_INDFILTER, keyBindings); client.deleteInstance (PEGASUS_NAMESPACENAME_INTEROP, path);}void _usage (){ PEGASUS_STD (cerr) << "Usage: TestProcessIndication " << "{setup | create1 | create2 | create3 | create4 " << "| sendNormal | sendMissing | sendExtra " << "| sendMatching | sendUnmatchingNamespace | sendUnmatchingClassName " << "| checkNormal | checkMissing | checkExtra | checkMatching " << "| checkUnmatchingNamespace | checkUnmatchingClassName " << "| checkNormalAll | checkMissingAll | checkExtraAll " << "| checkNormalWhere | checkMissingWhere " << "| checkNormalWhereNotSatisfied " << "| delete1 | delete2 | delete3 | delete4 | cleanup} {WQL | DMTF:CQL}" << PEGASUS_STD (endl);}void _setup (CIMClient & client, String& qlang){ try { _createFilterInstance (client, String ("PIFilter01"), String ("SELECT IndicationIdentifier, MethodName, CorrelatedIndications " "FROM RT_TestIndication"), qlang); _createFilterInstance (client, String ("PIFilter02"), String ("SELECT * FROM RT_TestIndication"), qlang); // // Filter03 and Filter04 are not created for WQL because WQL does not // support array properties in the WHERE clause // if (qlang != "WQL") { // // The following filters are used to test that only properties // required for the WHERE clause are treated as required for // indications. // Normally, the RT_Indication test provider generates an // indication that includes a non-NULL CorrelatedIndications // property value. // When the SendTestIndicationMissingProperty method is invoked, // the RT_Indication test provider generates an indication that // is missing the CorrelatedIndications property. // For PIFilter03, normally the generated indication includes all // required properties, and the generated indication satisfies the // query condition (WHERE clause). // However, when the SendTestIndicationMissingProperty method is // used, the generated indication does not include all the required // properties, and the indication is not forwarded. // For PIFilter04, normally the generated indication includes all // required properties, but the generated indication does not // satisfy the query condition (WHERE clause), because the // CorrelatedIndications property has a non-NULL value, so the // indication is not forwarded. // When the SendTestIndicationMissingProperty method is used, the // generated indication does not include all the required // properties, and the indication is not forwarded. // _createFilterInstance (client, String ("PIFilter03"), String ("SELECT IndicationIdentifier, MethodName, " "CorrelatedIndications " "FROM RT_TestIndication " "WHERE CorrelatedIndications IS NOT NULL"), qlang); _createFilterInstance (client, String ("PIFilter04"), String ("SELECT IndicationIdentifier, MethodName, " "CorrelatedIndications " "FROM RT_TestIndication WHERE CorrelatedIndications IS NULL"), qlang); } _createHandlerInstance (client, String ("PIHandler01"), String ("localhost/CIMListener/Pegasus_SimpleDisplayConsumer")); } catch (Exception & e) { PEGASUS_STD (cerr) << "setup failed: " << e.getMessage () << PEGASUS_STD (endl); exit (-1); } PEGASUS_STD (cout) << "+++++ setup completed successfully" << PEGASUS_STD (endl);}void _create1 (CIMClient & client){ try { String filterPathString; filterPathString.append ("CIM_IndicationFilter.CreationClassName=\"CIM_IndicationFilter\",Name=\"PIFilter01\",SystemCreationClassName=\""); filterPathString.append (System::getSystemCreationClassName ()); filterPathString.append ("\",SystemName=\""); filterPathString.append (System::getFullyQualifiedHostName ()); filterPathString.append ("\""); String handlerPathString; handlerPathString.append ("CIM_IndicationHandlerCIMXML.CreationClassName=\"CIM_IndicationHandlerCIMXML\",Name=\"PIHandler01\",SystemCreationClassName=\""); handlerPathString.append (System::getSystemCreationClassName ()); handlerPathString.append ("\",SystemName=\""); handlerPathString.append (System::getFullyQualifiedHostName ()); handlerPathString.append ("\""); _createSubscriptionInstance (client, CIMObjectPath (filterPathString), CIMObjectPath (handlerPathString)); } catch (Exception & e) { PEGASUS_STD (cerr) << "create1 failed: " << e.getMessage () << PEGASUS_STD (endl); exit (-1); } PEGASUS_STD (cout) << "+++++ create1 completed successfully" << PEGASUS_STD (endl);}void _create2 (CIMClient & client){ try { String filterPathString; filterPathString.append ("CIM_IndicationFilter.CreationClassName=\"CIM_IndicationFilter\",Name=\"PIFilter02\",SystemCreationClassName=\""); filterPathString.append (System::getSystemCreationClassName ()); filterPathString.append ("\",SystemName=\""); filterPathString.append (System::getFullyQualifiedHostName ()); filterPathString.append ("\""); String handlerPathString; handlerPathString.append ("CIM_IndicationHandlerCIMXML.CreationClassName=\"CIM_IndicationHandlerCIMXML\",Name=\"PIHandler01\",SystemCreationClassName=\""); handlerPathString.append (System::getSystemCreationClassName ()); handlerPathString.append ("\",SystemName=\""); handlerPathString.append (System::getFullyQualifiedHostName ()); handlerPathString.append ("\""); _createSubscriptionInstance (client, CIMObjectPath (filterPathString), CIMObjectPath (handlerPathString)); } catch (Exception & e) { PEGASUS_STD (cerr) << "create2 failed: " << e.getMessage () << PEGASUS_STD (endl); exit (-1); } PEGASUS_STD (cout) << "+++++ create2 completed successfully" << PEGASUS_STD (endl);}void _create3 (CIMClient & client){ try { String filterPathString; filterPathString.append ("CIM_IndicationFilter.CreationClassName=\"CIM_IndicationFilter\",Name=\"PIFilter03\",SystemCreationClassName=\""); filterPathString.append (System::getSystemCreationClassName ()); filterPathString.append ("\",SystemName=\""); filterPathString.append (System::getFullyQualifiedHostName ()); filterPathString.append ("\""); String handlerPathString; handlerPathString.append ("CIM_IndicationHandlerCIMXML.CreationClassName=\"CIM_IndicationHandlerCIMXML\",Name=\"PIHandler01\",SystemCreationClassName=\""); handlerPathString.append (System::getSystemCreationClassName ()); handlerPathString.append ("\",SystemName=\""); handlerPathString.append (System::getFullyQualifiedHostName ()); handlerPathString.append ("\""); _createSubscriptionInstance (client, CIMObjectPath (filterPathString), CIMObjectPath (handlerPathString)); } catch (Exception & e) { PEGASUS_STD (cerr) << "create3 failed: " << e.getMessage () << PEGASUS_STD (endl); exit (-1); } PEGASUS_STD (cout) << "+++++ create3 completed successfully" << PEGASUS_STD (endl);}void _create4 (CIMClient & client){ try { String filterPathString; filterPathString.append ("CIM_IndicationFilter.CreationClassName=\"CIM_IndicationFilter\",Name=\"PIFilter04\",SystemCreationClassName=\""); filterPathString.append (System::getSystemCreationClassName ()); filterPathString.append ("\",SystemName=\""); filterPathString.append (System::getFullyQualifiedHostName ()); filterPathString.append ("\""); String handlerPathString; handlerPathString.append ("CIM_IndicationHandlerCIMXML.CreationClassName=\"CIM_IndicationHandlerCIMXML\",Name=\"PIHandler01\",SystemCreationClassName=\""); handlerPathString.append (System::getSystemCreationClassName ()); handlerPathString.append ("\",SystemName=\""); handlerPathString.append (System::getFullyQualifiedHostName ()); handlerPathString.append ("\""); _createSubscriptionInstance (client, CIMObjectPath (filterPathString), CIMObjectPath (handlerPathString)); } catch (Exception & e) { PEGASUS_STD (cerr) << "create4 failed: " << e.getMessage () << PEGASUS_STD (endl); exit (-1); } PEGASUS_STD (cout) << "+++++ create4 completed successfully" << PEGASUS_STD (endl);}void _sendNormal (CIMClient & client){ try { _sendTestIndicationNormal (client); } catch (Exception & e) { PEGASUS_STD (cerr) << "sendNormal failed: " << e.getMessage () << PEGASUS_STD (endl); exit (-1); } PEGASUS_STD (cout) << "+++++ sendNormal completed successfully" << PEGASUS_STD (endl);}void _sendSubclass (CIMClient & client){ try { _sendTestIndicationSubclass (client); } catch (Exception & e) { PEGASUS_STD (cerr) << "sendSubclass failed: " << e.getMessage () << PEGASUS_STD (endl); exit (-1); } PEGASUS_STD (cout) << "+++++ sendSubclass completed successfully" << PEGASUS_STD (endl);}void _sendMissing (CIMClient & client){ try { _sendTestIndicationMissing (client); } catch (Exception & e) { PEGASUS_STD (cerr) << "sendMissing failed: " << e.getMessage () << PEGASUS_STD (endl); exit (-1); } PEGASUS_STD (cout) << "+++++ sendMissing completed successfully" << PEGASUS_STD (endl);}void _sendExtra (CIMClient & client){ try { _sendTestIndicationExtra (client); } catch (Exception & e) { PEGASUS_STD (cerr) << "sendExtra failed: " << e.getMessage () << PEGASUS_STD (endl); exit (-1); } PEGASUS_STD (cout) << "+++++ sendExtra completed successfully" << PEGASUS_STD (endl);}void _sendMatching (CIMClient & client){ try { _sendTestIndicationMatching (client); } catch (Exception & e) { PEGASUS_STD (cerr) << "sendMatching failed: " << e.getMessage () << PEGASUS_STD (endl); exit (-1); } PEGASUS_STD (cout) << "+++++ sendMatching completed successfully" << PEGASUS_STD (endl);}void _sendUnmatchingNamespace (CIMClient & client){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -