当前位置: 首页>>代码示例>>C++>>正文


C++ CIMInstance::addProperty方法代码示例

本文整理汇总了C++中CIMInstance::addProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ CIMInstance::addProperty方法的具体用法?C++ CIMInstance::addProperty怎么用?C++ CIMInstance::addProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CIMInstance的用法示例。


在下文中一共展示了CIMInstance::addProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _createHandlerInstance

CIMObjectPath _createHandlerInstance(
    CIMClient & client,
    const String & name,
    const String & targetHost,
    const String & securityName,
    const Uint16 targetHostFormat,
    const Uint16 snmpVersion)
{
    CIMInstance handlerInstance (PEGASUS_CLASSNAME_INDHANDLER_SNMP);
    handlerInstance.addProperty (CIMProperty (CIMName
                                 ("SystemCreationClassName"), System::getSystemCreationClassName ()));
    handlerInstance.addProperty (CIMProperty (CIMName ("SystemName"),
                                 System::getFullyQualifiedHostName ()));
    handlerInstance.addProperty (CIMProperty (CIMName ("CreationClassName"),
                                 PEGASUS_CLASSNAME_INDHANDLER_SNMP.getString ()));
    handlerInstance.addProperty (CIMProperty (CIMName ("Name"), name));
    handlerInstance.addProperty (CIMProperty (CIMName ("TargetHost"),
                                 targetHost));
    handlerInstance.addProperty (CIMProperty (CIMName ("TargetHostFormat"),
                                 CIMValue ((Uint16) targetHostFormat)));
    handlerInstance.addProperty (CIMProperty (CIMName ("SNMPSecurityName"),
                                 securityName));
    handlerInstance.addProperty (CIMProperty (CIMName ("SnmpVersion"),
                                 CIMValue ((Uint16) snmpVersion)));
    handlerInstance.addProperty (CIMProperty (CIMName ("PortNumber"),
                                 CIMValue ((Uint32) PORT_NUMBER)));

    return client.createInstance(
               PEGASUS_NAMESPACENAME_INTEROP, handlerInstance);
}
开发者ID:xenserver,项目名称:openpegasus,代码行数:30,代码来源:testSnmpHandler.cpp

示例2: handler

CIMObjectPath _createHandler
   (CIMClient & client,
    const String & name,
    const String & destination)
{
    CIMInstance handler (HANDLER_CLASSNAME);

    handler.addProperty (CIMProperty (CIMName ("Name"), name));
    handler.addProperty (CIMProperty (CIMName ("Destination"), destination));

    CIMObjectPath path = client.createInstance (INTEROPNAMESPACE, handler);
    return path;
}
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:13,代码来源:SendTestIndications.cpp

示例3: subscription

CIMObjectPath _createSubscription
   (CIMClient & client,
    const CIMObjectPath & filterPath,
    const CIMObjectPath & handlerPath)
{
    CIMInstance subscription (SUBSCRIPTION_CLASSNAME);

    subscription.addProperty (CIMProperty (CIMName ("Filter"),
        filterPath, 0, FILTER_CLASSNAME));
    subscription.addProperty (CIMProperty (CIMName ("Handler"),
        handlerPath, 0, HANDLER_CLASSNAME));

    CIMObjectPath path = client.createInstance (INTEROPNAMESPACE, subscription);
    return path;
}
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:15,代码来源:SendTestIndications.cpp

示例4: _createSubscriptionInstance

CIMObjectPath _createSubscriptionInstance(
    CIMClient & client,
    const CIMObjectPath & filterPath,
    const CIMObjectPath & handlerPath)
{
    CIMInstance subscriptionInstance (PEGASUS_CLASSNAME_INDSUBSCRIPTION);
    subscriptionInstance.addProperty (CIMProperty (CIMName ("Filter"),
                                      filterPath, 0, PEGASUS_CLASSNAME_INDFILTER));
    subscriptionInstance.addProperty (CIMProperty (CIMName ("Handler"),
                                      handlerPath, 0, PEGASUS_CLASSNAME_INDHANDLER_SNMP));
    subscriptionInstance.addProperty (CIMProperty
                                      (CIMName ("SubscriptionState"), CIMValue ((Uint16) 2)));

    return client.createInstance(
               PEGASUS_NAMESPACENAME_INTEROP, subscriptionInstance);
}
开发者ID:xenserver,项目名称:openpegasus,代码行数:16,代码来源:testSnmpHandler.cpp

示例5: subscriptionInstance

void _createSubscriptionInstance 
    (CIMClient & client,
     const CIMObjectPath & filterPath,
     const CIMObjectPath & handlerPath,
     const CIMNamespaceName & subscriptionNS)
{
    CIMInstance subscriptionInstance (PEGASUS_CLASSNAME_INDSUBSCRIPTION);
    subscriptionInstance.addProperty (CIMProperty (CIMName ("Filter"),
        filterPath, 0, PEGASUS_CLASSNAME_INDFILTER));
    subscriptionInstance.addProperty (CIMProperty (CIMName ("Handler"),
        handlerPath, 0, PEGASUS_CLASSNAME_INDHANDLER_CIMXML));
    subscriptionInstance.addProperty (CIMProperty
        (CIMName ("SubscriptionState"), CIMValue ((Uint16) 2)));

    CIMObjectPath path = client.createInstance (subscriptionNS, 
        subscriptionInstance);
}
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:17,代码来源:DisableEnable2.cpp

示例6: filter

CIMObjectPath _createFilter
   (CIMClient & client,
    const String & name,
    const String & query,
    const String & queryLanguage,
    const String & sourceNamespace)
{
    CIMInstance filter (FILTER_CLASSNAME);

    filter.addProperty (CIMProperty (CIMName ("Name"), name));
    filter.addProperty (CIMProperty (CIMName ("Query"), query));
    filter.addProperty (CIMProperty (CIMName ("QueryLanguage"), queryLanguage));
    filter.addProperty (CIMProperty (CIMName ("SourceNamespace"), 
        sourceNamespace));

    CIMObjectPath path = client.createInstance (INTEROPNAMESPACE, filter);
    return path;
}
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:18,代码来源:SendTestIndications.cpp

示例7: CreateSbscriptionInstance

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);
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:19,代码来源:IndicationProcess.cpp

示例8: handlerInstance

void _createHandlerInstance 
    (CIMClient & client, 
     const String & name,
     const String & destination,
     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"), name));
    handlerInstance.addProperty (CIMProperty (CIMName ("Destination"),
        destination));

    CIMObjectPath path = client.createInstance (handlerNS, handlerInstance);
}
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:19,代码来源:DisableEnable2.cpp

示例9: _createFilterInstance

CIMObjectPath _createFilterInstance(
    CIMClient & client,
    const String & name,
    const String & query,
    const String & qlang)
{
    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"), name));
    filterInstance.addProperty (CIMProperty (CIMName ("Query"), query));
    filterInstance.addProperty (CIMProperty (CIMName ("QueryLanguage"),
                                String (qlang)));
    filterInstance.addProperty (CIMProperty (CIMName ("SourceNamespace"),
                                SOURCE_NAMESPACE.getString ()));

    return client.createInstance(PEGASUS_NAMESPACENAME_INTEROP, filterInstance);
}
开发者ID:xenserver,项目名称:openpegasus,代码行数:22,代码来源:testSnmpHandler.cpp

示例10: test04

