⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subscription.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        PEGASUS_NAMESPACENAME_INTEROP);}void _deleteFilterInstance    (CIMClient & client,     const String & name,     const CIMNamespaceName & nameSpace){    CIMObjectPath path = _buildFilterOrHandlerPath        (PEGASUS_CLASSNAME_INDFILTER, name);    client.deleteInstance (nameSpace, path);}void _deleteFilterInstance    (CIMClient & client,     const String & name){    _deleteFilterInstance (client, name,        PEGASUS_NAMESPACENAME_INTEROP);}void _deleteCapabilityInstance    (CIMClient & client,     const String & providerModuleName,     const String & providerName,     const String & capabilityID){    Array<CIMKeyBinding> keyBindings;    keyBindings.append (CIMKeyBinding ("ProviderModuleName",        providerModuleName, CIMKeyBinding::STRING));    keyBindings.append (CIMKeyBinding ("ProviderName",        providerName, CIMKeyBinding::STRING));    keyBindings.append (CIMKeyBinding ("CapabilityID",        capabilityID, CIMKeyBinding::STRING));    CIMObjectPath path ("", CIMNamespaceName (),        CIMName ("PG_ProviderCapabilities"), keyBindings);    client.deleteInstance (PEGASUS_NAMESPACENAME_INTEROP, path);}void _deleteProviderInstance    (CIMClient & client,     const String & name,     const String & providerModuleName){    Array<CIMKeyBinding> keyBindings;    keyBindings.append (CIMKeyBinding ("Name",        name, CIMKeyBinding::STRING));    keyBindings.append (CIMKeyBinding ("ProviderModuleName",        providerModuleName, CIMKeyBinding::STRING));    CIMObjectPath path ("", CIMNamespaceName (),        CIMName ("PG_Provider"), keyBindings);    client.deleteInstance (PEGASUS_NAMESPACENAME_INTEROP, path);}void _deleteModuleInstance    (CIMClient & client,     const String & name){    Array<CIMKeyBinding> keyBindings;    keyBindings.append (CIMKeyBinding ("Name",        name, CIMKeyBinding::STRING));    CIMObjectPath path ("", CIMNamespaceName (),        CIMName ("PG_ProviderModule"), keyBindings);    client.deleteInstance (PEGASUS_NAMESPACENAME_INTEROP, path);}void _usage (){    cerr        << "Usage: TestSubscription "        << "{register | test | unregister | cleanup }"        << endl;}void _register (CIMClient & client){    try    {        Array <String> namespaces;        Array <Uint16> providerTypes;        namespaces.append (SOURCENAMESPACE.getString ());        providerTypes.append (4);        //        //  Register the ProcessIndicationProvider        //        _createModuleInstance (client,            String ("ProcessIndicationProviderModule"),            String ("ProcessIndicationProvider"));        _createProviderInstance (client,            String ("ProcessIndicationProvider"),            String ("ProcessIndicationProviderModule"));        _createCapabilityInstance (client,            String ("ProcessIndicationProviderModule"),            String ("ProcessIndicationProvider"),            String ("ProcessIndicationProviderCapability"),            String ("CIM_ProcessIndication"),            namespaces,            providerTypes,            CIMPropertyList ());        //        //  Register the AlertIndicationProvider        //        _createModuleInstance (client,            String ("AlertIndicationProviderModule"),            String ("AlertIndicationProvider"));        _createProviderInstance (client,            String ("AlertIndicationProvider"),            String ("AlertIndicationProviderModule"));        _createCapabilityInstance (client,            String ("AlertIndicationProviderModule"),            String ("AlertIndicationProvider"),            String ("AlertIndicationProviderCapability"),            String ("CIM_AlertIndication"),            namespaces,            providerTypes,            CIMPropertyList ());    }    catch (Exception & e)    {        cerr << "register failed: " << e.getMessage () << endl;        exit (-1);    }    cout << "+++++ register completed successfully" << endl;}////  Valid test cases: create, get, enumerate, modify, delete operations//void _valid (CIMClient & client, String& qlang){    CIMObjectPath path;    String query;    CIMInstance retrievedInstance;    Array <CIMInstance> instances;    Array <CIMObjectPath> paths;    //    //  Create filter that selects all properties from CIM_ProcessIndication    //    CIMInstance filter01 (PEGASUS_CLASSNAME_INDFILTER);    query = "SELECT * FROM CIM_ProcessIndication";    _addStringProperty (filter01, "SystemCreationClassName",         System::getSystemCreationClassName ());    _addStringProperty (filter01, "SystemName",         System::getFullyQualifiedHostName ());    _addStringProperty (filter01, "CreationClassName",         PEGASUS_CLASSNAME_INDFILTER.getString ());    _addStringProperty (filter01, "Name", "Filter01");    _addStringProperty (filter01, "SourceNamespace",        SOURCENAMESPACE.getString ());    _addStringProperty (filter01, "Query", query);    _addStringProperty (filter01, "QueryLanguage", qlang);    path = client.createInstance (PEGASUS_NAMESPACENAME_INTEROP, filter01);    _checkFilterOrHandlerPath (path, PEGASUS_CLASSNAME_INDFILTER, "Filter01");    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", "Filter01");    _checkStringProperty (retrievedInstance, "SourceNamespace",        SOURCENAMESPACE.getString ());    _checkStringProperty (retrievedInstance, "Query", query);    _checkStringProperty (retrievedInstance, "QueryLanguage", qlang);    //    //  Enumerate filters    //    instances = client.enumerateInstances        (PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_INDFILTER);    PEGASUS_TEST_ASSERT (instances.size () == 1);    _checkStringProperty (instances [0], "SystemCreationClassName",        System::getSystemCreationClassName ());    _checkStringProperty (instances [0], "SystemName",        System::getFullyQualifiedHostName ());    _checkStringProperty (instances [0], "CreationClassName",        PEGASUS_CLASSNAME_INDFILTER.getString ());    _checkStringProperty (instances [0], "Name", "Filter01");    _checkStringProperty (instances [0], "SourceNamespace",        SOURCENAMESPACE.getString ());    _checkStringProperty (instances [0], "Query", query);    _checkStringProperty (instances [0], "QueryLanguage", qlang);    paths = client.enumerateInstanceNames        (PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_INDFILTER);    PEGASUS_TEST_ASSERT (paths.size () == 1);    _checkFilterOrHandlerPath (paths [0], PEGASUS_CLASSNAME_INDFILTER,        "Filter01");    //    //  Create filter that selects some properties from    //  CIM_ProcessIndication    //    CIMInstance filter02 (PEGASUS_CLASSNAME_INDFILTER);    query = "SELECT IndicationTime, IndicationIdentifier, "        "CorrelatedIndications "        "FROM CIM_ProcessIndication";    _addStringProperty (filter02, "Name", "Filter02");    _addStringProperty (filter02, "Query", query);    _addStringProperty (filter02, "QueryLanguage", qlang);    _addStringProperty (filter02, "SourceNamespace",        SOURCENAMESPACE.getString ());    path = client.createInstance (PEGASUS_NAMESPACENAME_INTEROP,        filter02);    _checkFilterOrHandlerPath (path, PEGASUS_CLASSNAME_INDFILTER, "Filter02");    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", "Filter02");    _checkStringProperty (retrievedInstance, "SourceNamespace",        SOURCENAMESPACE.getString ());    _checkStringProperty (retrievedInstance, "Query", query);    _checkStringProperty (retrievedInstance, "QueryLanguage", qlang);    //    //  Create filter that selects one property from CIM_ProcessIndication    //    CIMInstance filter03 (PEGASUS_CLASSNAME_INDFILTER);    query = "SELECT IndicationTime FROM CIM_ProcessIndication";    _addStringProperty (filter03, "Name", "Filter03");    _addStringProperty (filter03, "Query", query);    _addStringProperty (filter03, "QueryLanguage", qlang);    _addStringProperty (filter03, "SourceNamespace",        SOURCENAMESPACE.getString ());    path = client.createInstance (PEGASUS_NAMESPACENAME_INTEROP, filter03);    _checkFilterOrHandlerPath (path, PEGASUS_CLASSNAME_INDFILTER, "Filter03");    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", "Filter03");    _checkStringProperty (retrievedInstance, "SourceNamespace",        SOURCENAMESPACE.getString ());    _checkStringProperty (retrievedInstance, "Query", query);    _checkStringProperty (retrievedInstance, "QueryLanguage", qlang);    //    //  Create filter that selects properties from CIM_ProcessIndication    //  and has a where clause condition    //    CIMInstance filter04 (PEGASUS_CLASSNAME_INDFILTER);    query = "SELECT IndicationTime, IndicationIdentifier "          "FROM CIM_ProcessIndication "          "WHERE IndicationTime IS NOT NULL";    _addStringProperty (filter04, "Name", "Filter04");    _addStringProperty (filter04, "Query", query);    _addStringProperty (filter04, "QueryLanguage", qlang);    _addStringProperty (filter04, "SourceNamespace",        SOURCENAMESPACE.getString ());    path = client.createInstance (PEGASUS_NAMESPACENAME_INTEROP, filter04);    _checkFilterOrHandlerPath (path, PEGASUS_CLASSNAME_INDFILTER, "Filter04");    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", "Filter04");    _checkStringProperty (retrievedInstance, "SourceNamespace",        SOURCENAMESPACE.getString ());    _checkStringProperty (retrievedInstance, "Query", query);    _checkStringProperty (retrievedInstance, "QueryLanguage", qlang);#ifndef PEGASUS_DISABLE_CQL    //    //  Create filter that selects properties from CIM_ProcessIndication    //  and has a where clause condition that includes an array property.    //  Note: this is only allowed by CQL.    //    CIMInstance filter04a (PEGASUS_CLASSNAME_INDFILTER);    query = "SELECT IndicationTime, IndicationIdentifier "          "FROM CIM_ProcessIndication "          "WHERE IndicationTime IS NOT NULL AND CorrelatedIndications IS NOT NULL";    _addStringProperty (filter04a, "Name", "Filter04a");    _addStringProperty (filter04a, "Query", query);    _addStringProperty (filter04a, "QueryLanguage", "DMTF:CQL");  // hardcode to CQL    _addStringProperty (filter04a, "SourceNamespace",        SOURCENAMESPACE.getString ());    path = client.createInstance (PEGASUS_NAMESPACENAME_INTEROP,        filter04a);    _checkFilterOrHandlerPath (path, PEGASUS_CLASSNAME_INDFILTER, "Filter04a");    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", "Filter04a");    _checkStringProperty (retrievedInstance, "SourceNamespace",        SOURCENAMESPACE.getString ());    _checkStringProperty (retrievedInstance, "Query", query);    _checkStringProperty (retrievedInstance, "QueryLanguage", "DMTF:CQL"); // hardcode to CQL#endif    //    //  Create filter that selects all properties from CIM_ProcessIndication    //  and has a where clause condition    //    CIMInstance filter05 (PEGASUS_CLASSNAME_INDFILTER);    query = "SELECT * FROM CIM_ProcessIndication "        "WHERE IndicationTime IS NOT NULL";    _addStringProperty (filter05, "Name", "Filter05");    _addStringProperty (filter05, "Query", query);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -