コード例 #1
0
ファイル: DeliveryRetry.cpp プロジェクト: brunolauze/pegasus
void _setup(CIMClient& client)
{
    _createFilterInstance(client, String("DRFilter01"),
        String("SELECT * FROM DeliveryRetryTestClass"), "WQL");

    char hName[256];

    for (Uint32 i = 1; i <= HANDLER_COUNT ; ++i)
    {
        sprintf(hName,"DRHandler%i",i);
        _createHandlerInstance(client, hName,
            String ("http://localhost:2003/CIMListener/DeliveryRetryListener"));
        _createSubscription(client, "DRFilter01", hName);
    }
}
コード例 #2
0
void _setup2 (CIMClient & client, String& qlang)
{
    try
    {
        _createFilterInstance (client, String ("DEFilter02"),
            String ("SELECT MethodName FROM Test_IndicationProviderClass"),
            qlang, NAMESPACE1);
        _createHandlerInstance (client, String ("DEHandler02"), 
            String ("localhost/CIMListener/Pegasus_SimpleDisplayConsumer"),
            NAMESPACE2);
    }
    catch (Exception & e)
    {
        PEGASUS_STD (cerr) << "setup2 failed: " << e.getMessage ()
                           << PEGASUS_STD (endl);
        exit (-1);
    }

    PEGASUS_STD (cout) << "+++++ setup2 completed successfully"
                       << PEGASUS_STD (endl);
}
コード例 #3
0
void _setup (CIMClient & client, const String& qlang)
{
    CIMObjectPath filterObjectPath;
    CIMObjectPath snmpv1HandlerObjectPath;
    CIMObjectPath snmpv2HandlerObjectPath;
    CIMObjectPath snmpv2IPV6HandlerObjectPath;

    try
    {
        filterObjectPath = _createFilterInstance (client, FILTER_NAME,
                           String ("SELECT * FROM Test_IndicationProviderClass"),
                           qlang);
    }
    catch (CIMException& e)
    {
        if (e.getCode() == CIM_ERR_ALREADY_EXISTS)
        {
            filterObjectPath = _getFilterObjectPath(FILTER_NAME);
            cerr << "----- Warning: Filter Instance Not Created: "
                 << e.getMessage () << endl;
        }
        else
        {
            cerr << "----- Error: Filter Instance Not Created: " << endl;
            throw;
        }
    }

    try
    {
        // Create SNMPv1 trap handler
        snmpv1HandlerObjectPath = _createHandlerInstance (client,
                                  SNMPV1_HANDLER_NAME,
                                  System::getFullyQualifiedHostName(),
                                  "",
                                  _HOST_NAME,
                                  _SNMPV1_TRAP);
    }
    catch (CIMException& e)
    {
        if (e.getCode() == CIM_ERR_ALREADY_EXISTS)
        {
            snmpv1HandlerObjectPath = _getHandlerObjectPath(
                                          SNMPV1_HANDLER_NAME);
            cerr << "----- Warning: SNMPv1 Trap Handler Instance Not Created: "
                 << e.getMessage () << endl;
        }
        else
        {
            cerr << "----- Error: SNMPv1 Trap Handler Instance Not Created: "
                 << endl;
            throw;
        }
    }

    try
    {
        _createSubscriptionInstance (client, filterObjectPath,
                                     snmpv1HandlerObjectPath);
    }
    catch (CIMException& e)
    {
        if (e.getCode() == CIM_ERR_ALREADY_EXISTS)
        {
            cerr << "----- Warning: Client Subscription Instance: "
                 << e.getMessage () << endl;
        }
        else
        {
            cerr << "----- Error: Client Subscription Instance: " << endl;
            throw;
        }
    }

    try
    {
        String ipAddress;
        int af;
        System::getHostIP(System::getFullyQualifiedHostName (), &af, ipAddress);
        // Create SNMPv2 trap handler
        snmpv2HandlerObjectPath = _createHandlerInstance (client,
                                  SNMPV2C_HANDLER_NAME,
                                  ipAddress,
                                  "public",
                                  af == AF_INET ? _IPV4_ADDRESS : _IPV6_ADDRESS,
                                  _SNMPV2C_TRAP);
    }
    catch (CIMException& e)
    {
        if (e.getCode() == CIM_ERR_ALREADY_EXISTS)
        {
            snmpv2HandlerObjectPath = _getHandlerObjectPath(
                                          SNMPV2C_HANDLER_NAME);
            cerr << "----- Warning: SNMPv2c Trap Handler Instance Not Created: "
                 << e.getMessage () << endl;
        }
        else
        {
            cerr << "----- Error: SNMPv2c Trap Handler Instance Not Created: "
                 << endl;
            throw;
        }
    }

    try
    {
        _createSubscriptionInstance (client, filterObjectPath,
                                     snmpv2HandlerObjectPath);
    }
    catch (CIMException& e)
    {
        if (e.getCode() == CIM_ERR_ALREADY_EXISTS)
        {
            cerr << "----- Warning: Client Subscription Instance: "
                 << e.getMessage () << endl;
        }
        else
        {
            cerr << "----- Error: Client Subscription Instance: " << endl;
            throw;
        }
    }

#if defined(PEGASUS_ENABLE_IPV6)
    // create a subscription with trap destination of IPV6 address format
    try
    {
        // Create SNMPv2 IPV6 trap handler
        snmpv2IPV6HandlerObjectPath = _createHandlerInstance (client,
                                      SNMPV2C_IPV6_HANDLER_NAME,
                                      String("::1"),
                                      "public",
                                      _IPV6_ADDRESS,
                                      _SNMPV2C_TRAP);
    }
    catch (CIMException& e)
    {
        if (e.getCode() == CIM_ERR_ALREADY_EXISTS)
        {
            snmpv2IPV6HandlerObjectPath = _getHandlerObjectPath(
                                              SNMPV2C_IPV6_HANDLER_NAME);
            cerr << "----- Warning: SNMPv2c IPV6 Trap Handler Instance "
                 "Not Created: " << e.getMessage () << endl;
        }
        else
        {
            cerr << "----- Error: SNMPv2c IPV6 Trap Handler Instance Not "
                 "Created: " << endl;
            throw;
        }
    }

    try
    {
        _createSubscriptionInstance (client, filterObjectPath,
                                     snmpv2IPV6HandlerObjectPath);
    }
    catch (CIMException& e)
    {
        if (e.getCode() == CIM_ERR_ALREADY_EXISTS)
        {
            cerr << "----- Warning: Client Subscription Instance: "
                 << e.getMessage () << endl;
        }
        else
        {
            cerr << "----- Error: Client Subscription Instance: " << endl;
            throw;
        }
    }
#endif
}