//
//  Test identical() function with keys that are references
//
void test04()
{
    //
    // Create classes A and B referenced classes, C - Association
    //
    CIMClass classA (CIMName ("A"), CIMName ());
    CIMProperty propertyX ("x", String ());
    propertyX.addQualifier (CIMQualifier (CIMName ("Key"), true));
    CIMProperty propertyY ("y", String ());
    propertyY.addQualifier (CIMQualifier (CIMName ("Key"), true));
    CIMProperty propertyZ ("z", String ());
    propertyZ.addQualifier (CIMQualifier (CIMName ("Key"), true));
    classA.addProperty (propertyX);
    classA.addProperty (propertyY);
    classA.addProperty (propertyZ);

    CIMClass classB ("B");
    CIMProperty propertyQ ("q", String ());
    propertyQ.addQualifier (CIMQualifier (CIMName ("Key"), true));
    CIMProperty propertyR ("r", String ());
    propertyR.addQualifier (CIMQualifier (CIMName ("Key"), true));
    CIMProperty propertyS ("s", String ());
    propertyS.addQualifier (CIMQualifier (CIMName ("Key"), true));
    classB.addProperty (propertyQ);
    classB.addProperty (propertyR);
    classB.addProperty (propertyS);

    CIMClass classC ("C");
    CIMProperty propertyA ("a", CIMValue ());
    propertyA.addQualifier (CIMQualifier (CIMName ("Key"), true));
    CIMProperty propertyB ("b", CIMValue ());
    propertyB.addQualifier (CIMQualifier (CIMName ("Key"), true));
    classC.addProperty (propertyA);
    classC.addProperty (propertyB);

    //
    //  Create instances of each classa
    //
    CIMInstance instanceA (CIMName ("A"));
    instanceA.addProperty (CIMProperty (CIMName ("x"), String ("rose")));
    instanceA.addProperty (CIMProperty (CIMName ("y"), String ("lavender")));
    instanceA.addProperty (CIMProperty (CIMName ("z"), String ("rosemary")));
    CIMObjectPath aPath = instanceA.buildPath (classA);
    CIMObjectPath aPath2 ("A.y=\"lavender\",x=\"rose\",z=\"rosemary\"");
    PEGASUS_TEST_ASSERT (aPath.identical (aPath2));

    CIMInstance instanceB (CIMName ("B"));
    instanceB.addProperty (CIMProperty (CIMName ("q"),
        String ("pelargonium")));
    instanceB.addProperty (CIMProperty (CIMName ("r"), String ("thyme")));
    instanceB.addProperty (CIMProperty (CIMName ("s"), String ("sage")));

    // Test to assure that the buildpath function works.
    CIMObjectPath bPath = instanceB.buildPath (classB);
    CIMObjectPath bPath2 ("B.s=\"sage\",q=\"pelargonium\",r=\"thyme\"");
    PEGASUS_TEST_ASSERT (bPath.identical (bPath2));

    // Build instance of C and build path from buildPath function.
    CIMInstance instanceC (CIMName ("C"));
    instanceC.addProperty (CIMProperty (CIMName ("a"), aPath, 0,
        CIMName ("A")));
    instanceC.addProperty (CIMProperty (CIMName ("b"), bPath, 0,
        CIMName ("B")));
    CIMObjectPath cPath = instanceC.buildPath (classC);

    // Build CIMObjectPath from keybindings.
    Array <CIMKeyBinding> keyBindings;
    CIMKeyBinding aBinding ("a", "A.y=\"lavender\",x=\"rose\",z=\"rosemary\"",
        CIMKeyBinding::REFERENCE);
    CIMKeyBinding bBinding ("b", "B.s=\"sage\",q=\"pelargonium\",r=\"thyme\"",
        CIMKeyBinding::REFERENCE);
    keyBindings.append (aBinding);
    keyBindings.append (bBinding);

    CIMObjectPath cPath2 ("", CIMNamespaceName (),
        cPath.getClassName (), keyBindings);

    // Assert that the CIMObjectPaths for C from build path and direct
    // from keybindings are equal.
    PEGASUS_TEST_ASSERT (cPath.identical (cPath2));

    // ATTN: KS 25 Feb 2003 P3 - Think we can extend these tests
    // since this is creation of classes and
    // instnaces for associations and referenced classes.
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:88,代码来源:Reference.cpp

示例11: _generateIndication

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);
    }
}
开发者ID:rdobson,项目名称:openpegasus,代码行数:81,代码来源:OOPModuleFailureTestProvider.cpp

