Esempio n. 1
0
CIMObjectPath CreateFilterInstance (CIMClient& client,
                                    const String query,
                                    const String qlang,
                                    const String name,
                                    const CIMNamespaceName & filterNS)
{
    CIMInstance filterInstance(PEGASUS_CLASSNAME_INDFILTER);
    filterInstance.addProperty(CIMProperty (CIMName ("SystemCreationClassName"),
        System::getSystemCreationClassName()));
    filterInstance.addProperty(CIMProperty(CIMName ("SystemName"),
        System::getFullyQualifiedHostName()));
    filterInstance.addProperty(CIMProperty(CIMName ("CreationClassName"),
        PEGASUS_CLASSNAME_INDFILTER.getString()));
    filterInstance.addProperty(CIMProperty(CIMName ("Name"),
        String(name)));
    filterInstance.addProperty (CIMProperty(CIMName ("Query"),
        String(query)));
    filterInstance.addProperty (CIMProperty(CIMName ("QueryLanguage"),
        String(qlang)));
    filterInstance.addProperty (CIMProperty(CIMName ("SourceNamespace"),
        String("test/TestProvider")));

    CIMObjectPath Ref = client.createInstance(filterNS, filterInstance);
    Ref.setNameSpace (filterNS);
    return (Ref);
}
Array<CIMObjectPath> PG_TestPropertyTypes::_enumerateInstanceNames(
    const OperationContext& context,
    const CIMObjectPath& classReference)
{
    Array<CIMObjectPath> instanceNames;

    // get class definition from repository
    CIMClass cimclass = _cimom.getClass(
        context,
        classReference.getNameSpace(),
        classReference.getClassName(),
        false,
        true,
        true,
        CIMPropertyList());

    // convert instances to references;
    for (Uint32 i = 0; i < _instances.size(); i++)
    {
        CIMObjectPath tempRef = _instances[i].buildPath(cimclass);

        // ensure references are fully qualified
        tempRef.setHost(classReference.getHost());
        tempRef.setNameSpace(classReference.getNameSpace());

        instanceNames.append(tempRef);
    }

    return instanceNames;
}
Esempio n. 3
0
// This method calls CMPIProviderManager::handleInvokeMethodRequest and
// 'if(rc.rc != CMPI_RC_OK)' condition  in CMPIProviderManager.cpp succeeds.
void _testMethodError(CIMClient & client)
{
    CIMObjectPath instanceName;
    instanceName.setNameSpace (providerNamespace);
    instanceName.setClassName (CMPI_TEST_FAIL);

    Array < CIMParamValue > inParams;
    Array < CIMParamValue > outParams;
    Boolean caughtException;

    caughtException = false;
    try
    {
        CIMValue retValue = client.invokeMethod(
             providerNamespace,
             instanceName,
             "test",
             inParams,
             outParams);
    }
    catch (const CIMException &e)
    {
        if (e.getCode() == CIM_ERR_NOT_SUPPORTED)
        {
            caughtException = true;
        }
    }
    PEGASUS_TEST_ASSERT (caughtException);
}
Esempio n. 4
0
IndicationStressTestProvider::IndicationStressTestProvider (void) throw ()
{
  // Set the destination of indications for all threads once

            path.setNameSpace("test/TestProvider");
            path.setClassName("IndicationStressTestClass");
}
Esempio n. 5
0
void
test06 (CIMClient & client)
{
  CIMObjectPath instanceName;
  Uint32 exception  =0;
  instanceName.setNameSpace (providerNamespace);
  instanceName.setClassName (CLASSNAME);

  Array < CIMParamValue > inParams;
  Array < CIMParamValue > outParams;

  /*     String returnDateTime(); */
  try {
  CIMValue retValue = client.invokeMethod (providerNamespace,
                       instanceName,
                       "noSuchFunction",
                       inParams,
                       outParams);
  } catch (const CIMException &e)
  {
      exception ++;
    PEGASUS_TEST_ASSERT (e.getCode() == CIM_ERR_NOT_FOUND);
  }
  PEGASUS_TEST_ASSERT (exception == 1);
}
Esempio n. 6
0
void
test04 (CIMClient & client)
{
  CIMObjectPath instanceName;

  instanceName.setNameSpace (providerNamespace);
  instanceName.setClassName (CLASSNAME);

  Array < CIMParamValue > inParams;
  Array < CIMParamValue > outParams;

  /*     [EmbeddedObject] String returnInstance(); */

  CIMValue retValue = client.invokeMethod (providerNamespace,
                       instanceName,
                       "returnInstance",
                       inParams,
                       outParams);

  PEGASUS_TEST_ASSERT (retValue.getType () == CIMTYPE_OBJECT);
  PEGASUS_TEST_ASSERT (!retValue.isArray ());
  PEGASUS_TEST_ASSERT (!retValue.isNull ());

  CIMObject result;
  retValue.get (result);

  CIMObjectPath objPath  = result.getPath();
  PEGASUS_TEST_ASSERT (objPath.toString() == "TestCMPI_Instance");

}
Esempio n. 7
0
void _testHostedIndicationServiceInstance(CIMClient &client)
{
    cout << "Testing Association Class "
        << (const char *)PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE.
             getString().getCString()
        << "...";
    // Get PG_HostedIndicationService Instances
    Array<CIMInstance> hostedInstances = client.enumerateInstances(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE);
    PEGASUS_TEST_ASSERT(hostedInstances.size() == 1);

    // Get PG_HostedIndicationService Instance names
    Array<CIMObjectPath> hostedPaths = client.enumerateInstanceNames(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE);
    PEGASUS_TEST_ASSERT(hostedPaths.size() == 1);

    // Get CIM_IndicationService instance names
    Array<CIMObjectPath> servicePaths = client.enumerateInstanceNames(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE);
    PEGASUS_TEST_ASSERT(servicePaths.size() == 1);

    // Test the CIM_IndicationService value.
    CIMValue capValue = hostedInstances[0].getProperty(
        hostedInstances[0].findProperty("Dependent")).getValue();
    CIMObjectPath testPath;
    capValue.get(testPath);
    testPath.setNameSpace(CIMNamespaceName());
    PEGASUS_TEST_ASSERT(testPath.identical(servicePaths[0]));

    cout << "Test Complete" << endl;
}
Esempio n. 8
0
void _testElementCapabilityInstance(CIMClient &client)
{
    cout << "Testing Association Class "
        << (const char *)PEGASUS_CLASSNAME_CIM_INDICATIONSERVICECAPABILITIES.
             getString().getCString()
        << "...";

    // Get CIM_IndicationServiceCapabilities instance names
    Array<CIMObjectPath> capPaths = client.enumerateInstanceNames(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_CIM_INDICATIONSERVICECAPABILITIES);
    PEGASUS_TEST_ASSERT(capPaths.size() == 1);

    // Get CIM_IndicationService instance names
    Array<CIMObjectPath> servicePaths = client.enumerateInstanceNames(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE);
    PEGASUS_TEST_ASSERT(servicePaths.size() == 1);


    // Get PG_ElementCapabilities instances
    Array<CIMInstance> eleInstances = client.enumerateInstances(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_PG_ELEMENTCAPABILITIES);
    PEGASUS_TEST_ASSERT(eleInstances.size() == 1);

    // Test PG_ElementCapabilities instance.
    CIMValue capValue = eleInstances[0].getProperty(
        eleInstances[0].findProperty("Capabilities")).getValue();

    CIMValue meValue = eleInstances[0].getProperty(
        eleInstances[0].findProperty("ManagedElement")).getValue();

    // Now test the instance names of CIM_IndicationService instance and
    // CIM_IndicationServiceCapabilities instance.
    CIMObjectPath testPath;
    capValue.get(testPath);
    testPath.setNameSpace(CIMNamespaceName());
    PEGASUS_TEST_ASSERT(testPath.identical(capPaths[0]));

    meValue.get(testPath);
    testPath.setNameSpace(CIMNamespaceName());
    PEGASUS_TEST_ASSERT(testPath.identical(servicePaths[0]));

    cout << "Test Complete" << endl;
}
Esempio n. 9
0
    static CMPIEnumeration* mbReferenceNames(
        const CMPIBroker *mb,
        const CMPIContext *ctx,
        const CMPIObjectPath *cop,
        const char *resultClass,
        const char *role,
        CMPIStatus *rc)
    {
        PEG_METHOD_ENTER(
            TRC_CMPIPROVIDERINTERFACE,
            "CMPI_Broker:mbReferenceNames()");
        mb = CM_BROKER;
        //  ATTN-CAKG-P2-20020726:  The following condition does not correctly
        //  distinguish instanceNames from classNames in every case
        //  The instanceName of a singleton instance of a keyless class has no
        //  key bindings
        if (!SCMO_ObjectPath(cop)->getKeyBindingCount())
        {
            CMSetStatus(rc, CMPI_RC_ERR_FAILED);
            PEG_METHOD_EXIT();
            return 0;
        }

        SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
        CIMObjectPath qop;
        try
        {
            scmoObjPath->getCIMObjectPath(qop);
            // For compatibility with previous implementations have empty ns
            qop.setNameSpace(CIMNamespaceName());

            CIMResponseData resData =
                CM_CIMOM(mb)->referenceNames(
                    *CM_Context(ctx),
                    scmoObjPath->getNameSpace(),
                    qop,
                    resultClass ? CIMName(resultClass) : CIMName(),
                    role ? String(role) : String::EMPTY);

            // Add the namespace from the input parameters when neccessary
            resData.completeNamespace(scmoObjPath);

            Array<SCMOInstance>* aRef =
                new Array<SCMOInstance>(resData.getSCMO());

            CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>(
                new CMPI_Object(new CMPI_OpEnumeration(aRef)));
            CMSetStatus(rc,CMPI_RC_OK);
            PEG_METHOD_EXIT();
            return cmpiEnum;
        }
        HandlerCatchSetStatus(rc, NULL);

        // Code flow should never get here.
    }
