本文整理汇总了C++中CIMObjectPath::setClassName方法的典型用法代码示例。如果您正苦于以下问题:C++ CIMObjectPath::setClassName方法的具体用法?C++ CIMObjectPath::setClassName怎么用?C++ CIMObjectPath::setClassName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIMObjectPath
的用法示例。
在下文中一共展示了CIMObjectPath::setClassName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _testMethodError
// 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);
}
示例2:
CIMObjectPath _buildSubscriptionPath
(const CIMObjectPath & filterPath,
const CIMObjectPath & handlerPath)
{
CIMObjectPath path;
Array <CIMKeyBinding> keyBindings;
keyBindings.append (CIMKeyBinding ("Filter",
filterPath.toString (), CIMKeyBinding::REFERENCE));
keyBindings.append (CIMKeyBinding ("Handler",
handlerPath.toString (), CIMKeyBinding::REFERENCE));
path.setClassName (SUBSCRIPTION_CLASSNAME);
path.setKeyBindings (keyBindings);
return path;
}
示例3: test1
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);
}
示例4: _checkSubscriptionCount
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);
}
示例5: generateIndication
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);
}
示例6: CIMNamespaceName
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;
}
示例7: _buildProviderIndDataInstanceName
CIMObjectPath ProviderIndicationCountTable::_buildProviderIndDataInstanceName(
const _ProviderIndicationCountTableEntry& indicationCountEntry)
{
PEG_METHOD_ENTER(TRC_INDICATION_SERVICE,
"ProviderIndicationCountTable::_buildProviderIndDataInstanceName");
CIMObjectPath instanceName;
Array<CIMKeyBinding> keyBindings;
keyBindings.append(CIMKeyBinding(
"ProviderModuleName",
indicationCountEntry.providerModuleName,
CIMKeyBinding::STRING));
keyBindings.append(CIMKeyBinding(
"ProviderName",
indicationCountEntry.providerName,
CIMKeyBinding::STRING));
instanceName.setClassName(PEGASUS_CLASSNAME_PROVIDERINDDATA);
instanceName.setKeyBindings(keyBindings);
PEG_METHOD_EXIT();
return instanceName;
}
示例8: TestDeleteInstances
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));
//.........这里部分代码省略.........
示例9: localGetInstance
//
// 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;
}
示例10: TestLookupInstanceProvider
Boolean TestLookupInstanceProvider(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(const CIMException&)
{
throw;
}
// 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(const CIMException&)
{
throw;
}
//
// 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));
//.........这里部分代码省略.........
示例11: instance
static void
_test2 (CIMClient & client)
{
Uint32 exceptions = 0;
CIMObjectPath instanceName;
Array < CIMKeyBinding > keyBindings;
keyBindings.append (CIMKeyBinding ("ElementNameName",
"TestCMPI_ExecQuery",
CIMKeyBinding::STRING));
instanceName.setNameSpace (providerNamespace);
instanceName.setClassName ("TestCMPI_ExecQuery");
instanceName.setKeyBindings (keyBindings);
/* Call the unsupported functions of the provider. */
try
{
CIMInstance instance (client.getInstance (providerNamespace,
instanceName));
} catch (const CIMException &)
{
exceptions ++;
}
try
{
client.deleteInstance (providerNamespace, instanceName);
} catch (const CIMException & )
{
exceptions ++;
}
CIMClass thisClass = client.getClass(
providerNamespace,
"TestCMPI_ExecQuery",
false,
true,
true,
CIMPropertyList());
Array<CIMName> propertyNameList;
propertyNameList.append(CIMName("ElementName"));
CIMPropertyList myPropertyList(propertyNameList);
// create the instance with the defined properties
CIMInstance newInstance = thisClass.buildInstance(true, true, myPropertyList);
newInstance.getProperty(0).setValue(CIMValue(String("TestCMPI_execQuery") ));
try
{
CIMObjectPath objectPath (client.createInstance (providerNamespace,
newInstance));
} catch (const CIMException &)
{
exceptions ++;
}
try
{
client.modifyInstance (providerNamespace, newInstance);
} catch (const CIMException &)
{
exceptions ++;
}
try
{
Array < CIMInstance > instances =
client.enumerateInstances (providerNamespace,
CIMName ("TestCMPI_ExecQuery"));
} catch (const CIMException &)
{
exceptions ++;
}
try
{
Array < CIMObjectPath > objectPaths =
client.enumerateInstanceNames (providerNamespace,
CIMName ("TestCMPI_ExecQuery"));
} catch (const CIMException &)
{
exceptions ++;
}
PEGASUS_TEST_ASSERT(exceptions == 6);
}
示例12: 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;
}
}
示例13: 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;
}
}
示例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.");
}
示例15: TestCreateInstances
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"),
//.........这里部分代码省略.........