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


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

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


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

示例1: buildElementConformsToProfile

PEGASUS_NAMESPACE_BEGIN

//
// Given the two references in the association, this function creates an
// instance of the PG_ElementConformsToProfile class.
//
CIMInstance buildElementConformsToProfile(
    const CIMObjectPath & currentProfile,
    const CIMObjectPath & currentElement,
    const CIMClass & elementConformsClass)
{
    Array<CIMName> elementPropArray;
    elementPropArray.append(
        ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD);
    elementPropArray.append(
        ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT);
    CIMPropertyList elementPropList(elementPropArray);

    CIMInstance tmpInstance =
        elementConformsClass.buildInstance(false, false,
            elementPropList);
    setPropertyValue(tmpInstance,
        ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD,
        currentProfile);
    setPropertyValue(tmpInstance,
        ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT,
        currentElement);
    tmpInstance.setPath(tmpInstance.buildPath(
        elementConformsClass));
    return tmpInstance;
}
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:31,代码来源:ElementConformsToProfile.cpp

示例2: createInstance

void InstanceProvider::createInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceReference,
    const CIMInstance & instanceObject,
    ObjectPathResponseHandler & handler)
{
    // Validate the class name
    if (!instanceObject.getClassName().equal("Sample_InstanceProviderClass"))
    {
        throw CIMNotSupportedException(
            instanceObject.getClassName().getString());
    }

    // Find the key property
    Uint32 idIndex = instanceObject.findProperty("Identifier");

    if (idIndex == PEG_NOT_FOUND)
    {
        throw CIMInvalidParameterException("Missing key value");
    }

    CIMInstance cimInstance = instanceObject.clone();

    // Create the new instance name
    CIMValue idValue = instanceObject.getProperty(idIndex).getValue();
    Array<CIMKeyBinding> keys;
    keys.append(CIMKeyBinding("Identifier", idValue));
    CIMObjectPath instanceName = CIMObjectPath(
        String(),
        CIMNamespaceName(),
        instanceObject.getClassName(),
        keys);

    cimInstance.setPath(instanceName);
    
    // Determine whether this instance already exists
    for(Uint32 i = 0, n = _instances.size(); i < n; i++)
    {
        if(instanceName == _instances[i].getPath())
        {
            throw CIMObjectAlreadyExistsException(instanceName.toString());
        }
    }

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

    // add the new instance to the array
    _instances.append(cimInstance);

    // deliver the new instance name
    handler.deliver(instanceName);

    // complete processing the request
    handler.complete();
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:56,代码来源:InstanceProvider.cpp

示例3: createInstance

/**
    Stores a copy of the provided instance locally in the errorInstance
    class property, and also creates a copy of the instance in the static
    repository namespace. The instance is then read back out of the repository
    and compared against the one stored by the class.
*/
void EmbeddedInstanceProvider::createInstance(
    const OperationContext& context,
    const CIMObjectPath& ref,
    const CIMInstance& obj,
    ObjectPathResponseHandler& handler)
{
    handler.processing();
    errorInstance.reset(new CIMInstance(obj));
    Array<CIMName> propNameList;
    propNameList.append(CIMName("errorKey"));
    propNameList.append(CIMName("EmbeddedInst"));
    CIMPropertyList propList(propNameList);
    CIMClass objClass = cimom.getClass(
        context,
        STATIC_REPOSITORY,
        obj.getClassName(),
        false,
        true,
        false,
        propList);
    CIMObjectPath objPath = obj.buildPath(objClass);
    errorInstance->setPath(objPath);

    repositoryPath = cimom.createInstance(
        context, STATIC_REPOSITORY, *errorInstance);

    CIMInstance repositoryInstance = cimom.getInstance(
        context,
        STATIC_REPOSITORY,
        repositoryPath,
        false,
        false,
        false,
        propList);
    repositoryInstance.setPath(repositoryPath);
    
    if (!errorInstance->identical(repositoryInstance))
    {
        throw Exception(
            "Repository instance and local instance for embedded error not "
                "identical");
    }

    handler.deliver(objPath);
    handler.complete();
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:52,代码来源:EmbeddedInstanceProvider.cpp

示例4: _inject_object_path

static void _inject_object_path(
    CIMInstance& instance,
    const CIMObjectPath& objectPath,
    const char* tag)
{
    Array<CIMKeyBinding> bindings;

    bindings.append(CIMKeyBinding("Tag", tag, CIMKeyBinding::STRING));

    bindings.append(CIMKeyBinding(
        "CreationClassName", "Benchmark2", CIMKeyBinding::STRING));

    instance.setPath(CIMObjectPath(
        objectPath.getHost(),
        objectPath.getNameSpace(),
        "Benchmark2",
        bindings));
}
开发者ID:LegalizeAdulthood,项目名称:cimple,代码行数:18,代码来源:main.cpp

示例5: modifyInstance

void InstanceProvider::modifyInstance(
	const OperationContext & context,
	const CIMObjectPath & instanceReference,
	const CIMInstance & instanceObject,
	const Boolean includeQualifiers,
	const CIMPropertyList & propertyList,
	ResponseHandler & handler)
{
	// 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())
		{
                       CIMInstance cimInstance = instanceObject.clone();

                       CIMObjectPath instanceName = CIMObjectPath(
                               String(),
                               CIMNamespaceName(),
                               instanceReference.getClassName(),
                               instanceReference.getKeyBindings());

                        cimInstance.setPath(instanceName);

			// overwrite existing instance
			_instances[i] = instanceObject;
			
			break;
		}
	}
	
	// complete processing the request
	handler.complete();
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:44,代码来源:InstanceProvider.cpp

示例6: setObjectManagerStatistics

Boolean setObjectManagerStatistics(CIMClient & client, Boolean newState)
{

    CIMName gathStatName ("GatherStatisticalData");
    Array<CIMInstance> instancesObjectManager;
    CIMInstance instObjectManager;
    Uint32 prop_num;
    Array<CIMName> plA;
    plA.append(gathStatName);
    CIMPropertyList statPropertyList(plA);
    // Create property list that represents correct request
    // get instance.  Get only the gatherstatitistics property
    instancesObjectManager  = 
        client.enumerateInstances(PEGASUS_NAMESPACENAME_INTEROP,
            "CIM_ObjectManager",
            true, false, false, false, statPropertyList);
    PEGASUS_TEST_ASSERT(instancesObjectManager.size() == 1);
    instObjectManager = instancesObjectManager[0];
    // set correct path into instance
    instObjectManager.setPath(instancesObjectManager[0].getPath());
    
    prop_num = instObjectManager.findProperty(gathStatName);
    PEGASUS_TEST_ASSERT(prop_num != PEG_NOT_FOUND);
    
    instObjectManager.getProperty(prop_num).setValue(CIMValue(newState));
    
    client.modifyInstance(PEGASUS_NAMESPACENAME_INTEROP, instObjectManager,
         false, statPropertyList);
    CIMInstance updatedInstance = 
        client.getInstance(PEGASUS_NAMESPACENAME_INTEROP,
        instObjectManager.getPath(),
        false, false, false, statPropertyList);
    prop_num = updatedInstance.findProperty(gathStatName);
    PEGASUS_TEST_ASSERT(prop_num != PEG_NOT_FOUND);
    CIMProperty p = updatedInstance.getProperty(prop_num);
    CIMValue v = p.getValue();
    Boolean rtn;
    v.get(rtn);
    //// Need to get it again
    cout << "Updated Status= " << ((rtn)? "true" : "false") << endl;
    return(rtn);
}
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:42,代码来源:CIMCLICommand.cpp

示例7: signalIndication

int signalIndication(CIMClient& client)
{
    AutoMutex a(*mut);
    Array<CIMParamValue> inParameters;
    Array<CIMParamValue> outParameters;

    try
    {
        inParameters.append(CIMParamValue("error", CIMValue(*errorInstance)));
        client.invokeMethod(
            TEST_NAMESPACE,
            errorPath,
            CIMName("PropagateError"),
            inParameters,
            outParameters);

        if (outParameters.size() != 1)
        {
            cout << "Expected to get 1 output parameter from PropagateError. "
                << "Received " << outParameters.size() << endl;
            return -1;
        }

        CIMInstance outParamInstance;
        outParameters[0].getValue().get(outParamInstance);
        outParamInstance.setPath(errorInstance->getPath());
        if (!errorInstance->identical(outParamInstance))
        {
            cout << "Output Instance differs from Input Instance" << endl;
            return -1;
        }
    }
    catch (Exception& e)
    {
        cout << "Exception caught during invoke method of PropagateError: "
            << e.getMessage() << endl;
        return -1;
    }

    return 0;
}
开发者ID:rdobson,项目名称:openpegasus,代码行数:41,代码来源:EmbeddedInstanceTest.cpp

示例8: enumerateInstances

void ComputerSystemProvider::enumerateInstances(
    const OperationContext& context,
    const CIMObjectPath& ref,
    const Boolean includeQualifiers,
    const Boolean includeClassOrigin,
    const CIMPropertyList& propertyList,
    InstanceResponseHandler& handler)
{
    CIMName className = ref.getClassName();
    _checkClass(className);

    handler.processing();

    // Deliver instance only if request was for leaf class
    if (className.equal (CLASS_EXTENDED_COMPUTER_SYSTEM))
    {
        Array<CIMKeyBinding> keys;
        keys.append(CIMKeyBinding(
            PROPERTY_CREATION_CLASS_NAME,
            CLASS_EXTENDED_COMPUTER_SYSTEM,
            CIMKeyBinding::STRING));
        keys.append(CIMKeyBinding(
            PROPERTY_NAME,
            _cs.getHostName(),
            CIMKeyBinding::STRING));
        CIMObjectPath instanceName(
            String::EMPTY,       // Hostname not required
            CIMNamespaceName(),  // Namespace not required
            CLASS_EXTENDED_COMPUTER_SYSTEM,
            keys);
        CIMInstance instance =
            _cs.buildInstance(CLASS_EXTENDED_COMPUTER_SYSTEM);
        instance.setPath(instanceName);
        handler.deliver(instance);
    }

    handler.complete();
    return;
}
开发者ID:deleisha,项目名称:neopegasus,代码行数:39,代码来源:ComputerSystemProvider.cpp

示例9: _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

示例10: main

int main(int argc, char** argv)
{
    cout << "+++++ testing Client Performance Statistics" << endl;

    try
    {
        // connecting to server
        CIMClient client;
        client.connect("localhost", 5988, String::EMPTY, String::EMPTY);

        // the value CIM_ObjectManager::GatherStatisticalData must be set to
        // true.  the following code does this
        String className = "CIM_ObjectManager";
        CIMName cN = CIMName(className);
        Boolean loc = true;
        String gath = "GatherStatisticalData";
        CIMName gst = CIMName(gath);
        CIMValue val = CIMValue(loc);
        Array<CIMObjectPath> instanceNames;
        /* EnumerateInstances and
        */
        try
        {
            instanceNames = client.enumerateInstanceNames(
                PEGASUS_NAMESPACENAME_INTEROP, cN);
        }
        catch (Exception& e)
        {
            cerr << "Exception : " << e.getMessage() << endl;
            exit(1);
        }
        catch (...)
        {
            cout << "enumerateInstancesNames in Client/tests/ClientStatistics "
                "has thrown an exception" << endl;
            exit(1);
        }
        // assert that we received  one name
        PEGASUS_TEST_ASSERT(instanceNames.size() == 1);
        /* ModifyInstance
        */
        CIMName gathStatName ("GatherStatisticalData");

        // variables used with gatherstatistics setting.
        CIMInstance instObjectManager;
        Uint32 prop_num;
        Array<CIMName> plA;
        plA.append(gathStatName);
        CIMPropertyList statPropertyList(plA);
        try
        {
            // Create property list that represents correct request
            // get instance.  Get only the gatherstatitistics property
            instObjectManager = client.getInstance(
                PEGASUS_NAMESPACENAME_INTEROP,
                instanceNames[0],
                true,
                false,
                false,
                statPropertyList);
            // set correct path into instance
            instObjectManager.setPath(instanceNames[0]);

            prop_num = instObjectManager.findProperty(gathStatName);
            PEGASUS_TEST_ASSERT(prop_num != PEG_NOT_FOUND);

            instObjectManager.getProperty(prop_num).setValue(CIMValue(true));

            client.modifyInstance(
                PEGASUS_NAMESPACENAME_INTEROP,
                instObjectManager,
                false,
                statPropertyList);
        }
        catch (Exception& e)
        {
            cerr << "Exception : " << e.getMessage() << endl;
            exit(1);
        }

        //registering class that has the callback method
        CliStat stat = CliStat();
        client.registerClientOpPerformanceDataHandler(stat);
        String classN = "PG_ComputerSystem";
        Array<CIMObjectPath> instance = client.enumerateInstanceNames(
            PEGASUS_NAMESPACENAME_CIMV2,
            classN);
        instObjectManager.getProperty(prop_num).setValue(CIMValue(false));
        client.modifyInstance(
            PEGASUS_NAMESPACENAME_INTEROP,
            instObjectManager,
            false,
            statPropertyList);
    }
    catch (Exception& e)
    {
        cerr << "Error: " << e.getMessage() << endl;
        exit(1);
    }

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

示例11: modifyInstance

//
// Modify instance based on modifiedInstance.
//
void UserAuthProvider::modifyInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceReference,
    const CIMInstance& modifiedIns,
    const Boolean includeQualifiers,
    const CIMPropertyList & propertyList,
    ResponseHandler & handler)
{
    PEG_METHOD_ENTER(TRC_USER_MANAGER,"UserAuthProvider::modifyInstance");

    //
    // get userName
    //
    String user;
    try
    {
        IdentityContainer container = context.get(IdentityContainer::NAME);
        user= container.getUserName();
    }
    catch (...)
    {
        user= String::EMPTY;
    }

    //
    // verify user authorizations
    //
    if ( user != String::EMPTY || user != "" )
    {
        _verifyAuthorization(user);
    }

    //
    // check if the class name requested is PG_Authorization
    //
    if (!instanceReference.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION))
    {
        PEG_METHOD_EXIT();
        throw PEGASUS_CIM_EXCEPTION (
            CIM_ERR_NOT_SUPPORTED, instanceReference.getClassName().getString());
    }

    CIMInstance newInstance = modifiedIns;

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

    try
    {
        //
        // Get the user name from the instance
        //
        String userNameStr;
        String namespaceStr;
        String authorizationStr;

        Uint32 pos = modifiedIns.findProperty ( PROPERTY_NAME_USERNAME );
        CIMProperty prop = (CIMProperty)newInstance.getProperty(pos);
        prop.getValue().get(userNameStr);

        //
        // Get the namespace from the instance
        //
        pos = modifiedIns.findProperty ( PROPERTY_NAME_NAMESPACE );
        prop = (CIMProperty)newInstance.getProperty(pos);
        prop.getValue().get(namespaceStr);

        //
        // Get the authorization from the instance
        //
        pos = modifiedIns.findProperty ( PROPERTY_NAME_AUTHORIZATION );
        prop = (CIMProperty)newInstance.getProperty(pos);
        prop.getValue().get(authorizationStr);

        //
        // ATTN: Note that the following is a hack, because
        // modifyInstance() in repository does not like
        // the hostname and namespace included in the CIMObjectPath
        // passed to it as a parameter.
        //
        CIMObjectPath ref("", CIMNamespaceName (),
                          modifiedIns.getClassName(), instanceReference.getKeyBindings());

        CIMInstance newModifiedIns = modifiedIns.clone ();
        newModifiedIns.setPath (ref);

        //
        // call modifyInstances of the repository
        //
        _repository->modifyInstance(
            instanceReference.getNameSpace(), newModifiedIns);

        //
        // set authorization in the UserManager
        //
        _userManager->setAuthorization(
            userNameStr, namespaceStr, authorizationStr );
//.........这里部分代码省略.........
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:101,代码来源:UserAuthProvider.cpp

示例12: createInstance

void LifecycleIndicationProvider::createInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceReference,
    const CIMInstance & instanceObject,
    ObjectPathResponseHandler & handler)
{
//  cout << "LifecycleIndicationProvider::createInstance()" << endl;
    // Validate the class name
    if(!instanceObject.getClassName().equal(
           "Sample_LifecycleIndicationProviderClass"))
    {
        throw CIMNotSupportedException(
            instanceObject.getClassName().getString());
    }

    // Find the key property
    Uint32 idIndex = instanceObject.findProperty("uniqueId");

    if(idIndex == PEG_NOT_FOUND)
    {
        throw CIMInvalidParameterException("Missing key value");
    }

    CIMInstance cimInstance = instanceObject.clone();

    // Create the new instance name
    CIMValue idValue = instanceObject.getProperty(idIndex).getValue();
    Array<CIMKeyBinding> keys;
    keys.append(CIMKeyBinding("uniqueId", idValue));

    CIMObjectPath instanceName =
        CIMObjectPath(
            String(),
            CIMNamespaceName(),
            instanceObject.getClassName(),
            keys);

    cimInstance.setPath(instanceName);

    // Determine whether this instance already exists
    for(Uint32 i = 0, n = _instances.size(); i < n; i++)
    {
        if(instanceName == _instances[i].getPath())
        {
            throw CIMObjectAlreadyExistsException(instanceName.toString());
        }
    }

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

    // add the new instance to the array
    _instances.append(cimInstance);

    // deliver the new instance name
    handler.deliver(instanceName);

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

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

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

        _indication_handler->deliver (indicationInstance);

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

示例13: mut

Array<CIMInstance> InteropProvider::getReferencedInstances(
    const Array<CIMInstance> &refs,
    const String &targetRole,
    const OperationContext & context,
    const CIMPropertyList & propertyList)
{
    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
                     "InteropProvider::getReferencedObjects");

    Array<CIMInstance> referencedInstances;
    Array<CIMInstance> classInstances;
    CIMName prevClassName;

    ConstArrayIterator<CIMInstance> refsIter(refs);
    for(Uint32 i = 0; i < refsIter.size(); i++)
    {
        CIMInstance thisRef = refsIter[i];
        CIMObjectPath thisTarget = getRequiredValue<CIMObjectPath>(
                                       thisRef,
                                       targetRole);

        // 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 = thisTarget.getNameSpace();
        CIMName opClass = thisTarget.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,
                                          thisTarget,
                                          false,
                                          false,
                                          false,
                                          propertyList);
            referencedInstances.append(gotInstance);
            continue;
        }

        TARGET_CLASS classEnum  = translateClassInput(opClass);
        CIMInstance retInstance;
        switch(classEnum)
        {
        case PG_SOFTWAREIDENTITY:
        {
            CIMInstance retInstance =
                getSoftwareIdentityInstance(thisTarget);
            normalizeInstance(
                retInstance, thisTarget, false, false, propertyList);
            retInstance.setPath(thisTarget);
            referencedInstances.append(retInstance);
        }
        break;
        case PG_NAMESPACE:
        {
            CIMInstance retInstance = getNameSpaceInstance(thisTarget);
            normalizeInstance(
                retInstance, thisTarget, false, false, propertyList);
            retInstance.setPath(thisTarget);
            referencedInstances.append(retInstance);
        }
        break;
        default:
        {
            if( opClass != prevClassName )
            {
                CIMObjectPath ref;
                ref.setHost(thisTarget.getHost());
                ref.setClassName(thisTarget.getClassName());
                ref.setNameSpace(thisTarget.getNameSpace());
                classInstances = localEnumerateInstances(
                                     context,
                                     ref,
                                     propertyList);
                ArrayIterator<CIMInstance> instsIter(classInstances);
                for(Uint32 n = 0; n < instsIter.size(); n++)
                {
                    CIMObjectPath tmpInst = instsIter[n].getPath();
                    tmpInst.setHost(thisTarget.getHost());
                    tmpInst.setNameSpace(thisTarget.getNameSpace());
                    instsIter[n].setPath(tmpInst);
                }
                prevClassName = opClass;
            }
            ConstArrayIterator<CIMInstance> instsConstIter(classInstances);
            for(Uint32 j = 0; j < instsConstIter.size(); j++)
            {
                if(thisTarget == instsConstIter[j].getPath())
                {
                    referencedInstances.append(instsConstIter[j]);
                    break;
//.........这里部分代码省略.........
开发者ID:deleisha,项目名称:neopegasus,代码行数:101,代码来源:InteropProvider.cpp

示例14: invokeMethod

/**
    When the "PropagateError" method is invoked, this function
    will read a CIM_Error embedded instance from the inParameters and use
    that instance to create an InstMethodIndication populating the Error[]
    property with the CIM_Error parameter and errorInstance stored in this
    class (if it's been created already). The output parameter of this method
    will contain the embedded instance received as input, and the newly
    created InstMethodIndication will be sent by the provider to any
    registered listeners.
*/
void EmbeddedInstanceProvider::invokeMethod(
        const OperationContext& context,
        const CIMObjectPath& objectReference,
        const CIMName& methodName,
        const Array<CIMParamValue>& inParameters,
        MethodResultResponseHandler& handler)
{
    // This should start sending indications with the stored Job instance
    // embedded in the InstMethodIndication
    handler.processing();
    if (!methodName.equal(CIMName("PropagateError")))
        throw CIMException(CIM_ERR_METHOD_NOT_AVAILABLE);

    if (inParameters.size() != 1)
    {
        throw CIMException(
            CIM_ERR_INVALID_PARAMETER, "Did not receive exactly 1 parameter");
    }

    CIMParamValue errorParam = inParameters[0];
    if (!String::equal(errorParam.getParameterName(), String("error")))
    {
        throw CIMException(
            CIM_ERR_INVALID_PARAMETER, "Did not find \"error\" parameter");
    }

    CIMInstance errorParamInst;
    errorParam.getValue().get(errorParamInst);
    if (errorParamInst.getPath().getClassName() != "PG_EmbeddedError")
    {
        throw CIMException(CIM_ERR_INVALID_PARAMETER);
    }
    errorParamInst.setPath(errorInstance->getPath());
    Array<CIMName> propList;
    for (unsigned int i = 0, n = errorParamInst.getPropertyCount(); i < n; i++)
    {
        propList.append(errorParamInst.getProperty(i).getName());
    }
    CIMInstance tmpErrorInstance(errorInstance->clone());
    if (!tmpErrorInstance.identical(errorParamInst))
    {
        throw Exception("Did not receive expected ErrorInstance");
    }

    // Build new indication instance
    CIMObjectPath indicationPath(System::getHostName(),
        CIMNamespaceName("test/EmbeddedInstance/Dynamic"),
        CIMName("PG_InstMethodIndication"));
    indicationInstance.reset(new CIMInstance("PG_InstMethodIndication"));
    indicationInstance->setPath(indicationPath);
    indicationInstance->addProperty(CIMProperty("MethodName",
        CIMValue(String("PropagateError"))));
    indicationInstance->addProperty(CIMProperty("PreCall",
        CIMValue(Boolean(false))));
    indicationInstance->addProperty(CIMProperty("SourceInstance",
        CIMValue(CIMObject(*errorInstance))));
    Array<CIMInstance> errorInstances;
    errorInstances.append(*errorInstance);
    errorInstances.append(*errorInstance);
    indicationInstance->addProperty(CIMProperty("Error",
        CIMValue(errorInstances)));

    handler.deliverParamValue(CIMParamValue(String("sameError"),
        CIMValue(errorParamInst)));
    handler.deliver(CIMValue(Uint32(1)));
    handler.complete();

    indicationHandler->deliver(*indicationInstance);
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:79,代码来源:EmbeddedInstanceProvider.cpp

示例15: retrieveErrorInstance

int retrieveErrorInstance(CIMClient& client)
{
    try
    {
        PEGASUS_STD(cout) << "Getting error instance: " << errorPath.toString()
            << PEGASUS_STD(endl);
        CIMInstance ret = client.getInstance(
            TEST_NAMESPACE, errorPath, true, false, false, errorPropList);
        ret.setPath(errorPath);
        if (!errorInstance->identical(ret))
        {
            if (!ret.getPath().identical(errorInstance->getPath()))
            {
                PEGASUS_STD(cout) << "Object Paths not identical"
                    << PEGASUS_STD(endl);
            }
            PEGASUS_STD(cout) << "Error Instance and instance retrieved "
                << "through GetInstance operation not the same\n"
                << PEGASUS_STD(endl);
            PEGASUS_STD(cout) << "Local Error Instance: "
                << errorInstance->getPath().toString() << PEGASUS_STD(endl);
            for (unsigned int i = 0, n = errorInstance->getPropertyCount();
                 i < n; i++)
            {
                CIMProperty prop = errorInstance->getProperty(i);
                PEGASUS_STD(cout) << i << ". " << prop.getName().getString()
                    << prop.getValue().toString() << PEGASUS_STD(endl);
            }

            PEGASUS_STD(cout) << "Retrieved Error Instance: " <<
                ret.getPath().toString() << PEGASUS_STD(endl);
            for (unsigned int i = 0, n = ret.getPropertyCount();
                 i < n; i++)
            {
                CIMProperty prop = ret.getProperty(i);
                PEGASUS_STD(cout) << i << ". " << prop.getName().getString()
                    << prop.getValue().toString() << PEGASUS_STD(endl);
            }

            CIMProperty localEmbeddedProp = errorInstance->getProperty(
                errorInstance->findProperty("EmbeddedInst"));
            CIMProperty retEmbeddedProp = ret.getProperty(
                ret.findProperty("EmbeddedInst"));
            CIMInstance localEmbeddedInst;
            CIMInstance retEmbeddedInst;
            localEmbeddedProp.getValue().get(localEmbeddedInst);
            retEmbeddedProp.getValue().get(retEmbeddedInst);
            CIMObjectPath localEmbeddedPath = localEmbeddedInst.getPath();
            CIMObjectPath retEmbeddedPath = retEmbeddedInst.getPath();

            PEGASUS_STD(cout) << "Local Embedded Path: " <<
                localEmbeddedPath.toString() << PEGASUS_STD(endl);
            PEGASUS_STD(cout) << "Ret Embedded Path: " <<
                retEmbeddedPath.toString() << PEGASUS_STD(endl);
            return -1;
        }
    }
    catch (Exception& e)
    {
        cout << "Exception caught while getting error instance: "
            << e.getMessage() << endl;
        return -1;
    }

    try
    {
        Array<CIMInstance> ret = client.enumerateInstances(
            TEST_NAMESPACE,
            "PG_EmbeddedError",
            true,
            true,
            false,
            false,
            errorPropList);
        int count = ret.size();
        for (int i = 0; i < count; i++)
        {
            if (!errorInstance->identical(ret[i]))
            {
                printf("Error instance and instance retrieved through "
                    "EnumerateInstances operation not the same\n");
                return -1;
            }
        }
    }
    catch (Exception& e)
    {
        cout << "Exception caught while enumerating error instances: "
            << e.getMessage() << endl;
        return -1;
    }

    return 0;
}
开发者ID:rdobson,项目名称:openpegasus,代码行数:94,代码来源:EmbeddedInstanceTest.cpp


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