示例12: TestExceptionHandling

static void TestExceptionHandling(CIMHandler* handler)
{
    CIMInstance indicationHandlerInstance;

    // Test "invalid IndicationHandlerSNMPMapper instance" exception
    CIMInstance indicationInstance(testClass1);
    indicationHandlerInstance = CreateHandlerInstance();
    TestException(handler, indicationHandlerInstance, indicationInstance,
        CIM_ERR_FAILED);

    // Test "no required property TargetHostFormat" exception
    indicationInstance = CIMInstance(testClass1);
    indicationInstance.addProperty(CIMProperty(
       CIMName ("OidDataType"), String("OctetString")));
    indicationHandlerInstance = CreateHandlerInstance();
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("TargetHost"), String("15.13.140.120")));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("SNMPVersion"), Uint16(2)));
    TestException(handler, indicationHandlerInstance, indicationInstance,
        CIM_ERR_FAILED);

    // Test "no required property SNMPVersion" exception
    indicationInstance = CIMInstance(testClass1);
    indicationHandlerInstance = CreateHandlerInstance();
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("TargetHost"), String("15.13.140.120")));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("TargetHostFormat"), Uint16(3)));
    TestException(handler, indicationHandlerInstance, indicationInstance,
        CIM_ERR_FAILED);

    // Test "unsupported snmp Version" exception
    indicationInstance = CIMInstance(testClass1);
    indicationHandlerInstance = CreateHandlerInstance();
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("TargetHost"), String("15.13.140.120")));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("TargetHostFormat"), Uint16(3)));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("SNMPVersion"), Uint16(5)));
    TestException(handler, indicationHandlerInstance, indicationInstance,
        CIM_ERR_FAILED);

    // Test "invalid MappingStrings Syntax" exception
    indicationInstance = CIMInstance(testClass8);
    indicationInstance.addProperty(CIMProperty(
        CIMName ("OidDataType"), String("OctetString")));
    indicationHandlerInstance = CreateHandlerInstance();
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("TargetHost"), String("15.13.140.120")));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("TargetHostFormat"), Uint16(3)));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("SNMPVersion"), Uint16(2)));
    TestException(handler, indicationHandlerInstance, indicationInstance,
        CIM_ERR_FAILED);

    // Test "invalid MappingStrings value" exception
    indicationInstance = CIMInstance(testClass2);
    indicationInstance.addProperty(CIMProperty(
        CIMName ("OidDataType"), String("OctetString")));
    indicationHandlerInstance = CreateHandlerInstance();
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("TargetHost"), String("15.13.140.120")));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("TargetHostFormat"), Uint16(3)));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("SNMPVersion"), Uint16(2)));
    TestException(handler, indicationHandlerInstance, indicationInstance,
        CIM_ERR_FAILED);

    // Test "no MappingStrings qualifier" exception
    indicationInstance = CIMInstance(testClass3);
    indicationHandlerInstance = CreateHandlerInstance();
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("TargetHost"), String("15.13.140.120")));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("TargetHostFormat"), Uint16(3)));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("SNMPVersion"), Uint16(2)));
    TestException(handler, indicationHandlerInstance, indicationInstance,
        CIM_ERR_FAILED);

    // Test "send trap failed" exception
    indicationInstance = CIMInstance(testClass4);
    indicationHandlerInstance = CreateHandlerInstance();
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("TargetHost"), String("15.13.140.120")));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("TargetHostFormat"), Uint16(3)));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("SNMPVersion"), Uint16(2)));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("SNMPSecurityName"), String("t")));
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat")));
    TestException(handler, indicationHandlerInstance, indicationInstance,
        CIM_ERR_FAILED);

