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

📄 disableenable.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    Array <CIMKeyBinding> keyBindings;    keyBindings.append (CIMKeyBinding ("SystemCreationClassName",        System::getSystemCreationClassName (), CIMKeyBinding::STRING));    keyBindings.append (CIMKeyBinding ("SystemName",        System::getFullyQualifiedHostName (), CIMKeyBinding::STRING));    keyBindings.append (CIMKeyBinding ("CreationClassName",        className.getString(), CIMKeyBinding::STRING));    keyBindings.append (CIMKeyBinding ("Name", name, CIMKeyBinding::STRING));    path.setClassName (className);    path.setKeyBindings (keyBindings);    path.setNameSpace (namespaceName);    return path;}void _usage (){    PEGASUS_STD (cerr)         << "Usage: TestDisableEnable "        << "{setup | create | delete | create2 | addProvider | modifyProvider1 "        << "| modifyProvider2 | deleteProvider | delete2 | cleanup} {WQL | DMTF:CQL}"         << PEGASUS_STD (endl);}void _setup (CIMClient & client, String& qlang){    try    {        _createModuleInstance (client,             String ("ProcessIndicationProviderModule"),             String ("ProcessIndicationProvider"));        _createProviderInstance (client,             String ("ProcessIndicationProvider"),             String ("ProcessIndicationProviderModule"));        Array <CIMName> propertyNames;        propertyNames.append (CIMName ("IndicationTime"));        propertyNames.append (CIMName ("IndicationIdentifier"));        CIMPropertyList supportedProperties (propertyNames);        _createCapabilityInstance (client,             String ("ProcessIndicationProviderModule"),             String ("ProcessIndicationProvider"),            String ("DECapability01"),            String ("CIM_ProcessIndication"),            supportedProperties);        _createFilterInstance (client, String ("DEFilter01"),            String ("SELECT IndicationTime FROM cim_processindication"),            qlang, PEGASUS_NAMESPACENAME_INTEROP);        _createFilterInstance (client, String ("DEFilter02"),            String ("SELECT IndicationTime, IndicationIdentifier "                    "FROM CIM_ProcessIndication"),            qlang, NAMESPACE1);        _createHandlerInstance (client, String ("DEHandler01"),             String ("localhost/CIMListener/test1"),            PEGASUS_NAMESPACENAME_INTEROP);        _createHandlerInstance (client, String ("DEHandler02"),             String ("localhost/CIMListener/test1"), NAMESPACE2);    }    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 _create (CIMClient & client){    try    {        _createSubscriptionInstance (client,             _buildFilterOrHandlerPath (PEGASUS_CLASSNAME_INDFILTER,                 String ("DEFilter01")),            _buildFilterOrHandlerPath (PEGASUS_CLASSNAME_INDHANDLER_CIMXML,                String ("DEHandler01")), PEGASUS_NAMESPACENAME_INTEROP);    }    catch (Exception & e)    {        PEGASUS_STD (cerr) << "create failed: " << e.getMessage ()                           << PEGASUS_STD (endl);        exit (-1);    }    PEGASUS_STD (cout) << "+++++ create completed successfully"                       << PEGASUS_STD (endl);}void _create2 (CIMClient & client, String& qlang){    try    {        _createSubscriptionInstance (client,             _buildFilterOrHandlerPath (PEGASUS_CLASSNAME_INDFILTER,                 String ("DEFilter02"), NAMESPACE1),            _buildFilterOrHandlerPath (PEGASUS_CLASSNAME_INDHANDLER_CIMXML,                String ("DEHandler02"), NAMESPACE2), NAMESPACE3);    }    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 _delete (CIMClient & client){    try    {        _deleteSubscriptionInstance (client, String ("DEFilter01"),            String ("DEHandler01"));    }    catch (Exception & e)    {        PEGASUS_STD (cerr) << "delete failed: " << e.getMessage ()                           << PEGASUS_STD (endl);        exit (-1);    }    PEGASUS_STD (cout) << "+++++ delete completed successfully"                       << PEGASUS_STD (endl);}void _delete2 (CIMClient & client){    try    {        _deleteSubscriptionInstance (client, String ("DEFilter02"),            String ("DEHandler02"), NAMESPACE1, NAMESPACE2, NAMESPACE3);    }    catch (Exception & e)    {        PEGASUS_STD (cerr) << "delete2 failed: " << e.getMessage ()                           << PEGASUS_STD (endl);        exit (-1);    }    PEGASUS_STD (cout) << "+++++ delete2 completed successfully"                       << PEGASUS_STD (endl);}void _cleanup (CIMClient & client){    try    {        _deleteHandlerInstance (client, String ("DEHandler01"),            PEGASUS_NAMESPACENAME_INTEROP);        _deleteHandlerInstance (client, String ("DEHandler02"), NAMESPACE2);        _deleteFilterInstance (client, String ("DEFilter01"),            PEGASUS_NAMESPACENAME_INTEROP);        _deleteFilterInstance (client, String ("DEFilter02"), NAMESPACE1);        _deleteCapabilityInstance (client,             String ("ProcessIndicationProviderModule"),             String ("ProcessIndicationProvider"),            String ("DECapability01"));        _deleteProviderInstance (client,             String ("ProcessIndicationProvider"),             String ("ProcessIndicationProviderModule"));        _deleteModuleInstance (client,             String ("ProcessIndicationProviderModule"));    }    catch (Exception & e)    {        PEGASUS_STD (cerr) << "cleanup failed: " << e.getMessage ()                           << PEGASUS_STD (endl);        exit (-1);    }    PEGASUS_STD (cout) << "+++++ cleanup completed successfully"                       << PEGASUS_STD (endl);}void _addProvider (CIMClient & client){    try    {        _createProviderInstance (client,             String ("ProcessIndicationProvider2"),             String ("ProcessIndicationProviderModule"));        Array <CIMName> propertyNames;        propertyNames.append (CIMName ("IndicationTime"));        CIMPropertyList supportedProperties (propertyNames);        _createCapabilityInstance (client,             String ("ProcessIndicationProviderModule"),             String ("ProcessIndicationProvider2"),            String ("DECapability02"),            String ("CIM_ProcessIndication"),            supportedProperties);    }    catch (Exception & e)    {        PEGASUS_STD (cerr) << "addProvider failed: " << e.getMessage ()                           << PEGASUS_STD (endl);        exit (-1);    }    PEGASUS_STD (cout) << "+++++ addProvider completed successfully"                       << PEGASUS_STD (endl);}void _modifyProvider1 (CIMClient & client){    try    {        Array <CIMName> propertyNames;        propertyNames.append (CIMName ("IndicationTime"));        propertyNames.append (CIMName ("IndicationIdentifier"));        CIMPropertyList supportedProperties (propertyNames);        _modifyCapabilityInstance (client,             String ("ProcessIndicationProviderModule"),             String ("ProcessIndicationProvider2"),            String ("DECapability02"),            supportedProperties);    }    catch (Exception & e)    {        PEGASUS_STD (cerr) << "modifyProvider1 failed: " << e.getMessage ()                           << PEGASUS_STD (endl);        exit (-1);    }    PEGASUS_STD (cout) << "+++++ modifyProvider1 completed successfully"                       << PEGASUS_STD (endl);}void _modifyProvider2 (CIMClient & client){    try    {        Array <CIMName> propertyNames;        propertyNames.append (CIMName ("IndicationTime"));        CIMPropertyList supportedProperties (propertyNames);        _modifyCapabilityInstance (client,             String ("ProcessIndicationProviderModule"),             String ("ProcessIndicationProvider2"),            String ("DECapability02"),            supportedProperties);    }    catch (Exception & e)    {        PEGASUS_STD (cerr) << "modifyProvider2 failed: " << e.getMessage ()                           << PEGASUS_STD (endl);        exit (-1);    }    PEGASUS_STD (cout) << "+++++ modifyProvider2 completed successfully"                       << PEGASUS_STD (endl);}void _deleteProvider (CIMClient & client){    try    {        _deleteCapabilityInstance (client,             String ("ProcessIndicationProviderModule"),             String ("ProcessIndicationProvider2"),            String ("DECapability02"));        _deleteProviderInstance (client,             String ("ProcessIndicationProvider2"),             String ("ProcessIndicationProviderModule"));    }    catch (Exception & e)    {        PEGASUS_STD (cerr) << "deleteProvider failed: " << e.getMessage ()                           << PEGASUS_STD (endl);        exit (-1);    }    PEGASUS_STD (cout) << "+++++ deleteProvider completed successfully"                       << PEGASUS_STD (endl);}int _test(CIMClient& client, const char* opt, String& qlang){  if (String::equalNoCase (opt, "setup"))  {      _setup (client, qlang);  }  else if (String::equalNoCase (opt, "create"))  {    _create (client);  }  else if (String::equalNoCase (opt, "create2"))  {    _create2 (client, qlang);  }  else if (String::equalNoCase (opt, "addProvider"))  {    _addProvider (client);  }  else if (String::equalNoCase (opt, "modifyProvider1"))  {      _modifyProvider1 (client);  }  else if (String::equalNoCase (opt, "modifyProvider2"))  {    _modifyProvider2 (client);  }  else if (String::equalNoCase (opt, "deleteProvider"))  {    _deleteProvider (client);  }  else if (String::equalNoCase (opt, "delete"))  {    _delete (client);  }  else if (String::equalNoCase (opt, "delete2"))  {    _delete2 (client);  }  else if (String::equalNoCase (opt, "cleanup"))  {    _cleanup (client);  }  else  {    PEGASUS_STD (cerr) << "Invalid option: " << opt                        << PEGASUS_STD (endl);    _usage ();    return -1;  }    return 0;}int main (int argc, char** argv){    CIMClient client;    try    {        client.connectLocal ();    }    catch (Exception & e)    {        PEGASUS_STD (cerr) << e.getMessage () << PEGASUS_STD (endl);        return -1;    }    if (argc != 3)    {        _usage ();        return 1;    }    else    {        const char * opt = argv [1];        const char * optLang = argv [2];        String qlang(optLang);#ifdef PEGASUS_DISABLE_CQL        if (qlang == "DMTF:CQL")        {          PEGASUS_STD (cout) << "+++++ cql test disabled" << PEGASUS_STD (endl);          return 0;        }        else        {          return _test(client, opt, qlang);        }#else        return _test(client, opt, qlang);#endif    }    PEGASUS_UNREACHABLE( return 0; )}

⌨️ 快捷键说明

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