Esempio n. 10
0
void _createDuplicate(CIMClient &client,
    const String &filterHost,
    const CIMNamespaceName &filterNameSpace,
    CIMObjectPath &filterPath,
    const String &handlerHost,
    const CIMNamespaceName &handlerNameSpace,
    CIMObjectPath &handlerPath)
{
    Boolean exceptionCaught = false;
    //
    //  Set Host and Namespace in filter CIMObjectPath
    //
    filterPath.setHost(filterHost);
    filterPath.setNameSpace(filterNameSpace);

    //
    //  Set Host and Namespace in handler CIMObjectPath
    //
    handlerPath.setHost (handlerHost);
    handlerPath.setNameSpace (handlerNameSpace);

    try
    {
        CreateSbscriptionInstance(client, handlerPath,
            filterPath, PEGASUS_NAMESPACENAME_INTEROP);
    }
    catch (CIMException &e)
    {
        if (e.getCode() != CIM_ERR_ALREADY_EXISTS)
        {
            PEGASUS_TEST_ASSERT(0);
        }
        exceptionCaught =  true;
    }
    PEGASUS_TEST_ASSERT(exceptionCaught);
}
Esempio n. 11
0
void
test08 (CIMClient & client)
{
  CIMObjectPath instanceName;
  instanceName.setNameSpace (providerNamespace);
  instanceName.setClassName (CLASSNAME);

  Array < CIMParamValue > inParams;
  Array < CIMParamValue > outParams;

  inParams.append (CIMParamValue ("Operation", CIMValue (Uint64 (1))));
  CIMValue retValue = client.invokeMethod (providerNamespace,
                       instanceName,
                       "TestCMPIBroker",
                       inParams,
                       outParams);
    _checkUint32Value (retValue, 1);
}
Esempio n. 12
0
void test1 (CIMClient &client)
{
    CIMObjectPath instanceName;
    CIMValue output;
    instanceName.setNameSpace (providerNamespace);
    instanceName.setClassName (CLASSNAME);

    Array < CIMParamValue > inParams;
    Array < CIMParamValue > outParams;

    CIMValue retValue = client.invokeMethod (providerNamespace,
        instanceName,
        "testBrokerServices",
        inParams,
        outParams);

    _checkUint32Value (retValue, 1);
}
Esempio n. 13
0
CIMObjectPath CreateSbscriptionInstance (CIMClient& client,
    const CIMObjectPath handlerRef,
    const CIMObjectPath filterRef,
    const CIMNamespaceName & subscriptionNS)
{
    CIMInstance subscriptionInstance
        (PEGASUS_CLASSNAME_INDSUBSCRIPTION);
    subscriptionInstance.addProperty(CIMProperty(CIMName ("Filter"),
        filterRef, 0, PEGASUS_CLASSNAME_INDFILTER));
    subscriptionInstance.addProperty(CIMProperty(CIMName ("Handler"),
        handlerRef, 0, PEGASUS_CLASSNAME_INDHANDLER_CIMXML));
    subscriptionInstance.addProperty (CIMProperty
        (CIMName ("SubscriptionState"), CIMValue ((Uint16) 2)));

    CIMObjectPath Ref = client.createInstance(subscriptionNS,
        subscriptionInstance);
    Ref.setNameSpace (subscriptionNS);
    return (Ref);
}
Esempio n. 14
0
void _checkSubscriptionCount(CIMClient &client)
{
    CIMObjectPath path;
    path.setNameSpace("test/TestProvider");
    path.setClassName("Test_IndicationProviderClass");

    Array<CIMParamValue> inParams;
    Array<CIMParamValue> outParams;

    CIMValue ret_value = client.invokeMethod(
        "test/TestProvider",
        path,
        "GetSubscriptionCount",
        inParams,
        outParams);
    Uint32 n;
    ret_value.get(n);
    PEGASUS_TEST_ASSERT( n == 1);
}
Esempio n. 15
0
CIMObjectPath CreateHandler1Instance (CIMClient& client,
    const CIMNamespaceName & handlerNS)
{
    CIMInstance handlerInstance(PEGASUS_CLASSNAME_INDHANDLER_CIMXML);
    handlerInstance.addProperty(CIMProperty (CIMName("SystemCreationClassName"),
        System::getSystemCreationClassName()));
    handlerInstance.addProperty(CIMProperty(CIMName ("SystemName"),
        System::getFullyQualifiedHostName()));
    handlerInstance.addProperty(CIMProperty(CIMName ("CreationClassName"),
        PEGASUS_CLASSNAME_INDHANDLER_CIMXML.getString()));
    handlerInstance.addProperty(CIMProperty(CIMName ("Name"),
        String("Handler1")));
    handlerInstance.addProperty(CIMProperty(CIMName ("Destination"),
        String("localhost/CIMListener/Pegasus_SimpleDisplayConsumer")));

    CIMObjectPath Ref = client.createInstance(handlerNS, handlerInstance);
    Ref.setNameSpace (handlerNS);
    return (Ref);
}
Esempio n. 16
0
void generateIndication(CIMClient& client)
{
    CIMInstance indicationInstance(CIMName("Test_IndicationProviderClass"));

    CIMObjectPath path ;
    path.setNameSpace("test/TestProvider");
    path.setClassName("Test_IndicationProviderClass");

    indicationInstance.setPath(path);

    Array<CIMParamValue> inParams;
    Array<CIMParamValue> outParams;

    CIMValue ret_value = client.invokeMethod(
        "test/TestProvider",
        path,
        "SendTestIndication",
        inParams,
        outParams);
}
Esempio n. 17
0
void
test01 (CIMClient & client)
{
  CIMObjectPath instanceName;

  instanceName.setNameSpace (providerNamespace);
  instanceName.setClassName (CLASSNAME);

  Array < CIMParamValue > inParams;
  Array < CIMParamValue > outParams;

  /*     String returnUint32(); */

  CIMValue retValue = client.invokeMethod (providerNamespace,
                       instanceName,
                       "returnUint32",
                       inParams,
                       outParams);
  _checkUint32Value (retValue, 42);
}
CIMObjectPath _buildFilterOrHandlerPath
    (const CIMName & className,
     const String & name,
     const CIMNamespaceName & namespaceName = CIMNamespaceName ())
{
    CIMObjectPath path;

    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;
}
Esempio n. 19
0
void
test05 (CIMClient & client)
{
  CIMObjectPath instanceName;

  instanceName.setNameSpace (providerNamespace);
  instanceName.setClassName (CLASSNAME);

  Array < CIMParamValue > inParams;
  Array < CIMParamValue > outParams;

  /*     String returnDateTime(); */

  CIMValue retValue = client.invokeMethod (providerNamespace,
                       instanceName,
                       "returnDateTime",
                       inParams,
                       outParams);
  PEGASUS_TEST_ASSERT (retValue.getType () == CIMTYPE_DATETIME);
  PEGASUS_TEST_ASSERT (!retValue.isArray ());
  PEGASUS_TEST_ASSERT (!retValue.isNull ());

}
Esempio n. 20
0
void test1 (CIMClient &client)
{
    CIMObjectPath instanceName;
    CIMValue output;
    instanceName.setNameSpace (providerNamespace);
    instanceName.setClassName (CLASSNAME);

    Array < CIMParamValue > inParams;
    Array < CIMParamValue > outParams;

    AcceptLanguageList accLangs;
    accLangs.insert(LanguageTag("en-US"),1.0);
    accLangs.insert(LanguageTag("fr"),0.8);
    client.setRequestAcceptLanguages(accLangs);

    CIMValue retValue = client.invokeMethod (providerNamespace,
        instanceName,
        "testBrokerEnc",
        inParams,
        outParams);

    _checkUint32Value (retValue, 1);
}
void _generateIndication (
    IndicationResponseHandler * handler,
    const String & identifier)
{
    if (_enabled)
    {
        CIMInstance indicationInstance (CIMName ("FailureTestIndication"));

        CIMObjectPath path;
        path.setNameSpace ("test/testProvider");
        path.setClassName ("FailureTestIndication");

        indicationInstance.setPath (path);

        indicationInstance.addProperty
            (CIMProperty ("IndicationIdentifier", identifier));

        CIMDateTime currentDateTime = CIMDateTime::getCurrentDateTime ();
        indicationInstance.addProperty
            (CIMProperty ("IndicationTime", currentDateTime));

        Array <String> correlatedIndications;
        indicationInstance.addProperty
            (CIMProperty ("CorrelatedIndications", correlatedIndications));

        indicationInstance.addProperty
            (CIMProperty ("Description", String ("Failure Test Indication")));

        indicationInstance.addProperty
            (CIMProperty ("AlertingManagedElement",
            System::getFullyQualifiedHostName ()));

        indicationInstance.addProperty
            (CIMProperty ("AlertingElementFormat", Uint16 (0)));

        indicationInstance.addProperty
            (CIMProperty ("AlertType", Uint16 (1)));

        indicationInstance.addProperty
            (CIMProperty ("OtherAlertType", String ("Test")));

        indicationInstance.addProperty
            (CIMProperty ("PerceivedSeverity", Uint16 (2)));

        indicationInstance.addProperty
            (CIMProperty ("ProbableCause", Uint16 (1)));

        indicationInstance.addProperty
            (CIMProperty ("ProbableCauseDescription", String ("Test")));

        indicationInstance.addProperty
            (CIMProperty ("Trending", Uint16 (4)));

        Array <String> recommendedActions;
        recommendedActions.append ("Test");
        indicationInstance.addProperty
            (CIMProperty ("RecommendedActions", recommendedActions));

        indicationInstance.addProperty
            (CIMProperty ("EventID", String ("Test")));

        CIMDateTime eventTime = CIMDateTime::getCurrentDateTime ();
        indicationInstance.addProperty
            (CIMProperty ("EventTime", eventTime));

        indicationInstance.addProperty
            (CIMProperty ("SystemCreationClassName",
            System::getSystemCreationClassName ()));

        indicationInstance.addProperty
            (CIMProperty ("SystemName",
            System::getFullyQualifiedHostName ()));

        indicationInstance.addProperty
            (CIMProperty ("ProviderName", _providerName));

        CIMIndication cimIndication (indicationInstance);

        handler->deliver (cimIndication);
    }
}
Esempio n. 22
0
void TestCreateInstances(CIMClient& client)
{
    //
    // Test create Provider module instances
    //
    CIMObjectPath returnRef;

    CIMClass cimClass(CLASSNAME);

    CIMInstance cimInstance(CLASSNAME);

    cimInstance.addProperty(CIMProperty(CIMName ("Name"), 
        String("providersModule1")));
    cimInstance.addProperty(CIMProperty(CIMName ("Vendor"), String("HP")));
    cimInstance.addProperty(CIMProperty(CIMName ("Version"), String("2.0")));
    cimInstance.addProperty(CIMProperty(CIMName ("InterfaceType"), 
        String("C++Default")));
    cimInstance.addProperty(CIMProperty(CIMName ("InterfaceVersion"), 
        String("2.1.0")));
    cimInstance.addProperty(CIMProperty(CIMName ("Location"), 
        String("/tmp/module1")));

    CIMObjectPath instanceName = cimInstance.buildPath(cimClass);

    instanceName.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP);
    instanceName.setClassName(CLASSNAME);

    try
    {
        returnRef = client.createInstance(PEGASUS_NAMESPACENAME_INTEROP, cimInstance);
    }
    catch(const CIMException&)
    {
        throw;
    }

    // Test create PG_Provider instances

    CIMObjectPath returnRef2;

    CIMClass cimClass2(CLASSNAME2);

    CIMInstance cimInstance2(CLASSNAME2);

    cimInstance2.addProperty(CIMProperty(CIMName ("ProviderModuleName"), 
        String("providersModule1")));
    cimInstance2.addProperty(CIMProperty(CIMName ("Name"), 
        String("PG_ProviderInstance1")));

    CIMObjectPath instanceName2 = cimInstance2.buildPath(cimClass2);

    instanceName2.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP);
    instanceName2.setClassName(CLASSNAME2);

    try
    {
        returnRef2 = client.createInstance(PEGASUS_NAMESPACENAME_INTEROP, cimInstance2);
    }
    catch(const CIMException&)
    {
        throw;
    }

    //
    // test create provider capability instances
    //

    Array <String> namespaces;
    Array <Uint16> providerType;
    Array <String> supportedMethods;
    Array <String> supportedProperties;

    namespaces.append("root/cimv2");
    namespaces.append("root/cimv3");
    
    providerType.append(4);
    providerType.append(5);

    supportedMethods.append("test_method1");
    supportedMethods.append("test_method2");

    supportedProperties.append("PkgStatus");
    supportedProperties.append("PkgIndex");

    CIMObjectPath returnRef3;

    CIMClass cimClass3(CLASSNAME3);

    CIMInstance cimInstance3(CLASSNAME3);

    cimInstance3.addProperty(CIMProperty(CIMName ("ProviderModuleName"), 
        String("providersModule1")));
    cimInstance3.addProperty(CIMProperty(CIMName ("ProviderName"), 
        String("PG_ProviderInstance1")));
    cimInstance3.addProperty(CIMProperty(CIMName ("CapabilityID"), 
        String("capability1")));
    cimInstance3.addProperty(CIMProperty(CIMName ("ClassName"), 
        String("TestSoftwarePkg")));
    cimInstance3.addProperty(CIMProperty(CIMName ("Namespaces"), namespaces));
    cimInstance3.addProperty(CIMProperty(CIMName ("ProviderType"), 
        providerType));
    cimInstance3.addProperty(CIMProperty(CIMName ("SupportedMethods"), 
        supportedMethods));
    cimInstance3.addProperty(CIMProperty(CIMName ("SupportedProperties"), 
        supportedProperties));

    CIMObjectPath instanceName3 = cimInstance3.buildPath(cimClass3);

    instanceName3.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP);
    instanceName3.setClassName(CLASSNAME3);

    try
    {
        returnRef3 = client.createInstance(PEGASUS_NAMESPACENAME_INTEROP, cimInstance3);
    }
    catch(const CIMException&)
    {
        throw;
    }

    CIMKeyBinding kb1(CIMName ("Name"), "providersModule1", 
        CIMKeyBinding::STRING);
    Array<CIMKeyBinding> keys;
    keys.append(kb1);

    instanceName.setKeyBindings(keys);

    // test getInstance
    try
    {
    	client.getInstance(PEGASUS_NAMESPACENAME_INTEROP, instanceName);
    }
    catch(const CIMException&)
    {
        throw;
    }

    // test enumerateInstances
    try
    {
    	client.enumerateInstances(PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PROVIDER);
    }
    catch(const CIMException&)
    {
        throw;
    }

    // test enumerateInstanceNames
    try
    {
    	client.enumerateInstanceNames(PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PROVIDER);
    }
    catch(const CIMException&)
    {
        throw;
    }


    client.deleteInstance(PEGASUS_NAMESPACENAME_INTEROP, instanceName);
}
Esempio n. 23
0
void _generateIndication (
    IndicationResponseHandler * handler,
    const CIMName methodName)
{
    if (_enabled)
    {
        CIMInstance indicationInstance;

        if (methodName.equal ("SendTestIndicationSubclass"))
        {
            CIMInstance theIndication (CIMName ("RT_TestIndicationSubclass"));
            indicationInstance = theIndication;
        }
        else
        {
            CIMInstance theIndication (CIMName ("RT_TestIndication"));
            indicationInstance = theIndication;
        }

        CIMObjectPath path;
        if (methodName.equal ("SendTestIndicationUnmatchingNamespace"))
        {
            //
            //  For SendTestIndicationUnmatchingNamespace, generate an
            //  indication instance with namespace that does not match the
            //  subscription instance name included in the operation context
            //  (nor does it match the namespace for which provider has
            //  registered)
            //
            path.setNameSpace ("root/cimv2");
            path.setClassName ("RT_TestIndication");
        }
        else if (methodName.equal ("SendTestIndicationUnmatchingClassName"))
        {
            // the indication class name and object path class must match
            indicationInstance = CIMInstance("CIM_AlertIndication");

            //
            //  For SendTestIndicationUnmatchingClassName, generate an
            //  indication instance with classname that does not match the
            //  subscription instance name included in the operation context
            //  (nor does it match the classname for which provider has
            //  registered)
            //
            path.setNameSpace ("root/SampleProvider");
            path.setClassName ("CIM_AlertIndication");
        }
        else if (methodName.equal ("SendTestIndicationSubclass"))
        {
            //
            //  For SendTestIndicationSubclass, generate an indication instance
            //  of a the RT_TestIndicationSubclass subclass
            //
            path.setNameSpace ("root/SampleProvider");
            path.setClassName ("RT_TestIndicationSubclass");
        }
        else
        {
            path.setNameSpace("root/SampleProvider");
            path.setClassName("RT_TestIndication");
        }

        indicationInstance.setPath(path);

        char buffer[32];
        sprintf(buffer, "%d", _nextUID++);
        indicationInstance.addProperty
            (CIMProperty ("IndicationIdentifier",String(buffer)));

	CIMDateTime currentDateTime = CIMDateTime::getCurrentDateTime ();
	indicationInstance.addProperty
            (CIMProperty ("IndicationTime", currentDateTime));

        //
        //  For SendTestIndicationMissingProperty, leave out the
        //  CorrelatedIndications property
        //
        if (!methodName.equal ("SendTestIndicationMissingProperty"))
        {
	    Array <String> correlatedIndications;
	    indicationInstance.addProperty
                (CIMProperty ("CorrelatedIndications", correlatedIndications));
        }

        if ((methodName.equal ("SendTestIndicationNormal")) ||
            (methodName.equal ("SendTestIndicationSubclass")) ||
            (methodName.equal ("SendTestIndicationMissingProperty")) ||
            (methodName.equal ("SendTestIndicationExtraProperty")) ||
            (methodName.equal ("SendTestIndicationMatchingInstance")) ||
            (methodName.equal ("SendTestIndicationUnmatchingNamespace")) ||
            (methodName.equal ("SendTestIndicationUnmatchingClassName")))
        {
            indicationInstance.addProperty
                (CIMProperty ("MethodName", CIMValue (methodName.getString())));
        }
        else
        {
            indicationInstance.addProperty
                (CIMProperty ("MethodName",
                    CIMValue (String ("generateIndication"))));
        }

        //
        //  For SendTestIndicationExtraProperty, add an extra property,
        //  ExtraProperty, that is not a member of the indication class
        //
        if (methodName.equal ("SendTestIndicationExtraProperty"))
        {
            indicationInstance.addProperty
                (CIMProperty ("ExtraProperty",
                    CIMValue (String ("extraProperty"))));
        }

        CIMIndication cimIndication (indicationInstance);

        //
        //  For SendTestIndicationSubclass,
        //  SendTestIndicationMatchingInstance,
        //  SendTestIndicationUnmatchingNamespace or
        //  SendTestIndicationUnmatchingClassName, include
        //  SubscriptionInstanceNamesContainer in operation context
        //
        if ((methodName.equal ("SendTestIndicationSubclass")) ||
            (methodName.equal ("SendTestIndicationMatchingInstance")) ||
            (methodName.equal ("SendTestIndicationUnmatchingNamespace")) ||
            (methodName.equal ("SendTestIndicationUnmatchingClassName")))
        {
            Array <CIMObjectPath> subscriptionInstanceNames;
            Array <CIMKeyBinding> subscriptionKeyBindings;

            String filterString;
            filterString.append ("CIM_IndicationFilter.CreationClassName=\"CIM_IndicationFilter\",Name=\"PIFilter01\",SystemCreationClassName=\"");
            filterString.append (System::getSystemCreationClassName ());
            filterString.append ("\",SystemName=\"");
            filterString.append (System::getFullyQualifiedHostName ());
            filterString.append ("\"");
            subscriptionKeyBindings.append (CIMKeyBinding ("Filter",
                filterString, CIMKeyBinding::REFERENCE));

            String handlerString;
            handlerString.append ("CIM_IndicationHandlerCIMXML.CreationClassName=\"CIM_IndicationHandlerCIMXML\",Name=\"PIHandler01\",SystemCreationClassName=\"");
            handlerString.append (System::getSystemCreationClassName ());
            handlerString.append ("\",SystemName=\"");
            handlerString.append (System::getFullyQualifiedHostName ());
            handlerString.append ("\"");
            subscriptionKeyBindings.append (CIMKeyBinding ("Handler",
                handlerString, CIMKeyBinding::REFERENCE));

            CIMObjectPath subscriptionPath ("",
                CIMNamespaceName ("root/PG_InterOp"),
                CIMName ("CIM_IndicationSubscription"),
                subscriptionKeyBindings);
            subscriptionInstanceNames.append (subscriptionPath);

	    OperationContext context;
            context.insert (SubscriptionInstanceNamesContainer
                (subscriptionInstanceNames));

            handler->deliver (context, indicationInstance);
        }
        else
        {
	    // deliver an indication without trapOid
            handler->deliver (indicationInstance);
        }

        //
        //  Only deliver extra indication with trapOid for SendTestIndication
        //
        if ((!methodName.equal ("SendTestIndicationNormal")) &&
            (!methodName.equal ("SendTestIndicationSubclass")) &&
            (!methodName.equal ("SendTestIndicationMissingProperty")) &&
            (!methodName.equal ("SendTestIndicationExtraProperty")) &&
            (!methodName.equal ("SendTestIndicationMatchingInstance")) &&
            (!methodName.equal ("SendTestIndicationUnmatchingNamespace")) &&
            (!methodName.equal ("SendTestIndicationUnmatchingClassName")))
        {
	    // deliver another indication with a trapOid which contains in the
	    // operationContext container
	    OperationContext context;

 	    // add trap OID to the context
	    context.insert
                (SnmpTrapOidContainer("1.3.6.1.4.1.900.2.3.9002.9600"));
            handler->deliver (context, indicationInstance);
        }
    }
}
Esempio n. 24
0
void TestModifyInstances(ProviderRegistrationManager & prmanager)
{
    //
    // create Provider module instances
    //
    CIMObjectPath returnRef;

    CIMClass cimClass(CLASSNAME);

    CIMInstance cimInstance(CLASSNAME);

    cimInstance.addProperty(CIMProperty(CIMName ("Name"), String("providersModule1")));
    cimInstance.addProperty(CIMProperty(CIMName ("Vendor"), String("HP")));
    cimInstance.addProperty(CIMProperty(CIMName ("Version"), String("2.0")));
    cimInstance.addProperty(CIMProperty(CIMName ("InterfaceType"), String("PG_DefaultC++")));
    cimInstance.addProperty(CIMProperty(CIMName ("InterfaceVersion"), String("2.0")));
    cimInstance.addProperty(CIMProperty(CIMName ("Location"), String("/tmp/module1")));

    CIMObjectPath instanceName = cimInstance.buildPath(cimClass);

    instanceName.setNameSpace(NAMESPACE);
    instanceName.setClassName(CLASSNAME);

    try
    {
        returnRef = prmanager.createInstance(instanceName, cimInstance);
    }
    catch(CIMException& e)
    {
	throw (e);
    }

    // create PG_Provider instances

    CIMObjectPath returnRef2;

    CIMClass cimClass2(CLASSNAME2);

    CIMInstance cimInstance2(CLASSNAME2);

    cimInstance2.addProperty(CIMProperty(CIMName ("ProviderModuleName"), String("providersModule1")));
    cimInstance2.addProperty(CIMProperty(CIMName ("Name"), String("PG_ProviderInstance1")));

    CIMObjectPath instanceName2 = cimInstance2.buildPath(cimClass2);

    instanceName2.setNameSpace(NAMESPACE);
    instanceName2.setClassName(CLASSNAME2);

    try
    {
	returnRef2 = prmanager.createInstance(instanceName2, cimInstance2);
    }
    catch(CIMException& e)
    {
        throw (e);
    }

    //
    // create provider capability instances
    //

    Array <String> namespaces;
    Array <Uint16> providerType;
    Array <String> supportedMethods;
    Array <String> supportedProperties;

    namespaces.append("root/cimv2");
    namespaces.append("root/cimv3");

    providerType.append(2);
    providerType.append(5);

    supportedMethods.append("test_method1");
    supportedMethods.append("test_method2");

    supportedProperties.append("PkgStatus");
    supportedProperties.append("PkgIndex");

    CIMObjectPath returnRef3;

    CIMClass cimClass3(CLASSNAME3);

    CIMInstance cimInstance3(CLASSNAME3);

    cimInstance3.addProperty(CIMProperty(CIMName ("ProviderModuleName"), String("providersModule1")));
    cimInstance3.addProperty(CIMProperty(CIMName ("ProviderName"), String("PG_ProviderInstance1")));
    cimInstance3.addProperty(CIMProperty(CIMName ("CapabilityID"), String("capability1")));
    cimInstance3.addProperty(CIMProperty(CIMName ("ClassName"), String("TestSoftwarePkg")));
    cimInstance3.addProperty(CIMProperty(CIMName ("Namespaces"), namespaces));
    cimInstance3.addProperty(CIMProperty(CIMName ("ProviderType"), providerType));
    cimInstance3.addProperty(CIMProperty(CIMName ("SupportedMethods"), supportedMethods));
    cimInstance3.addProperty(CIMProperty(CIMName ("SupportedProperties"), supportedProperties));

    CIMObjectPath instanceName3 = cimInstance3.buildPath(cimClass3);

    instanceName3.setNameSpace(NAMESPACE);
    instanceName3.setClassName(CLASSNAME3);

    try
    {
        returnRef3 = prmanager.createInstance(instanceName3, cimInstance3);
    }
    catch(const CIMException&)
    {
        throw;
    }

    // create CIMObjectPath
    Array<CIMKeyBinding> keys;
    CIMKeyBinding kb1(CIMName ("ProviderModuleName"), "providersModule1",
        CIMKeyBinding::STRING);
    CIMKeyBinding kb2(CIMName ("ProviderName"), "PG_ProviderInstance1",
        CIMKeyBinding::STRING);
    CIMKeyBinding kb3(CIMName ("CapabilityID"), "capability1",
        CIMKeyBinding::STRING);

    keys.append(kb1);
    keys.append(kb2);
    keys.append(kb3);

    instanceName3.setKeyBindings(keys);

    Array <String> supportedMethods2;
    Array <String> namespaces2;
    Array<CIMName> propertyList;

    // create new instance which will replace cimInstance3
    CIMInstance cimInstance4(CLASSNAME3);
    namespaces2.append("root/cimv4");
    namespaces2.append("root/cimv5");

    supportedMethods2.append("test_method2");
    supportedMethods2.append("test_method3");

    cimInstance4.addProperty(CIMProperty(CIMName ("Namespaces"), namespaces2));
    cimInstance4.addProperty(CIMProperty(CIMName ("SupportedMethods"), supportedMethods2));

    propertyList.append(CIMName ("Namespaces"));
    propertyList.append(CIMName ("SupportedMethods"));

    try
    {
        prmanager.modifyInstance(instanceName3, cimInstance4, false, propertyList);
    }
    catch(const CIMException&)
    {
        throw;
    }
}
Esempio n. 25
0
    static CMPIEnumeration* mbAssociators(
        const CMPIBroker *mb,
        const CMPIContext *ctx,
        const CMPIObjectPath *cop,
        const char *assocClass,
        const char *resultClass,
        const char *role,
        const char *resultRole,
        const char **properties,
        CMPIStatus *rc)
    {
        PEG_METHOD_ENTER(
            TRC_CMPIPROVIDERINTERFACE,
            "CMPI_Broker:mbAssociators()");
        mb = CM_BROKER;
        //  ATTN-CAKG-P2-20020726:  The following condition does not correctly
        //  distinguish instanceNames from classNames in every case
        //  The instanceName of a singleton instance of a keyless class has no
        //  key bindings
        if (!SCMO_ObjectPath(cop)->getKeyBindingCount())
        {
            CMSetStatus(rc, CMPI_RC_ERR_FAILED);
            PEG_METHOD_EXIT();
            return 0;
        }
        CMPIFlags flgs =
            ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32;
        const CIMPropertyList props = getList(properties);

        SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
        CIMObjectPath qop;
        try
        {
            scmoObjPath->getCIMObjectPath(qop);
            // For compatibility with previous implementations have empty ns
            qop.setNameSpace(CIMNamespaceName());

            CIMResponseData resData =
                CM_CIMOM(mb)->associators(
                    *CM_Context(ctx),
                    SCMO_ObjectPath(cop)->getNameSpace(),
                    qop,
                    assocClass ? CIMName(assocClass) : CIMName(),
                    resultClass ? CIMName(resultClass) : CIMName(),
                    role ? String(role) : String::EMPTY,
                    resultRole ? String(resultRole) : String::EMPTY,
                    CM_IncludeQualifiers(flgs),
                    CM_ClassOrigin(flgs),
                    props);

            // When running out of process the returned instances don't contain
            // a namespace.
            // Add the namespace from the input parameters where neccessary
            resData.completeNamespace(scmoObjPath);

            Array<SCMOInstance>* aObj =
                new Array<SCMOInstance>(resData.getSCMO());

            CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>(
                new CMPI_Object(new CMPI_ObjEnumeration(aObj)));

            CMSetStatus(rc,CMPI_RC_OK);
            PEG_METHOD_EXIT();
            return cmpiEnum;
        }
        HandlerCatchSetStatus(rc, NULL);

        // Code flow should never get here.
    }