//.........这里部分代码省略.........
开发者ID:brunolauze,项目名称:pegasus,代码行数:101,代码来源:TestSnmpHandlerException.cpp

示例13: addManagedSystemElementProperties

void UNIX_PROVIDER::addManagedSystemElementProperties(CIMInstance &inst, CLASS_IMPLEMENTATION _p)
{
  CIMProperty p;
  #include <CIM_ManagedElementProvider.cpp>
  //ManagedSystemElement
  if (_p.getInstallDate(p)) inst.addProperty(p);
  if (_p.getName(p)) inst.addProperty(p);
  if (_p.getStatus(p)) inst.addProperty(p);
  if (_p.getCommunicationStatus(p)) inst.addProperty(p);
  if (_p.getDetailedStatus(p)) inst.addProperty(p);
  if (_p.getHealthStatus(p)) inst.addProperty(p);
  if (_p.getOperatingStatus(p)) inst.addProperty(p);
  if (_p.getPrimaryStatus(p)) inst.addProperty(p);
  if (_p.getOperationalStatus(p)) inst.addProperty(p);
  if (_p.getStatusDescriptions(p)) inst.addProperty(p);

  //ALL TOP CLASS /* Let's add it here */
  if (_p.getCreationClassName(p)) inst.addProperty(p);
  if (_p.getSystemCreationClassName(p)) inst.addProperty(p);
  inst.addProperty(CIMProperty(PROPERTY_SYSTEM_NAME, _hostName));
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:21,代码来源:CIM_ManagedSystemElementProvider.cpp

示例14: associators

void MCCA_TestAssocProvider::associators(
    const OperationContext & context,
    const CIMObjectPath & objectName,
    const CIMName & associationClass,
    const CIMName & resultClass,
    const String & role,
    const String & resultRole,
    const Boolean includeQualifiers,
    const Boolean includeClassOrigin,
    const CIMPropertyList & propertyList,
    ObjectResponseHandler & handler)
{
    CDEBUG("MCCA_TestAssocProvider::associators() called.");
    // create a new CIMInstance based on class with name className
    CIMInstance constructedInstance = CIMInstance(testClassName);
    CIMObjectPath   targetObjectPath = CIMObjectPath();
    Array<CIMKeyBinding> keyBindings = Array<CIMKeyBinding>();
    Uint32 sourceKey = 0;

    CDEBUG("Initialisation ended.");
    handler.processing();
    CDEBUG("handler.processing started.");
    // we do ignore role, resultRole, includeQualifiers, includeClassOrigin,
    // propertyList

    CDEBUG("Next building object path.");
    /////////////////////////////////////////////////////////////////////
    //      BUILD OBJECTPATH
    /////////////////////////////////////////////////////////////////////

    // preparing object path first
    targetObjectPath.setHost("localhost:5988");
    targetObjectPath.setClassName(testClassName);
    CDEBUG("Host and classname set, host=" << objectName.getHost());
    // determine if source namespace is namespace A or B
    // and build respective target namespace ...
    if (objectName.getNameSpace().equal(nameSpaceA))
    {
        targetObjectPath.setNameSpace(nameSpaceB);
    }
    if (objectName.getNameSpace().equal(nameSpaceB))
    {
        targetObjectPath.setNameSpace(nameSpaceA);
    }
    CDEBUG("NameSpace set.");
    // determine key of source object so we can create target object
    Array<CIMKeyBinding> sourceKeyBindings = objectName.getKeyBindings();

    CDEBUG("Determining sourceKey.");
    // only one keyvalue, so we take that first one
    String      keyValueString = String(sourceKeyBindings[0].getValue());
    CDEBUG("keyValueString=" << keyValueString);
    sourceKey = strtoul((const char*) keyValueString.getCString(), NULL, 0);
    CDEBUG("sourceKey=" << sourceKey);


    CIMKeyBinding  testClassKey = CIMKeyBinding(CIMName("theKey"),
                                                    CIMValue(sourceKey) );
    CDEBUG("Created new KeyBinding testClassKey.");
    // testClassKey.setValue(keyValueString);

    CDEBUG("sourceKey = string(set keybinding),int(sourceKey)"
            << testClassKey.getValue()
            << "," << sourceKey);
    keyBindings.append(testClassKey);
    CDEBUG("Appended(testClassKey).");

    targetObjectPath.setKeyBindings(keyBindings);
    /////////////////////////////////////////////////////////////////////
    //      ADD PROPERTIES
    /////////////////////////////////////////////////////////////////////

    // add properties to the CIMInstance object
    constructedInstance.addProperty( CIMProperty( CIMName("theKey"),
                sourceKey));
    constructedInstance.addProperty( CIMProperty( CIMName("theData"),
                20+sourceKey));
    char  buffer[100];
    sprintf(buffer,"ABC-%u",20*sourceKey+sourceKey);
    constructedInstance.addProperty(CIMProperty(CIMName ("theString"),
                String(buffer)));

    CDEBUG("Added properties to the CIMInstance object");

    CIMObject cimObject(constructedInstance);
    cimObject.setPath (targetObjectPath);

    // lets deliver all instances of CIMObjectpaths I do think are okay
    handler.deliver(cimObject);
    // complete processing the request
    handler.complete();
    CDEBUG("Association call conmplete.");
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:93,代码来源:MCCA_TestAssocProvider.cpp

示例15: deleteInstance

void LifecycleIndicationProvider::deleteInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceReference,
    ResponseHandler & handler)
{
//  cout << "LifecycleIndicationProvider::deleteInstance()" << endl;
    CIMInstance localInstance;
    // convert a potential fully qualified reference into a local reference
    // (class name and keys only).
    CIMObjectPath localReference =
        CIMObjectPath(
            String(),
            CIMNamespaceName(),
            instanceReference.getClassName(),
            instanceReference.getKeyBindings());

    // begin processing the request
    handler.processing();

    // instance index corresponds to reference index
    for(Uint32 i = 0, n = _instances.size(); i < n; i++)
    {
        if(localReference == _instances[i].getPath())
        {
            localInstance = _instances[i];
            // remove instance from the array
            _instances.remove(i);

            break;
        }
    }

    // complete processing the request
    handler.complete();

    // If there is at least one subscription active for the lifecycle indication
    // InstDeletion_for_Sample_LifecycleIndicationProviderClass, then generate
    // that indication here, embedding the just-deleted instance as the
    // SourceInstance property. See LifecycleIndicationProviderR.mof.
    if (_lifecycle_indications_enabled)
    {
        CIMInstance indicationInstance(
            CIMName(
                "InstDeletion_for_Sample_LifecycleIndicationProviderClass"));
        CIMObjectPath path;
        path.setNameSpace("root/SampleProvider");
        path.setClassName(
            "InstDeletion_for_Sample_LifecycleIndicationProviderClass");
        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));

        // Before we send the Lifecycle Indication for the delete of this
        // instance, change the "lastOp" property value to "deleteInstance".
        Uint32 ix = localInstance.findProperty(CIMName("lastOp"));
        if (ix != PEG_NOT_FOUND)
        {
            localInstance.removeProperty(ix);
            localInstance.addProperty(
                CIMProperty(
                    CIMName("lastOp"),
                    String("deleteInstance")));
        }

        indicationInstance.addProperty
            (CIMProperty ("SourceInstance",CIMObject(localInstance)));

        _indication_handler->deliver (indicationInstance);

//      cout << "LifecycleIndicationProvider::deleteInstance() sent "
//                  "InstDeletion_for_Sample_LifecycleIndicationProviderClass"
//           << endl;
    }
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:81,代码来源:LifecycleIndicationProvider.cpp


注:本文中的CIMInstance::addProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。