本文整理汇总了C++中CIMObjectPath::setKeyBindings方法的典型用法代码示例。如果您正苦于以下问题:C++ CIMObjectPath::setKeyBindings方法的具体用法?C++ CIMObjectPath::setKeyBindings怎么用?C++ CIMObjectPath::setKeyBindings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIMObjectPath
的用法示例。
在下文中一共展示了CIMObjectPath::setKeyBindings方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _BubbleSort
static void _BubbleSort(Array<CIMKeyBinding>& x)
{
Uint32 n = x.size();
//
// If the key is a reference, the keys in the reference must also be
// sorted
//
for (Uint32 k = 0; k < n ; k++)
if (x[k].getType () == CIMKeyBinding::REFERENCE)
{
CIMObjectPath tmp (x[k].getValue ());
Array <CIMKeyBinding> keyBindings = tmp.getKeyBindings ();
_BubbleSort (keyBindings);
tmp.setKeyBindings (keyBindings);
x[k].setValue (tmp.toString ());
}
if (n < 2)
return;
for (Uint32 i = 0; i < n - 1; i++)
{
for (Uint32 j = 0; j < n - 1; j++)
{
if (String::compareNoCase(x[j].getName().getString(),
x[j+1].getName().getString()) > 0)
{
CIMKeyBinding t = x[j];
x[j] = x[j+1];
x[j+1] = t;
}
}
}
}
示例2: testCreateInstance
void testCreateInstance(CIMClient& client, const char* ns)
{
CIMObjectPath path;
Array<CIMInstance> instances;
CIMName keyName;
String keyValue;
instances = client.enumerateInstances(ns, CIM_QUERYCAPCLASS_NAME);
Array<CIMKeyBinding> keys = instances[0].getPath().getKeyBindings();
keys[0].setValue("100");
path = instances[0].getPath();
path.setKeyBindings(keys);
try
{
path = client.createInstance(ns, instances[0]);
}
catch(Exception)
{
// Do nothing. This is expected since createInstance is NOT
// supported.
return;
}
throw Exception("createInstance is supported");
}
示例3:
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;
}
示例4: 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;
}
示例5: _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;
}
示例6: TestCreateInstances
//.........这里部分代码省略.........
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);
}
示例7: TestDeleteInstances
//.........这里部分代码省略.........
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);
}
}
示例8: initialize
void PG_TestPropertyTypes::initialize(CIMOMHandle& cimom)
{
// save cimom handle
_cimom = cimom;
// create default instances
CIMInstance instance1("PG_TestPropertyTypes");
instance1.addProperty(CIMProperty(
"CreationClassName", String("PG_TestPropertyTypes"))); // key
instance1.addProperty(CIMProperty("InstanceId", Uint64(1))); //key
instance1.addProperty(CIMProperty(
"PropertyString", String("PG_TestPropertyTypes_Instance1")));
instance1.addProperty(CIMProperty("PropertyUint8", Uint8(120)));
instance1.addProperty(CIMProperty("PropertyUint16", Uint16(1600)));
instance1.addProperty(CIMProperty("PropertyUint32", Uint32(3200)));
instance1.addProperty(CIMProperty("PropertyUint64", Uint64(6400)));
instance1.addProperty(CIMProperty("PropertySint8", Sint8(-120)));
instance1.addProperty(CIMProperty("PropertySint16", Sint16(-1600)));
instance1.addProperty(CIMProperty("PropertySint32", Sint32(-3200)));
instance1.addProperty(CIMProperty("PropertySint64", Sint64(-6400)));
instance1.addProperty(CIMProperty("PropertyBoolean", Boolean(1)));
instance1.addProperty(CIMProperty("PropertyReal32", Real32(1.12345670123)));
instance1.addProperty(CIMProperty(
"PropertyReal64", Real64(1.12345678906543210123)));
instance1.addProperty(CIMProperty(
"PropertyDatetime", CIMDateTime("20010515104354.000000:000")));
// update object path
{
CIMObjectPath objectPath = instance1.getPath();
Array<CIMKeyBinding> keys;
{
CIMProperty keyProperty = instance1.getProperty(
instance1.findProperty("CreationClassName"));
keys.append(
CIMKeyBinding(keyProperty.getName(), keyProperty.getValue()));
}
{
CIMProperty keyProperty = instance1.getProperty(
instance1.findProperty("InstanceId"));
keys.append(
CIMKeyBinding(keyProperty.getName(), keyProperty.getValue()));
}
objectPath.setKeyBindings(keys);
instance1.setPath(objectPath);
}
_instances.append(instance1);
CIMInstance instance2("PG_TestPropertyTypes");
instance2.addProperty(CIMProperty(
"CreationClassName", String("PG_TestPropertyTypes"))); // key
instance2.addProperty(CIMProperty("InstanceId", Uint64(2))); //key
instance2.addProperty(CIMProperty(
"PropertyString", String("PG_TestPropertyTypes_Instance2")));
instance2.addProperty(CIMProperty("PropertyUint8", Uint8(122)));
instance2.addProperty(CIMProperty("PropertyUint16", Uint16(1602)));
instance2.addProperty(CIMProperty("PropertyUint32", Uint32(3202)));
instance2.addProperty(CIMProperty("PropertyUint64", Uint64(6402)));
instance2.addProperty(CIMProperty("PropertySint8", Sint8(-122)));
instance2.addProperty(CIMProperty("PropertySint16", Sint16(-1602)));
instance2.addProperty(CIMProperty("PropertySint32", Sint32(-3202)));
instance2.addProperty(CIMProperty("PropertySint64", Sint64(-6402)));
instance2.addProperty(CIMProperty("PropertyBoolean", Boolean(0)));
instance2.addProperty(CIMProperty("PropertyReal32", Real32(2.12345670123)));
instance2.addProperty(CIMProperty(
"PropertyReal64", Real64(2.12345678906543210123)));
instance2.addProperty(CIMProperty(
"PropertyDatetime", CIMDateTime("20010515104354.000000:000")));
_instances.append(instance2);
// update object path
{
CIMObjectPath objectPath = instance2.getPath();
Array<CIMKeyBinding> keys;
{
CIMProperty keyProperty = instance2.getProperty(
instance2.findProperty("CreationClassName"));
keys.append(
CIMKeyBinding(keyProperty.getName(), keyProperty.getValue()));
}
{
CIMProperty keyProperty = instance2.getProperty(
instance2.findProperty("InstanceId"));
//.........这里部分代码省略.........
示例9: 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);
}
示例10: testClass
int testClass(const String& className)
{
Array<CIMObjectPath> refs;
// =======================================================================
// enumerateInstanceNames
// =======================================================================
cout << "+++++ enumerateInstanceNames(" << className << ") ";
try
{
refs = c.enumerateInstanceNames(NAMESPACE,className);
}
catch (Exception& e)
{
cout << endl;
errorExit(e);
}
cout << refs.size() << " instances" << endl;
// if zero instances, not an error, but can't proceed
if (refs.size() == 0)
{
cout << "+++++ test completed early" << endl;
return 0;
}
// =======================================================================
// getInstance
// =======================================================================
// -------------------- First do normal getInstance() --------------------
// pick the middle instance of the bunch
int i = (refs.size()-1) >> 1; // This is a shift right, not streamio!
CIMObjectPath ref = refs[i];
CIMInstance inst;
cout << "+++++ getInstance #" << i << endl;
try
{
inst = c.getInstance(NAMESPACE,ref);
}
catch (Exception& e)
{
errorExit(e);
}
// ATTN-MG-20020501: Can add some property value checks here
// ------------------ do getInstance() with bad key ----------------------
Array<CIMKeyBinding> kb = ref.getKeyBindings();
// mess up first key name
kb[0].setName("foobar");
ref.setKeyBindings(kb);
int status = 0;
cout << "+++++ getInstance with bad key" << endl;
try
{
inst = c.getInstance(NAMESPACE,ref);
}
catch (CIMException& e)
{
if (e.getCode() == CIM_ERR_INVALID_PARAMETER) status = 1;
}
catch (Exception& e)
{
// any other exception is a failure; leave status alone
}
if (status == 0)
{
cout << "+++++ Error: bad instance name not rejected" << endl;
return 1;
}
// =======================================================================
// createInstance
// =======================================================================
CIMObjectPath ref2;
cout << "+++++ createInstance" << endl;
status = 0;
try
{
ref2 = c.createInstance(NAMESPACE,inst);
}
catch (CIMException& e)
{
if (e.getCode() == CIM_ERR_NOT_SUPPORTED) status = 1;
}
catch (Exception& e)
{
// any other Exception is a problem; leave status alone
}
if (status == 0)
{
cout << "+++++ Error: createInstance didn't throw exception" << endl;
return 1;
//.........这里部分代码省略.........
示例11: 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.");
}
示例12: CIMException
//.........这里部分代码省略.........
strAux = NULL;
vAux.Clear();
//set namespace
if (pInstance->Get(L"__NAMESPACE", 0, &vAux, NULL, NULL) != S_OK)
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
"Failed to retrieve WMI Data.");
strAux = new char[wcslen(vAux.bstrVal)+1];
if (strAux == NULL)
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "Out of Memory.");
wcstombs(strAux, vAux.bstrVal, wcslen(vAux.bstrVal)+1);
//converts '\' to '/'
_translateBackslashes(strAux);
tempRef.setNameSpace(strAux);
delete [] strAux;
strAux = NULL;
vAux.Clear();
//get key bindings
SAFEARRAY * aNames;
if (pInstance->GetNames(NULL,
WBEM_FLAG_KEYS_ONLY,
NULL,
&aNames) != S_OK)
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
"Failed to retrieve WMI Data.");
LONG lLBuond;
LONG lUBuond;
SafeArrayGetLBound(aNames, 1, &lLBuond);
SafeArrayGetUBound(aNames, 1, &lUBuond);
Array<CIMKeyBinding> keyBindings;
for(LONG i = lLBuond; i <=lUBuond; i++)
{
CComBSTR bstrName;
SafeArrayGetElement(aNames, &i, &bstrName);
char * strPropertyName = new char[bstrName.Length()+1];
if (strPropertyName == NULL)
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
"Out of Memory.");
wcstombs(strPropertyName, bstrName, bstrName.Length()+1);
CIMName keyname(strPropertyName);
Uint32 Index = tempInst.findProperty(keyname);
if (Index == PEG_NOT_FOUND)
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
"Failed to retrieve WMI Data.");
CIMValue keyvalue = tempInst.getProperty(Index).getValue();
CIMKeyBinding key(keyname, keyvalue);
keyBindings.append(key);
delete [] strPropertyName;
}
SafeArrayDestroy(aNames);
tempRef.setKeyBindings(keyBindings);
instanceNames.append(tempRef);
}
if (pInstance)
pInstance.Release();
hr = pInstEnum->Next(WBEM_INFINITE, 1, &pInstance, &dwReturned);
}
if (pInstEnum)
pInstEnum.Release();
PEG_TRACE((TRC_WMIPROVIDER,
Tracer::LEVEL4,
"WMIInstanceProvider::enumerateInstanceNames() -"
" Instance count is %d",
lCount));
if (lCount == 0)
{
PEG_TRACE((TRC_WMIPROVIDER,
Tracer::LEVEL2,
"WMIInstanceProvider::enumerateInstanceNames() -"
" hResult value is %x",
hr));
}
PEG_METHOD_EXIT();
return instanceNames;
}
示例13: TestDeleteInstances
//.........这里部分代码省略.........
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);
Boolean callFailed = false;
switch (i)
{
case 1:
//
// delete cimInstance2
//
keys2.append(kbp1);
keys2.append(kbp2);
instanceName2.setKeyBindings(keys2);
prmanager.deleteInstance(instanceName2);
// Test duplicate delete which should fail
try
{
prmanager.deleteInstance(instanceName2);
}
catch(CIMException& e)
{
callFailed = true;
VCOUT << "CIMException code " << e.getCode()
<< "(" << cimStatusCodeToString(e.getCode()) << ")"
<< "\nDescription \"" << e.getMessage() << "\""
<< endl;
PEGASUS_TEST_ASSERT(e.getCode() == CIM_ERR_NOT_FOUND);
}
PEGASUS_TEST_ASSERT(callFailed);
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);
}
}