Esempio n. 26
0
void TestDeleteInstances(ProviderRegistrationManager & prmanager)
{
   CIMKeyBinding kb1(CIMName ("ProviderModuleName"), "providersModule1", 
       CIMKeyBinding::STRING);
   CIMKeyBinding kb2(CIMName ("ProviderName"), "PG_ProviderInstance1", 
       CIMKeyBinding::STRING);
   CIMKeyBinding kb3(CIMName ("CapabilityID"), "capability1", 
       CIMKeyBinding::STRING);
   CIMKeyBinding kbp1(CIMName ("ProviderModuleName"), "providersModule1", 
       CIMKeyBinding::STRING);
   CIMKeyBinding kbp2(CIMName ("Name"), "PG_ProviderInstance1", 
       CIMKeyBinding::STRING);
   CIMKeyBinding kbm1(CIMName ("Name"), "providersModule1", 
       CIMKeyBinding::STRING);

   CIMObjectPath instanceName;

  try
  {
    for (Uint32 i=1; i<=3; i++)
    {
      CIMObjectPath instanceName2;
      Array<CIMKeyBinding> keys2;
      Array<CIMKeyBinding> keysm;
      Array<CIMKeyBinding> keys;

      //
      // create Provider module instances
      //
      if (i <= 1)
      {
        CIMObjectPath returnRef;
        CIMClass cimClass(CLASSNAME);
        CIMInstance cimInstance(CLASSNAME);

    	cimInstance.addProperty(CIMProperty(CIMName ("Name"), String("providersModule1")));
    	cimInstance.addProperty(CIMProperty(CIMName ("Vendor"), String("HP")));
    	cimInstance.addProperty(CIMProperty(CIMName ("Version"), String("2.0")));
    	cimInstance.addProperty(CIMProperty(CIMName ("InterfaceType"), String("PG_DefaultC++")));
    	cimInstance.addProperty(CIMProperty(CIMName ("InterfaceVersion"), String("2.0")));
    	cimInstance.addProperty(CIMProperty(CIMName ("Location"), String("/tmp/module1")));

    	instanceName = cimInstance.buildPath(cimClass);

    	instanceName.setNameSpace(NAMESPACE);
    	instanceName.setClassName(CLASSNAME);

    	returnRef = prmanager.createInstance(instanceName, cimInstance);
    }

    // create PG_Provider instances

    if (i <= 2 )
    {
    	CIMObjectPath returnRef2;

    	CIMClass cimClass2(CLASSNAME2);

    	CIMInstance cimInstance2(CLASSNAME2);

    	cimInstance2.addProperty(CIMProperty(CIMName ("ProviderModuleName"), String("providersModule1")));
    	cimInstance2.addProperty(CIMProperty(CIMName ("Name"), String("PG_ProviderInstance1")));

    	instanceName2 = cimInstance2.buildPath(cimClass2);

    	instanceName2.setNameSpace(NAMESPACE);
    	instanceName2.setClassName(CLASSNAME2);

    	returnRef2 = prmanager.createInstance(instanceName2, cimInstance2);
    }

    //
    // create provider capability instances
    //

    Array <String> namespaces;
    Array <Uint16> providerType;
    Array <String> supportedMethods;

    namespaces.append("test_namespace1");
    namespaces.append("test_namespace2");
    
    providerType.append(2);
    providerType.append(5);

    supportedMethods.append("test_method1");
    supportedMethods.append("test_method2");

    CIMObjectPath returnRef3;

    CIMClass cimClass3(CLASSNAME3);

    CIMInstance cimInstance3(CLASSNAME3);

    cimInstance3.addProperty(CIMProperty(CIMName ("ProviderModuleName"), String("providersModule1")));
    cimInstance3.addProperty(CIMProperty(CIMName ("ProviderName"), String("PG_ProviderInstance1")));
    cimInstance3.addProperty(CIMProperty(CIMName ("CapabilityID"), String("capability1")));
    cimInstance3.addProperty(CIMProperty(CIMName ("ClassName"), String("test_class1")));
    cimInstance3.addProperty(CIMProperty(CIMName ("Namespaces"), namespaces));
    cimInstance3.addProperty(CIMProperty(CIMName ("ProviderType"), providerType));
    cimInstance3.addProperty(CIMProperty(CIMName ("SupportedMethods"), supportedMethods));

    CIMObjectPath instanceName3 = cimInstance3.buildPath(cimClass3);

    instanceName3.setNameSpace(NAMESPACE);
    instanceName3.setClassName(CLASSNAME3);

    returnRef3 = prmanager.createInstance(instanceName3, cimInstance3);

    switch (i)
    {
	case 1:
            //
            // delete cimInstance2
            //
            keys2.append(kbp1);
            keys2.append(kbp2);

            instanceName2.setKeyBindings(keys2);

    	    prmanager.deleteInstance(instanceName2);
	    break;

	case 2:
            //
            // delete cimInstance3
            //
            keys.append(kb1);
            keys.append(kb2);
            keys.append(kb3);

            instanceName3.setKeyBindings(keys);

    	    prmanager.deleteInstance(instanceName3);
	    break;

	case 3:
    	    //
    	    // delete cimInstance
            //
            keysm.append(kbm1);

            instanceName.setKeyBindings(keysm);

	    prmanager.deleteInstance(instanceName);
	    break;
        }
    }
  }
  catch(CIMException& e)
  {
      throw (e);
  }
}
//
// Initialize the namespaces so that all namespaces with the
// CIM_ElementConformsToProfile class also have the
// PG_ElementConformsToProfile class. Needed in order to implement
// the cross-namespace ElementConformsToProfile association in both
// directions.
//
void InteropProvider::initializeNamespaces()
{
    Array<CIMNamespaceName> namespaceNames =  repository->enumerateNameSpaces();
    // get the PG_ElementConformstoProfile class without the qualifiers
    // and then add just the required ASSOCIATION qualifier, so that
    // resolveclass doesn't fail for the test/EmbeddedInstance/Dynamic
    // namespace, which uses the CIM25 schema that doesn't include any
    // of the new qualifiers added to this class in later versions of
    // the CIMSchema.
    CIMClass conformsClass = repository->getClass(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE,
        true,
        false);
    conformsClass.addQualifier(
        CIMQualifier(CIMName("ASSOCIATION"), CIMValue(true)));
    CIMClass profileClass = repository->getClass(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE,
        true,
        false);
    for(Uint32 i = 0, n = namespaceNames.size(); i < n; ++i)
    {
        // Check if the PG_ElementConformsToProfile class is present
        CIMNamespaceName & currentNamespace = namespaceNames[i];
        CIMClass tmpCimClass;
        CIMClass tmpPgClass;
        CIMClass tmpPgProfileClass;
        try
        {
            // Look for these classes in the same try-block since the
            // second depends on the first
            tmpCimClass = repository->getClass(
                currentNamespace,
                PEGASUS_CLASSNAME_CIM_ELEMENTCONFORMSTOPROFILE);
            tmpPgClass = repository->getClass(
                currentNamespace,
                PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE);
        }
        catch(const Exception &)
        {
        }
        try
        {
            tmpPgProfileClass = repository->getClass(
                currentNamespace,
                PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE);
        }
        catch(const Exception &)
        {
            // Note: if any of the above three classes aren't found,
            // an exception will be thrown, which we can ignore since it's
            // an expected case
            // TBD: Log trace message?
        }

        // If the CIM_ElementConformsToProfile class is present, but
        // the PG_ElementConformsToProfile or PG_RegisteredProfile
        // class is not, then add it to that namespace.
        //
        // Note that we don't have to check for the
        // CIM_RegisteredProfile class because if the
        // CIM_ElementConformsToProfile class is present, the
        // CIM_RegisteredProfile class must also be present.
        if(!tmpCimClass.isUninitialized())
        {
            if(tmpPgClass.isUninitialized())
            {
                CIMClass newclass = conformsClass.clone();
                CIMObjectPath newPath = conformsClass.getPath();
                newPath.setNameSpace(currentNamespace);
                newclass.setPath(newPath);
                repository->createClass(
                    currentNamespace,
                    newclass);
            }
            if(tmpPgProfileClass.isUninitialized())
            {
                CIMClass newclass = profileClass.clone();
                CIMObjectPath newPath = profileClass.getPath();
                newPath.setNameSpace(currentNamespace);
                newclass.setPath(newPath);
                repository->createClass(
                    currentNamespace,
                    newclass);
            }
        }
    }
}
//
// Local version of the references operation. It validates the input
// parameters, setting the origin and target property values if not set
// already, and then performs an enumeration on the association class. It then
// filters the results of that enumeration to see if one of the reference
// properties matches the objectName parameter passed into the method. If so,
// then it is added to the array of association instances to be returned.
//
Array<CIMInstance> InteropProvider::localReferences(
    const OperationContext & context,
    const CIMObjectPath & objectName,
    const CIMName & assocClass,
    String & originProperty,
    String & targetProperty,
    const CIMPropertyList & propertyList,
    const CIMName & targetClass)
{
    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
        "InteropProvider::localReferences()");

    Array<CIMInstance> instances;
    CIMName originClass = objectName.getClassName();

    Array<CIMName> targetSubclasses;
    CIMNamespaceName lastTargetNamespace;
    CIMNamespaceName originNamespace(objectName.getNameSpace());

    // Check that the association traversal request is valid
    if (validAssocClassForObject(
        context, 
        assocClass, 
        objectName,
        originNamespace, 
        originProperty, 
        targetProperty))
    {
        // retrieve all of the association class instances
        Array<CIMInstance> localInstances = localEnumerateInstances(context,
            CIMObjectPath(hostName, originNamespace,
                assocClass));
        // Filter the association class instances based on the origin instance
        // and other input parameters.
        for(Uint32 i = 0, n = localInstances.size(); i < n; ++i)
        {
            CIMInstance & currentInstance = localInstances[i];
            CIMObjectPath originPath = getRequiredValue<CIMObjectPath>(
                currentInstance, originProperty);
            originPath.setNameSpace(objectName.getNameSpace());
            originPath.setHost(objectName.getHost());
            // Only include instances where the origin instance is present in
            // the association.
            if(originPath.identical(objectName))
            {
                if(!targetClass.isNull())
                {
                    // Have to check if the target reference is of the
                    // targetClass type. We first must determine all the
                    // possible subclasses of the targetClass in the target
                    // namespace.
                    CIMObjectPath targetPath = getRequiredValue<CIMObjectPath>(
                        currentInstance, targetProperty);

                    CIMNamespaceName targetNamespace(
                        targetPath.getNameSpace());
                    if(targetNamespace.isNull())
                    {
                        targetNamespace = originNamespace;
                        targetPath.setNameSpace(targetNamespace);
                    }
                    if(targetNamespace != lastTargetNamespace)
                    {
                        try
                        {
                            targetSubclasses = repository->enumerateClassNames(
                                targetNamespace, targetClass, true);
                        }
                        catch(...)
                        {
                            // If an exception was thrown during enumeration,
                            // then the base class didn't exist in the
                            // namespace, so the target instance retrieved
                            // must not match the targetClass parameter.
                            continue;
                        }
                        targetSubclasses.append(targetClass);
                        lastTargetNamespace = targetNamespace;
                    }

                    // Try to find the targetPath's class in the search space
                    CIMName targetPathClass = targetPath.getClassName();
                    for(Uint32 j = 0, m = targetSubclasses.size(); j < m; ++j)
                    {
                        if(targetPathClass == targetSubclasses[j])
                        {
                            instances.append(currentInstance);
                            break;
                        }
                    }
                }
                else
                {
                    instances.append(currentInstance);
                }
            }
        }
    }

    PEG_METHOD_EXIT();
    return instances;
}
//
// Local version of getInstance to be used by other functions in the the
// provider. Returns a single instance. Note that it always returns an
// instance. If none was found, it is uninialitized.
//
CIMInstance InteropProvider::localGetInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceName,
    const CIMPropertyList & propertyList)
{
    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::localGetInstance");

    PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4,
        "%s getInstance. instanceName= %s , PropertyList= %s",
        thisProvider,
        (const char *)instanceName.toString().getCString(),
        (const char *)propertyListToString(propertyList).getCString()));

    // Test if we're looking for something outside of our namespace. This will
    // happen during associators calls from PG_RegisteredProfile instances
    // through the PG_ElementConformsToProfile association
    CIMNamespaceName opNamespace = instanceName.getNameSpace();
    CIMName opClass = instanceName.getClassName();
    if(opNamespace != PEGASUS_NAMESPACENAME_INTEROP &&
        opClass != PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE
        // Get CIM_IndicationService instance from IndicationService.
#ifdef PEGASUS_ENABLE_DMTF_INDICATION_PROFILE_SUPPORT
        || opClass == PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE
#endif
        )
    {
        AutoMutex mut(interopMut);
        CIMInstance gotInstance = cimomHandle.getInstance(
                                         context,
                                         opNamespace,
                                         instanceName, 
                                         false, 
                                         false, 
                                         false, 
                                         propertyList);
        PEG_METHOD_EXIT();
        return gotInstance;
    }

    // Create reference from host, namespace, class components of
    // instance name
    CIMObjectPath ref;
    ref.setHost(instanceName.getHost());
    ref.setClassName(opClass);
    ref.setNameSpace(opNamespace);

    // Enumerate instances for this class. Returns all instances
    // Note that this returns paths setup and instances already
    // filtered per the input criteria.
    Array<CIMInstance> instances =  localEnumerateInstances(
        context,
        ref,
        propertyList);

    // deliver a single instance if found.
    CIMInstance retInstance;

    bool found = false;
    for(Uint32 i = 0, n = instances.size(); i < n; i++)
    {
        CIMObjectPath currentInstRef = instances[i].getPath();
        currentInstRef.setHost(instanceName.getHost());
        currentInstRef.setNameSpace(instanceName.getNameSpace());
        if(instanceName == currentInstRef)
        {
            retInstance = instances[i];
            found = true;
            break;
        }
    }

    if(!found)
    {
      cout << "Coule not find instance: " << instanceName.toString() << endl;
    }
    PEG_METHOD_EXIT();
    return retInstance;
}
Esempio n. 30
0
void PG_TestPropertyTypes::getInstance(
    const OperationContext& context,
    const CIMObjectPath& instanceReference,
    const Boolean includeQualifiers,
    const Boolean includeClassOrigin,
    const CIMPropertyList& propertyList,
    InstanceResponseHandler& handler)
{
    // synchronously get references
    //Get extra instance created for testing negative realValues.
    Array<CIMObjectPath> references =
        _enumerateInstanceNames(context, instanceReference);

    // ensure the InstanceId key is valid
    Array<CIMKeyBinding> keys = instanceReference.getKeyBindings();
    Uint32 i;
    for (i=0; i<keys.size() && !keys[i].getName().equal("InstanceId"); i++);

    if (i==keys.size())
    {
        throw CIMException(CIM_ERR_INVALID_PARAMETER);
    }

    // ensure the Namespace is valid
    if (!instanceReference.getNameSpace().equal ("test/static"))
    {
        throw CIMException(CIM_ERR_INVALID_NAMESPACE);
    }

    // ensure the class existing in the specified namespace
    if (!instanceReference.getClassName().equal ("PG_TestPropertyTypes"))
    {
        throw CIMException(CIM_ERR_INVALID_CLASS);
    }
        Boolean testRealValue = false;
    // ensure the request object exists
    Uint32 index = findObjectPath(references, instanceReference);
    if (index == PEG_NOT_FOUND)
    {
        CIMClass cimclass = _cimom.getClass(
            context,
            instanceReference.getNameSpace(),
            instanceReference.getClassName(),
            false,
            true,
            true,
            CIMPropertyList());
        CIMObjectPath tempRef = realValueTestInstance.buildPath(cimclass);
        tempRef.setHost(instanceReference.getHost());
        tempRef.setNameSpace(instanceReference.getNameSpace());
        if (instanceReference != tempRef)
        {
            throw CIMException(CIM_ERR_NOT_FOUND);
        }
        testRealValue = true;
    }

    // begin processing the request
    handler.processing();
    if (testRealValue)
    {
        handler.deliver(realValueTestInstance);
    }
    else
    {
        // instance index corresponds to reference index
        handler.deliver(_instances[index]);
    }
    // complete processing the request
    handler.complete();
}