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

📄 cimsubinterop.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        PEGASUS_CLASSNAME_INDSUBSCRIPTION, subscriptionKeyBindings);    return subscriptionPath;}CIMInstance _buildSubscriptionInstance(    const CIMObjectPath & filterPath,    const CIMName & handlerClass,    const CIMObjectPath & handlerPath){    CIMInstance subscriptionInstance(PEGASUS_CLASSNAME_INDSUBSCRIPTION);    subscriptionInstance.addProperty(CIMProperty(            PEGASUS_PROPERTYNAME_FILTER.getString(),        filterPath, 0, PEGASUS_CLASSNAME_INDFILTER));    subscriptionInstance.addProperty(CIMProperty(        PEGASUS_PROPERTYNAME_HANDLER.getString(),        handlerPath, 0, handlerClass));    return subscriptionInstance;}void _deleteSubscriptionInstance(    CIMClient & client,    const String & filterName,    const CIMName & handlerClass,    const String & handlerName,    const String & filterHost = String::EMPTY,    const String & handlerHost = String::EMPTY,    const CIMNamespaceName & filterNS = NULL_NAMESPACE,    const CIMNamespaceName & handlerNS = CIMNamespaceName(),    const CIMNamespaceName & subscriptionNS = NAMESPACE){    CIMObjectPath subscriptionPath = _buildSubscriptionPath(        filterName, handlerClass, handlerName, filterHost, handlerHost,        filterNS, handlerNS);    client.deleteInstance(subscriptionNS, subscriptionPath);}void _deleteHandlerInstance(    CIMClient & client,    const CIMName & className,    const String & name,    const CIMNamespaceName & nameSpace = NAMESPACE){    CIMObjectPath path = _buildFilterOrHandlerPath(className, name);    client.deleteInstance(nameSpace, path);}void _deleteFilterInstance(    CIMClient & client,    const String & name,    const CIMNamespaceName & nameSpace = NAMESPACE){    CIMObjectPath path = _buildFilterOrHandlerPath(        PEGASUS_CLASSNAME_INDFILTER, name);    client.deleteInstance(nameSpace, path);}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(PEGASUS_PROPERTYNAME_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(PEGASUS_PROPERTYNAME_NAME,        name, CIMKeyBinding::STRING));    CIMObjectPath path("", CIMNamespaceName(),        CIMName("PG_ProviderModule"), keyBindings);    client.deleteInstance(PEGASUS_NAMESPACENAME_INTEROP, path);}void _usage(){    cerr        << "Usage: TestCimsubInteOp "        << "{register | test | "#ifdef PEGASUS_ENABLE_EMAIL_HANDLER        << "test_email |"#endif#ifdef PEGASUS_ENABLE_SYSTEM_LOG_HANDLER        << " test_syslog |"#endif        << " unregister | cleanup }"        << endl;}void _register(CIMClient & client){    try    {        Array <String> namespaces;        Array <Uint16> providerTypes;        namespaces.append(SOURCENAMESPACE.getString());        providerTypes.append(4);        providerTypes.append(5);        //        //  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;}////  Creates filters, handlers, and subscriptions to test the cimsub CLI//void _createCimsubTests(CIMClient & client, String& qlang){    CIMObjectPath path;    String query;    //    //  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,         PEGASUS_PROPERTYNAME_CREATIONCLASSNAME.getString(),         PEGASUS_CLASSNAME_INDFILTER.getString());    _addStringProperty(filter01, PEGASUS_PROPERTYNAME_NAME.getString(),        "Filter01");    _addStringProperty(filter01, "SourceNamespace",        SOURCENAMESPACE.getString());    _addStringProperty(filter01, PEGASUS_PROPERTYNAME_QUERY.getString(),        query);    _addStringProperty(filter01,        PEGASUS_PROPERTYNAME_QUERYLANGUAGE.getString(), qlang);    path = client.createInstance(NAMESPACE, 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, PEGASUS_PROPERTYNAME_NAME.getString(),        "Filter02");    _addStringProperty(filter02, PEGASUS_PROPERTYNAME_QUERY.getString(),        query);    _addStringProperty(filter02,        PEGASUS_PROPERTYNAME_QUERYLANGUAGE.getString(), qlang);    _addStringProperty(filter02, "SourceNamespace",        SOURCENAMESPACE.getString());    path = client.createInstance(NAMESPACE, filter02);    //    //  Create filter that selects one property from CIM_ProcessIndication    //    CIMInstance filter03(PEGASUS_CLASSNAME_INDFILTER);    query = "SELECT IndicationTime FROM CIM_ProcessIndication";    _addStringProperty(filter03, PEGASUS_PROPERTYNAME_NAME.getString(),        "Filter03");    _addStringProperty(filter03, PEGASUS_PROPERTYNAME_QUERY.getString(),        query);    _addStringProperty(filter03,        PEGASUS_PROPERTYNAME_QUERYLANGUAGE.getString(), qlang);    _addStringProperty(filter03, "SourceNamespace",        SOURCENAMESPACE.getString());    path = client.createInstance(NAMESPACE, filter03);    //    //  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, PEGASUS_PROPERTYNAME_NAME.getString(),        "Filter04");    _addStringProperty(filter04, PEGASUS_PROPERTYNAME_QUERY.getString(),        query);    _addStringProperty(filter04,         PEGASUS_PROPERTYNAME_QUERYLANGUAGE.getString(), qlang);    _addStringProperty(filter04, "SourceNamespace",        SOURCENAMESPACE.getString());    path = client.createInstance(NAMESPACE, filter04);#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, PEGASUS_PROPERTYNAME_NAME.getString(),        "Filter04a");    _addStringProperty(filter04a, PEGASUS_PROPERTYNAME_QUERY.getString(),        query);        // hardcode to CQL       _addStringProperty(filter04a,         PEGASUS_PROPERTYNAME_QUERYLANGUAGE.getString(), "DMTF:CQL");     _addStringProperty(filter04a, "SourceNamespace",        SOURCENAMESPACE.getString());    path = client.createInstance(NAMESPACE, filter04a);#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, PEGASUS_PROPERTYNAME_NAME.getString(),        "Filter05");    _addStringProperty(filter05, PEGASUS_PROPERTYNAME_QUERY.getString(),        query);    _addStringProperty(filter05,        PEGASUS_PROPERTYNAME_QUERYLANGUAGE.getString(), qlang);    _addStringProperty(filter05, "SourceNamespace",        SOURCENAMESPACE.getString());    path = client.createInstance(NAMESPACE, filter05);    //    //  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, PEGASUS_PROPERTYNAME_NAME.getString(),        "Filter06");    _addStringProperty(filter06, PEGASUS_PROPERTYNAME_QUERY.getString(),        query);    _addStringProperty(filter06,        PEGASUS_PROPERTYNAME_QUERYLANGUAGE.getString(), qlang);    _addStringProperty(filter06, "SourceNamespace",        SOURCENAMESPACE.getString());    path = client.createInstance(NAMESPACE, filter06);    //    //  Create persistent CIMXML handler    //    CIMInstance handler01(PEGASUS_CLASSNAME_INDHANDLER_CIMXML);    _addStringProperty(handler01, "SystemCreationClassName",         System::getSystemCreationClassName());    _addStringProperty(handler01, "SystemName",         System::getFullyQualifiedHostName());    _addStringProperty(handler01,         PEGASUS_PROPERTYNAME_CREATIONCLASSNAME.getString(),         PEGASUS_CLASSNAME_INDHANDLER_CIMXML.getString());    _addStringProperty(handler01, PEGASUS_PROPERTYNAME_NAME.getString(),        "Handler01");    _addStringProperty(handler01, "Owner", "an owner");    _addUint16Property(handler01,        PEGASUS_PROPERTYNAME_PERSISTENCETYPE.getString(),        PERSISTENCE_PERMANENT);    _addStringProperty(handler01, "OtherPersistenceType", String::EMPTY,        true);    _addStringProperty(handler01,        PEGASUS_PROPERTYNAME_LSTNRDST_DESTINATION.getString(),        "localhost/CIMListener/test1");    path = client.createInstance(NAMESPACE, handler01);    //

⌨️ 快捷键说明

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