CMPIStatus      indProvInvokeMethod
    (CMPIMethodMI * cThis, const CMPIContext *ctx,
     const CMPIResult *rslt, const CMPIObjectPath * cop,
     const char *method, const CMPIArgs * in, CMPIArgs * out) {
  CMPIValue       value;
  fprintf(stderr, "+++ indProvInvokeMethod()\n");

  if (enabled == 0) {
    fprintf(stderr, "+++ PROVIDER NOT ENABLED\n");
  } else {
    generateIndication(method, ctx);
  }

  value.uint32 = 0;
  CMReturnData(rslt, &value, CMPI_uint32);
  CMReturnDone(rslt);
  CMReturn(CMPI_RC_OK);
}
Exemplo n.º 2
0
int _test(CIMClient& client, String& qlang, String& query1, String& query2)
{
    CIMObjectPath Handler1Ref, Handler2Ref;
    CIMObjectPath Filter1Ref, Filter2Ref;
    CIMObjectPath Subscription1Ref, Subscription2Ref;

    try
    {
        Handler1Ref =
            CreateHandler1Instance(client, PEGASUS_NAMESPACENAME_INTEROP);
        Handler2Ref = CreateHandler1Instance(client, NAMESPACE2);
    }
    catch (Exception& e)
    {
        PEGASUS_STD (cerr) << "Exception: " << e.getMessage()
                           << PEGASUS_STD (endl);
        PEGASUS_STD (cerr) << "create handler instance failed"
                           << PEGASUS_STD (endl);
        return -1;
    }

    PEGASUS_STD (cout) << "+++++ handler instances created"
                       << PEGASUS_STD (endl);
    try
    {
      String name1 = "TestFilter01";
      String name2 = "TestFilter02";
      Filter1Ref = CreateFilterInstance (client, query1, qlang, name1,
          PEGASUS_NAMESPACENAME_INTEROP);
      Filter2Ref = CreateFilterInstance (client, query2, qlang, name2,
          NAMESPACE1);
    }
    catch (Exception& e)
    {
        PEGASUS_STD (cerr) << "Exception: " << e.getMessage()
                           << PEGASUS_STD (endl);
        PEGASUS_STD (cerr) << "create filter instances failed"
                           << PEGASUS_STD (endl);
        return -1;
    }

    PEGASUS_STD (cout) << "+++++ filter instances created for "
                       << qlang
                       << PEGASUS_STD (endl);
    try
    {
        Subscription1Ref =
          CreateSbscriptionInstance (client, Handler1Ref, Filter1Ref,
              PEGASUS_NAMESPACENAME_INTEROP);
        Subscription2Ref =
          CreateSbscriptionInstance (client, Handler1Ref, Filter2Ref,
              NAMESPACE3);
    }
    catch (Exception& e)
    {
        PEGASUS_STD (cerr) << "Exception: " << e.getMessage()
                           << PEGASUS_STD (endl);
        PEGASUS_STD (cerr) << "create subscription instance failed"
                           << PEGASUS_STD (endl);
        return -1;
    }

    PEGASUS_STD (cout) << "+++++ subscription instances created"
                       << PEGASUS_STD (endl);

    // get display consumer
    String indicationFile2, oldIndicationFile;

    indicationFile2 = INDICATION_DIR;
    indicationFile2.append("/indicationLog");

    if (FileSystem::exists(indicationFile2))
    {
        oldIndicationFile = INDICATION_DIR;
        oldIndicationFile.append("/oldIndicationFile");
        if (FileSystem::exists(oldIndicationFile))
        {
          FileSystem::removeFile(oldIndicationFile);
        }
        if (!FileSystem::renameFile(indicationFile2, oldIndicationFile))
        {
          FileSystem::removeFile(indicationFile2);
        }
    }

    try
    {
      //
      // generate three indications
      //
      for(Uint8 i = 0; i < 3; i++)
      {
        generateIndication(client);
      }
    }
    catch (Exception& e)
    {
      PEGASUS_STD (cerr) << "Exception: " << e.getMessage()
                         << PEGASUS_STD (endl);
      PEGASUS_STD (cerr) << "generate indication failed"
                         << PEGASUS_STD (endl);
      return -1;
    }

    PEGASUS_STD (cout) << "+++++ indications generated"
                       << PEGASUS_STD (endl);

    System::sleep(5);

    try
    {
      DeleteInstance (client, Subscription1Ref,
                      PEGASUS_NAMESPACENAME_INTEROP);
      DeleteInstance (client, Subscription2Ref, NAMESPACE3);
      DeleteInstance (client, Filter1Ref,
                      PEGASUS_NAMESPACENAME_INTEROP);
      DeleteInstance (client, Filter2Ref, NAMESPACE1);
      DeleteInstance (client, Handler1Ref,
                      PEGASUS_NAMESPACENAME_INTEROP);
      DeleteInstance (client, Handler2Ref, NAMESPACE2);
    }
    catch (Exception& e)
    {
      PEGASUS_STD (cerr) << "Exception: " << e.getMessage()
                         << PEGASUS_STD (endl);
      PEGASUS_STD (cerr) << "delete instance failed"
                         << PEGASUS_STD (endl);
      return -1;
    }

    PEGASUS_STD (cout) << "+++++ instances deleted"
                       << PEGASUS_STD (endl);

    //
    // compare indications with the master output
    //
    String indicationFile, masterFile, indication_failed;

    indicationFile = INDICATION_DIR;
    indicationFile.append("/indicationLog");

    // Get environment variable:
    masterFile = getenv("PEGASUS_ROOT");
    masterFile.append(
        "/src/Pegasus/IndicationService/tests/IndicationProcess/masterOutput");

    if (FileSystem::exists(indicationFile) && FileSystem::exists(masterFile))
    {
      if (FileSystem::compareFiles(indicationFile, masterFile))
      {
        PEGASUS_STD (cout) << "+++++ passed all tests." << PEGASUS_STD (endl);
        // remove indicationFile
        FileSystem::removeFile(indicationFile);
        return 0;
      }
      else
      {
        PEGASUS_STD (cerr) << "----- tests failed" << PEGASUS_STD (endl);
        // rename indicationFile to be indicationLog_FAILED
        // and remove indicationFile
        indication_failed = INDICATION_DIR;
        indication_failed.append("/indicationLog_FAILED");
        FileSystem::renameFile(indicationFile, indication_failed);
        FileSystem::removeFile(indicationFile);
        return 1;
      }
    }
    else
    {
      PEGASUS_STD (cerr) << "----- tests failed" << PEGASUS_STD (endl);
      // rename indicationFile to be indicationFile_FAILED
      // and remove indicationFile
      if (FileSystem::exists(indicationFile))
      {
        indication_failed = INDICATION_DIR;
        indication_failed.append("/indicationLog_FAILED");
        FileSystem::renameFile(indicationFile, indication_failed);
        FileSystem::removeFile(indicationFile);
      }
      return 1;
    }
}