// 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); }
void test04 (CIMClient & client) { CIMObjectPath instanceName; instanceName.setNameSpace (providerNamespace); instanceName.setClassName (CLASSNAME); Array < CIMParamValue > inParams; Array < CIMParamValue > outParams; /* [EmbeddedObject] String returnInstance(); */ CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "returnInstance", inParams, outParams); PEGASUS_TEST_ASSERT (retValue.getType () == CIMTYPE_OBJECT); PEGASUS_TEST_ASSERT (!retValue.isArray ()); PEGASUS_TEST_ASSERT (!retValue.isNull ()); CIMObject result; retValue.get (result); CIMObjectPath objPath = result.getPath(); PEGASUS_TEST_ASSERT (objPath.toString() == "TestCMPI_Instance"); }
void test06 (CIMClient & client) { CIMObjectPath instanceName; Uint32 exception =0; instanceName.setNameSpace (providerNamespace); instanceName.setClassName (CLASSNAME); Array < CIMParamValue > inParams; Array < CIMParamValue > outParams; /* String returnDateTime(); */ try { CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "noSuchFunction", inParams, outParams); } catch (const CIMException &e) { exception ++; PEGASUS_TEST_ASSERT (e.getCode() == CIM_ERR_NOT_FOUND); } PEGASUS_TEST_ASSERT (exception == 1); }
IndicationStressTestProvider::IndicationStressTestProvider (void) throw () { // Set the destination of indications for all threads once path.setNameSpace("test/TestProvider"); path.setClassName("IndicationStressTestClass"); }
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; }
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); }
void test08 (CIMClient & client) { CIMObjectPath instanceName; instanceName.setNameSpace (providerNamespace); instanceName.setClassName (CLASSNAME); Array < CIMParamValue > inParams; Array < CIMParamValue > outParams; inParams.append (CIMParamValue ("Operation", CIMValue (Uint64 (1)))); CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "TestCMPIBroker", inParams, outParams); _checkUint32Value (retValue, 1); }
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); }
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); }
void test01 (CIMClient & client) { CIMObjectPath instanceName; instanceName.setNameSpace (providerNamespace); instanceName.setClassName (CLASSNAME); Array < CIMParamValue > inParams; Array < CIMParamValue > outParams; /* String returnUint32(); */ CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "returnUint32", inParams, outParams); _checkUint32Value (retValue, 42); }
CIMObjectPath _buildFilterOrHandlerPath (const CIMName & className, const String & name, const CIMNamespaceName & namespaceName = CIMNamespaceName ()) { CIMObjectPath path; Array <CIMKeyBinding> keyBindings; keyBindings.append (CIMKeyBinding ("SystemCreationClassName", System::getSystemCreationClassName (), CIMKeyBinding::STRING)); keyBindings.append (CIMKeyBinding ("SystemName", System::getFullyQualifiedHostName (), CIMKeyBinding::STRING)); keyBindings.append (CIMKeyBinding ("CreationClassName", className.getString(), CIMKeyBinding::STRING)); keyBindings.append (CIMKeyBinding ("Name", name, CIMKeyBinding::STRING)); path.setClassName (className); path.setKeyBindings (keyBindings); path.setNameSpace (namespaceName); return path; }
void test05 (CIMClient & client) { CIMObjectPath instanceName; instanceName.setNameSpace (providerNamespace); instanceName.setClassName (CLASSNAME); Array < CIMParamValue > inParams; Array < CIMParamValue > outParams; /* String returnDateTime(); */ CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "returnDateTime", inParams, outParams); PEGASUS_TEST_ASSERT (retValue.getType () == CIMTYPE_DATETIME); PEGASUS_TEST_ASSERT (!retValue.isArray ()); PEGASUS_TEST_ASSERT (!retValue.isNull ()); }
void test1 (CIMClient &client) { CIMObjectPath instanceName; CIMValue output; instanceName.setNameSpace (providerNamespace); instanceName.setClassName (CLASSNAME); Array < CIMParamValue > inParams; Array < CIMParamValue > outParams; AcceptLanguageList accLangs; accLangs.insert(LanguageTag("en-US"),1.0); accLangs.insert(LanguageTag("fr"),0.8); client.setRequestAcceptLanguages(accLangs); CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "testBrokerEnc", inParams, outParams); _checkUint32Value (retValue, 1); }
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; }
void TestDeleteInstances(ProviderRegistrationManager & prmanager) { CIMKeyBinding kb1(CIMName ("ProviderModuleName"), "providersModule1", CIMKeyBinding::STRING); CIMKeyBinding kb2(CIMName ("ProviderName"), "PG_ProviderInstance1", CIMKeyBinding::STRING); CIMKeyBinding kb3(CIMName ("CapabilityID"), "capability1", CIMKeyBinding::STRING); CIMKeyBinding kbp1(CIMName ("ProviderModuleName"), "providersModule1", CIMKeyBinding::STRING); CIMKeyBinding kbp2(CIMName ("Name"), "PG_ProviderInstance1", CIMKeyBinding::STRING); CIMKeyBinding kbm1(CIMName ("Name"), "providersModule1", CIMKeyBinding::STRING); CIMObjectPath instanceName; try { for (Uint32 i=1; i<=3; i++) { CIMObjectPath instanceName2; Array<CIMKeyBinding> keys2; Array<CIMKeyBinding> keysm; Array<CIMKeyBinding> keys; // // create Provider module instances // if (i <= 1) { CIMObjectPath returnRef; CIMClass cimClass(CLASSNAME); CIMInstance cimInstance(CLASSNAME); cimInstance.addProperty(CIMProperty(CIMName ("Name"), String("providersModule1"))); cimInstance.addProperty(CIMProperty(CIMName ("Vendor"), String("HP"))); cimInstance.addProperty(CIMProperty(CIMName ("Version"), String("2.0"))); cimInstance.addProperty(CIMProperty(CIMName ("InterfaceType"), String("PG_DefaultC++"))); cimInstance.addProperty(CIMProperty(CIMName ("InterfaceVersion"), String("2.0"))); cimInstance.addProperty(CIMProperty(CIMName ("Location"), String("/tmp/module1"))); instanceName = cimInstance.buildPath(cimClass); instanceName.setNameSpace(NAMESPACE); instanceName.setClassName(CLASSNAME); returnRef = prmanager.createInstance(instanceName, cimInstance); } // create PG_Provider instances if (i <= 2 ) { CIMObjectPath returnRef2; CIMClass cimClass2(CLASSNAME2); CIMInstance cimInstance2(CLASSNAME2); cimInstance2.addProperty(CIMProperty(CIMName ("ProviderModuleName"), String("providersModule1"))); cimInstance2.addProperty(CIMProperty(CIMName ("Name"), String("PG_ProviderInstance1"))); instanceName2 = cimInstance2.buildPath(cimClass2); instanceName2.setNameSpace(NAMESPACE); instanceName2.setClassName(CLASSNAME2); returnRef2 = prmanager.createInstance(instanceName2, cimInstance2); } // // create provider capability instances // Array <String> namespaces; Array <Uint16> providerType; Array <String> supportedMethods; namespaces.append("test_namespace1"); namespaces.append("test_namespace2"); providerType.append(2); providerType.append(5); supportedMethods.append("test_method1"); supportedMethods.append("test_method2"); CIMObjectPath returnRef3; CIMClass cimClass3(CLASSNAME3); CIMInstance cimInstance3(CLASSNAME3); cimInstance3.addProperty(CIMProperty(CIMName ("ProviderModuleName"), String("providersModule1"))); cimInstance3.addProperty(CIMProperty(CIMName ("ProviderName"), String("PG_ProviderInstance1"))); cimInstance3.addProperty(CIMProperty(CIMName ("CapabilityID"), String("capability1"))); cimInstance3.addProperty(CIMProperty(CIMName ("ClassName"), String("test_class1"))); cimInstance3.addProperty(CIMProperty(CIMName ("Namespaces"), namespaces)); cimInstance3.addProperty(CIMProperty(CIMName ("ProviderType"), providerType)); cimInstance3.addProperty(CIMProperty(CIMName ("SupportedMethods"), supportedMethods)); CIMObjectPath instanceName3 = cimInstance3.buildPath(cimClass3); instanceName3.setNameSpace(NAMESPACE); instanceName3.setClassName(CLASSNAME3); returnRef3 = prmanager.createInstance(instanceName3, cimInstance3); switch (i) { case 1: // // delete cimInstance2 // keys2.append(kbp1); keys2.append(kbp2); instanceName2.setKeyBindings(keys2); prmanager.deleteInstance(instanceName2); break; case 2: // // delete cimInstance3 // keys.append(kb1); keys.append(kb2); keys.append(kb3); instanceName3.setKeyBindings(keys); prmanager.deleteInstance(instanceName3); break; case 3: // // delete cimInstance // keysm.append(kbm1); instanceName.setKeyBindings(keysm); prmanager.deleteInstance(instanceName); break; } } } catch(CIMException& e) { throw (e); } }
void test03 (CIMClient & client) { CIMObjectPath instanceName; instanceName.setNameSpace (providerNamespace); instanceName.setClassName (CLASSNAME); Array < CIMParamValue > inParams; Array < CIMParamValue > outParams; /* uint32 TestCMPIBroker ( * [IN, Description ( * "The requested are to test different * CMPI data structure operations."), * ValueMap { "1", "2", "3", "4", "5", "6"}, * Values {"CDGetType", "CDToString", "CDIsOfType", * "CMGetMessage", "CMLogMessage","CDTraceMessage"}] * uint32 Operation, * [OUT, Description ( * " The result of what the operation carried out.")] * string Result); * */ { /* CDGetType */ inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (1)))); CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "TestCMPIBroker", inParams, outParams); // Check the return value. Make sure it is 0. _checkUint32Value (retValue, 0); PEGASUS_TEST_ASSERT (outParams.size () == 1); CIMValue paramValue = outParams[0].getValue (); _checkStringValue (paramValue, "CMPIArgs"); } inParams.clear (); outParams.clear (); { /* CDToString */ inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (2)))); CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "TestCMPIBroker", inParams, outParams); // Check the return value. Make sure it is 0. _checkUint32Value (retValue, 0); PEGASUS_TEST_ASSERT (outParams.size () == 1); CIMValue paramValue = outParams[0].getValue (); _checkStringValue (paramValue, " Operation:2\n"); } inParams.clear (); outParams.clear (); { /* CDIsOfType */ inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (3)))); CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "TestCMPIBroker", inParams, outParams); // Check the return value. Make sure it is 0. _checkUint32Value (retValue, 0); PEGASUS_TEST_ASSERT (outParams.size () == 1); CIMValue paramValue = outParams[0].getValue (); _checkStringValue (paramValue, "++++ CMPIArgs = Yes"); } inParams.clear (); outParams.clear (); { /* CMGetMessage */ inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (4)))); CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "TestCMPIBroker", inParams, outParams); // Check the return value. Make sure it is 0. _checkUint32Value (retValue, 0); PEGASUS_TEST_ASSERT (outParams.size () == 1); CIMValue paramValue = outParams[0].getValue (); // If PEGASUS_USE_DEFAULT_MESSAGES is not set, we can't make an // assumption about what the value of the msg will be. if (useDefaultMsg) { _checkStringValue (paramValue, "CIM_ERR_SUCCESS: Successful."); } } inParams.clear (); outParams.clear (); { /* CMLogMessage */ inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (5)))); CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "TestCMPIBroker", inParams, outParams); // Check the return value. Make sure it is 0. _checkUint32Value (retValue, 0); // Nothing is returned PEGASUS_TEST_ASSERT (outParams.size () == 1); CIMValue paramValue = outParams[0].getValue (); PEGASUS_TEST_ASSERT (paramValue.isNull ()); } inParams.clear (); outParams.clear (); { /* CMTraceMessage */ inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (6)))); CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "TestCMPIBroker", inParams, outParams); // Check the return value. Make sure it is 0. _checkUint32Value (retValue, 0); // Nothing is returned PEGASUS_TEST_ASSERT (outParams.size () == 1); CIMValue paramValue = outParams[0].getValue (); PEGASUS_TEST_ASSERT (paramValue.isNull ()); } inParams.clear (); outParams.clear (); { // CMGetMessage2 inParams.append(CIMParamValue( "Operation", CIMValue(Uint32(7)))); inParams.append(CIMParamValue( "msgFile", CIMValue(String("test/pegasusTest")))); inParams.append(CIMParamValue( "msgId", CIMValue(String("CIMStatusCode.CIM_ERR_SUCCESS")))); inParams.append(CIMParamValue( "insert1", CIMValue(String("rab oof is foo bar backwards")))); inParams.append(CIMParamValue( "insert2", CIMValue(Uint32(64001)))); AcceptLanguageList accLangs; accLangs.insert(LanguageTag("en-US"),Real32(1.0)); accLangs.insert(LanguageTag("fr"),Real32(0.8)); client.setRequestAcceptLanguages(accLangs); CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "TestCMPIBroker", inParams, outParams); // Check the return value. Make sure it is 0. _checkUint32Value (retValue, 0); PEGASUS_TEST_ASSERT (outParams.size () == 1); CIMValue paramValue = outParams[0].getValue (); // If PEGASUS_USE_DEFAULT_MESSAGES is not set, we can't make an // assumption about what the value of the msg will be, or the // ContentLanguage. #ifdef PEGASUS_HAS_MESSAGES if (useDefaultMsg) { #endif _checkStringValue (paramValue, "CIM_ERR_SUCCESS: Successful."); #ifdef PEGASUS_HAS_MESSAGES } else { ContentLanguageList contLangs; contLangs = client.getResponseContentLanguages(); cout << "ContentLanguage size == " << contLangs.size() << endl; PEGASUS_TEST_ASSERT(contLangs.size() == 1); cout << "ContentLanguage == " << contLangs.getLanguageTag(0).toString(); PEGASUS_TEST_ASSERT( contLangs.getLanguageTag(0).toString() == "en-US"); } #endif // Reset client accLangs.clear(); client.setRequestAcceptLanguages(accLangs); } inParams.clear(); outParams.clear(); { // _testCMPIEnumeration inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (8)))); CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "TestCMPIBroker", inParams, outParams); // Check the return value. Make sure it is 0. _checkUint32Value (retValue, 0); PEGASUS_TEST_ASSERT (outParams.size () == 1); CIMValue paramValue = outParams[0].getValue (); PEGASUS_TEST_ASSERT (paramValue.isNull ()); } inParams.clear(); outParams.clear(); { // _testCMPIArray inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (9)))); CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "TestCMPIBroker", inParams, outParams); // Check the return value. Make sure it is 0. _checkUint32Value (retValue, 0); PEGASUS_TEST_ASSERT (outParams.size () == 1); CIMValue paramValue = outParams[0].getValue (); PEGASUS_TEST_ASSERT (paramValue.isNull ()); } inParams.clear(); outParams.clear(); { // _testCMPIcontext inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (10)))); CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "TestCMPIBroker", inParams, outParams); // Check the return value. Make sure it is 0. _checkUint32Value (retValue, 0); PEGASUS_TEST_ASSERT (outParams.size () == 1); CIMValue paramValue = outParams[0].getValue (); PEGASUS_TEST_ASSERT (paramValue.isNull ()); } inParams.clear(); outParams.clear(); { // _testCMPIDateTime inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (11)))); CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "TestCMPIBroker", inParams, outParams); // Check the return value. Make sure it is 0. _checkUint32Value (retValue, 0); // Nothing is returned PEGASUS_TEST_ASSERT (outParams.size () == 1); CIMValue paramValue = outParams[0].getValue (); PEGASUS_TEST_ASSERT (paramValue.isNull ()); } inParams.clear(); outParams.clear(); { // _testCMPIInstance inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (12)))); CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "TestCMPIBroker", inParams, outParams); // Check the return value. Make sure it is 0. _checkUint32Value (retValue, 0); // Nothing is returned PEGASUS_TEST_ASSERT (outParams.size () == 1); CIMValue paramValue = outParams[0].getValue (); PEGASUS_TEST_ASSERT (paramValue.isNull ()); } inParams.clear(); outParams.clear(); { // _testCMPIObjectPath inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (13)))); CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "TestCMPIBroker", inParams, outParams); // Check the return value. Make sure it is 0. _checkUint32Value (retValue, 0); // Nothing is returned PEGASUS_TEST_ASSERT (outParams.size () == 1); CIMValue paramValue = outParams[0].getValue (); PEGASUS_TEST_ASSERT (paramValue.isNull ()); } inParams.clear(); outParams.clear(); { // _testCMPIResult inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (14)))); CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "TestCMPIBroker", inParams, outParams); // Check the return value. Make sure it is 0. _checkUint32Value (retValue, 0); // Nothing is returned PEGASUS_TEST_ASSERT (outParams.size () == 1); CIMValue paramValue = outParams[0].getValue (); PEGASUS_TEST_ASSERT (paramValue.isNull ()); } inParams.clear(); outParams.clear(); { // _testCMPIString inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (15)))); CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "TestCMPIBroker", inParams, outParams); // Check the return value. Make sure it is 0. _checkUint32Value (retValue, 0); // Nothing is returned PEGASUS_TEST_ASSERT (outParams.size () == 1); CIMValue paramValue = outParams[0].getValue (); PEGASUS_TEST_ASSERT (paramValue.isNull ()); } inParams.clear(); outParams.clear(); { //_testCMPIArgs inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (16)))); CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "TestCMPIBroker", inParams, outParams); //Check the return value. Make sure it is 0. _checkUint32Value (retValue, 0); // Nothing is returned PEGASUS_TEST_ASSERT (outParams.size () == 1); CIMValue paramValue = outParams[0].getValue (); PEGASUS_TEST_ASSERT (paramValue.isNull ()); } inParams.clear(); outParams.clear(); { //_testCMPIBroker inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (17)))); CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "TestCMPIBroker", inParams, outParams); //Check the return value. Make sure it is 0. _checkUint32Value (retValue, 0); // Nothing is returned PEGASUS_TEST_ASSERT (outParams.size () == 1); CIMValue paramValue = outParams[0].getValue (); PEGASUS_TEST_ASSERT (paramValue.isNull ()); } }
// // 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; }
void test14 (CIMClient & client) { CIMObjectPath instanceName; instanceName.setNameSpace (providerNamespace); instanceName.setClassName (CLASSNAME); Array < CIMParamValue > inParams; Array < CIMInstance> eObjs; Array < CIMParamValue > outParams; CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "returnInstance", inParams, outParams); PEGASUS_TEST_ASSERT (retValue.getType () == CIMTYPE_OBJECT); PEGASUS_TEST_ASSERT (!retValue.isArray ()); PEGASUS_TEST_ASSERT (!retValue.isNull ()); CIMObject result; retValue.get (result); CIMObjectPath objPath = result.getPath(); CIMInstance inputInstance(result); CIMInstance outputInstance; eObjs.append(inputInstance); eObjs.append(inputInstance); eObjs.append(inputInstance); inParams.append ( CIMParamValue(String("inputInstances"), CIMValue(eObjs))); retValue = client.invokeMethod (providerNamespace, instanceName, "processArrayEmbeddedInstance", inParams, outParams); // First test the return value PEGASUS_TEST_ASSERT(retValue.getType() == CIMTYPE_INSTANCE); PEGASUS_TEST_ASSERT(!retValue.isArray()); PEGASUS_TEST_ASSERT(!retValue.isNull()); retValue.get(outputInstance); PEGASUS_TEST_ASSERT(objPath.toString() == outputInstance.getPath().toString()); PEGASUS_TEST_ASSERT(outputInstance.getPropertyCount() == inputInstance.getPropertyCount()); for(unsigned int i = 0, n = outputInstance.getPropertyCount(); i < n; ++i) { CIMProperty outputProp(outputInstance.getProperty(i)); CIMProperty inputProp(inputInstance.getProperty(i)); PEGASUS_TEST_ASSERT(outputProp.getName() == inputProp.getName()); PEGASUS_TEST_ASSERT(outputProp.getValue() == inputProp.getValue()); } // Now test the output parameters PEGASUS_TEST_ASSERT(outParams.size() == 3); CIMValue outParamValue = outParams[0].getValue(); PEGASUS_TEST_ASSERT(outParamValue.isArray()); PEGASUS_TEST_ASSERT(!outParamValue.isNull()); Array<CIMInstance> instances; outParamValue.get(instances); for (unsigned int j = 0; j < instances.size () ; ++j) { outputInstance = instances[j]; PEGASUS_TEST_ASSERT(objPath.toString() == outputInstance.getPath().toString()); PEGASUS_TEST_ASSERT(outputInstance.getPropertyCount() == eObjs[j].getPropertyCount()); for(unsigned int i = 0, n = outputInstance.getPropertyCount(); i < n; ++i) { CIMProperty outputProp(outputInstance.getProperty(i)); CIMProperty inputProp(eObjs[j].getProperty(i)); PEGASUS_TEST_ASSERT(outputProp.getName() == inputProp.getName()); PEGASUS_TEST_ASSERT(outputProp.getValue() == inputProp.getValue()); } } outParamValue = outParams[1].getValue(); PEGASUS_TEST_ASSERT(outParamValue.isArray()); PEGASUS_TEST_ASSERT(!outParamValue.isNull()); Array<CIMObject> objs; outParamValue.get(objs); for (unsigned int j = 0; j < objs.size () ; ++j) { outputInstance = CIMInstance(objs[j]); PEGASUS_TEST_ASSERT(objPath.toString() == outputInstance.getPath().toString()); PEGASUS_TEST_ASSERT(outputInstance.getPropertyCount() == eObjs[j].getPropertyCount()); for(unsigned int i = 0, n = outputInstance.getPropertyCount(); i < n; ++i) { CIMProperty outputProp(outputInstance.getProperty(i)); CIMProperty inputProp(eObjs[j].getProperty(i)); PEGASUS_TEST_ASSERT(outputProp.getName() == inputProp.getName()); PEGASUS_TEST_ASSERT(outputProp.getValue() == inputProp.getValue()); } } outParamValue = outParams[2].getValue(); PEGASUS_TEST_ASSERT(outParamValue.isArray()); PEGASUS_TEST_ASSERT(!outParamValue.isNull()); outParamValue.get(objs); for (Uint32 j = 0, m = objs.size(); j < m ; ++j) { outputInstance = CIMInstance(objs[j]); Uint32 id; CIMInstance emInstance; CIMObject emObject; outputInstance.getProperty( outputInstance.findProperty("id")).getValue().get(id); outputInstance.getProperty( outputInstance.findProperty("emInstance")). getValue().get(emInstance); outputInstance.getProperty( outputInstance.findProperty("emObject")).getValue().get(emObject); PEGASUS_TEST_ASSERT(eObjs[j].identical(emInstance)); PEGASUS_TEST_ASSERT(eObjs[j].identical(CIMInstance(emObject))); PEGASUS_TEST_ASSERT(id == j+1); } }
/** * This tests the embedded instance functionality through the CMPI Test * Method Provider. It first invokes the returnInstance() method to retrieve * an instance that can be used */ void test09 (CIMClient & client) { CIMObjectPath instanceName; instanceName.setNameSpace (providerNamespace); instanceName.setClassName (CLASSNAME); Array < CIMParamValue > inParams; Array < CIMParamValue > outParams; /* [EmbeddedObject] String returnInstance(); */ CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "returnInstance", inParams, outParams); PEGASUS_TEST_ASSERT (retValue.getType () == CIMTYPE_OBJECT); PEGASUS_TEST_ASSERT (!retValue.isArray ()); PEGASUS_TEST_ASSERT (!retValue.isNull ()); CIMObject result; retValue.get (result); CIMObjectPath objPath = result.getPath(); CIMInstance inputInstance(result); CIMInstance outputInstance; inParams.append( CIMParamValue(String("inputInstance"), CIMValue(inputInstance))); retValue = client.invokeMethod (providerNamespace, instanceName, "processEmbeddedInstance", inParams, outParams); // First test the return value PEGASUS_TEST_ASSERT(retValue.getType() == CIMTYPE_INSTANCE); PEGASUS_TEST_ASSERT(!retValue.isArray()); PEGASUS_TEST_ASSERT(!retValue.isNull()); retValue.get(outputInstance); PEGASUS_TEST_ASSERT(objPath.toString() == outputInstance.getPath().toString()); PEGASUS_TEST_ASSERT(outputInstance.getPropertyCount() == inputInstance.getPropertyCount()); for(unsigned int i = 0, n = outputInstance.getPropertyCount(); i < n; ++i) { CIMProperty outputProp(outputInstance.getProperty(i)); CIMProperty inputProp(inputInstance.getProperty(i)); PEGASUS_TEST_ASSERT(outputProp.getName() == inputProp.getName()); PEGASUS_TEST_ASSERT(outputProp.getValue() == inputProp.getValue()); } // Now test the output parameter PEGASUS_TEST_ASSERT(outParams.size() == 1); retValue = outParams[0].getValue(); PEGASUS_TEST_ASSERT(retValue.getType() == CIMTYPE_INSTANCE); PEGASUS_TEST_ASSERT(!retValue.isArray()); PEGASUS_TEST_ASSERT(!retValue.isNull()); retValue.get(outputInstance); PEGASUS_TEST_ASSERT(objPath.toString() == outputInstance.getPath().toString()); PEGASUS_TEST_ASSERT(outputInstance.getPropertyCount() == inputInstance.getPropertyCount()); for(unsigned int i = 0, n = outputInstance.getPropertyCount(); i < n; ++i) { CIMProperty outputProp(outputInstance.getProperty(i)); CIMProperty inputProp(inputInstance.getProperty(i)); PEGASUS_TEST_ASSERT(outputProp.getName() == inputProp.getName()); PEGASUS_TEST_ASSERT(outputProp.getValue() == inputProp.getValue()); } }
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)); CIMObjectPath instanceName3 = cimInstance3.buildPath(cimClass3); instanceName3.setNameSpace(NAMESPACE); instanceName3.setClassName(CLASSNAME3); try { returnRef3 = prmanager.createInstance(instanceName3, cimInstance3); } catch(const CIMException&) { throw; } // find the instance provider // String _providerModuleName; String _providerModuleName2; CIMInstance providerIns; CIMInstance providerModuleIns; if (prmanager.lookupInstanceProvider(CIMNamespaceName ("test_namespace1"), CIMName ("test_class1"), providerIns, providerModuleIns)) { providerIns.getProperty(providerIns.findProperty (CIMName ("ProviderModuleName"))).getValue().get (_providerModuleName); providerModuleIns.getProperty(providerModuleIns.findProperty (CIMName ("Name"))).getValue().get(_providerModuleName2); if (String::equal(_providerModuleName, _providerModuleName2)) { return (true); } else { return (false); } } else { return (false); } }
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); }
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; } }
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; } }
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."); }
void TestCreateInstances(CIMClient& client) { // // Test create Provider module instances // CIMObjectPath returnRef; CIMClass cimClass(CLASSNAME); CIMInstance cimInstance(CLASSNAME); cimInstance.addProperty(CIMProperty(CIMName ("Name"), String("providersModule1"))); cimInstance.addProperty(CIMProperty(CIMName ("Vendor"), String("HP"))); cimInstance.addProperty(CIMProperty(CIMName ("Version"), String("2.0"))); cimInstance.addProperty(CIMProperty(CIMName ("InterfaceType"), String("C++Default"))); cimInstance.addProperty(CIMProperty(CIMName ("InterfaceVersion"), String("2.1.0"))); cimInstance.addProperty(CIMProperty(CIMName ("Location"), String("/tmp/module1"))); CIMObjectPath instanceName = cimInstance.buildPath(cimClass); instanceName.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP); instanceName.setClassName(CLASSNAME); try { returnRef = client.createInstance(PEGASUS_NAMESPACENAME_INTEROP, cimInstance); } catch(const CIMException&) { throw; } // Test create PG_Provider instances CIMObjectPath returnRef2; CIMClass cimClass2(CLASSNAME2); CIMInstance cimInstance2(CLASSNAME2); cimInstance2.addProperty(CIMProperty(CIMName ("ProviderModuleName"), String("providersModule1"))); cimInstance2.addProperty(CIMProperty(CIMName ("Name"), String("PG_ProviderInstance1"))); CIMObjectPath instanceName2 = cimInstance2.buildPath(cimClass2); instanceName2.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP); instanceName2.setClassName(CLASSNAME2); try { returnRef2 = client.createInstance(PEGASUS_NAMESPACENAME_INTEROP, cimInstance2); } catch(const CIMException&) { throw; } // // test create provider capability instances // Array <String> namespaces; Array <Uint16> providerType; Array <String> supportedMethods; Array <String> supportedProperties; namespaces.append("root/cimv2"); namespaces.append("root/cimv3"); providerType.append(4); providerType.append(5); supportedMethods.append("test_method1"); supportedMethods.append("test_method2"); supportedProperties.append("PkgStatus"); supportedProperties.append("PkgIndex"); CIMObjectPath returnRef3; CIMClass cimClass3(CLASSNAME3); CIMInstance cimInstance3(CLASSNAME3); cimInstance3.addProperty(CIMProperty(CIMName ("ProviderModuleName"), String("providersModule1"))); cimInstance3.addProperty(CIMProperty(CIMName ("ProviderName"), String("PG_ProviderInstance1"))); cimInstance3.addProperty(CIMProperty(CIMName ("CapabilityID"), String("capability1"))); cimInstance3.addProperty(CIMProperty(CIMName ("ClassName"), String("TestSoftwarePkg"))); cimInstance3.addProperty(CIMProperty(CIMName ("Namespaces"), namespaces)); cimInstance3.addProperty(CIMProperty(CIMName ("ProviderType"), providerType)); cimInstance3.addProperty(CIMProperty(CIMName ("SupportedMethods"), supportedMethods)); cimInstance3.addProperty(CIMProperty(CIMName ("SupportedProperties"), supportedProperties)); CIMObjectPath instanceName3 = cimInstance3.buildPath(cimClass3); instanceName3.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP); instanceName3.setClassName(CLASSNAME3); try { returnRef3 = client.createInstance(PEGASUS_NAMESPACENAME_INTEROP, cimInstance3); } catch(const CIMException&) { throw; } CIMKeyBinding kb1(CIMName ("Name"), "providersModule1", CIMKeyBinding::STRING); Array<CIMKeyBinding> keys; keys.append(kb1); instanceName.setKeyBindings(keys); // test getInstance try { client.getInstance(PEGASUS_NAMESPACENAME_INTEROP, instanceName); } catch(const CIMException&) { throw; } // test enumerateInstances try { client.enumerateInstances(PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PROVIDER); } catch(const CIMException&) { throw; } // test enumerateInstanceNames try { client.enumerateInstanceNames(PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PROVIDER); } catch(const CIMException&) { throw; } client.deleteInstance(PEGASUS_NAMESPACENAME_INTEROP, instanceName); }
void TestModifyInstances(ProviderRegistrationManager & prmanager) { // // create Provider module instances // CIMObjectPath returnRef; CIMClass cimClass(CLASSNAME); CIMInstance cimInstance(CLASSNAME); cimInstance.addProperty(CIMProperty(CIMName ("Name"), String("providersModule1"))); cimInstance.addProperty(CIMProperty(CIMName ("Vendor"), String("HP"))); cimInstance.addProperty(CIMProperty(CIMName ("Version"), String("2.0"))); cimInstance.addProperty(CIMProperty(CIMName ("InterfaceType"), String("PG_DefaultC++"))); cimInstance.addProperty(CIMProperty(CIMName ("InterfaceVersion"), String("2.0"))); cimInstance.addProperty(CIMProperty(CIMName ("Location"), String("/tmp/module1"))); CIMObjectPath instanceName = cimInstance.buildPath(cimClass); instanceName.setNameSpace(NAMESPACE); instanceName.setClassName(CLASSNAME); try { returnRef = prmanager.createInstance(instanceName, cimInstance); } catch(CIMException& e) { throw (e); } // create PG_Provider instances CIMObjectPath returnRef2; CIMClass cimClass2(CLASSNAME2); CIMInstance cimInstance2(CLASSNAME2); cimInstance2.addProperty(CIMProperty(CIMName ("ProviderModuleName"), String("providersModule1"))); cimInstance2.addProperty(CIMProperty(CIMName ("Name"), String("PG_ProviderInstance1"))); CIMObjectPath instanceName2 = cimInstance2.buildPath(cimClass2); instanceName2.setNameSpace(NAMESPACE); instanceName2.setClassName(CLASSNAME2); try { returnRef2 = prmanager.createInstance(instanceName2, cimInstance2); } catch(CIMException& e) { throw (e); } // // create provider capability instances // Array <String> namespaces; Array <Uint16> providerType; Array <String> supportedMethods; Array <String> supportedProperties; namespaces.append("root/cimv2"); namespaces.append("root/cimv3"); providerType.append(2); providerType.append(5); supportedMethods.append("test_method1"); supportedMethods.append("test_method2"); supportedProperties.append("PkgStatus"); supportedProperties.append("PkgIndex"); CIMObjectPath returnRef3; CIMClass cimClass3(CLASSNAME3); CIMInstance cimInstance3(CLASSNAME3); cimInstance3.addProperty(CIMProperty(CIMName ("ProviderModuleName"), String("providersModule1"))); cimInstance3.addProperty(CIMProperty(CIMName ("ProviderName"), String("PG_ProviderInstance1"))); cimInstance3.addProperty(CIMProperty(CIMName ("CapabilityID"), String("capability1"))); cimInstance3.addProperty(CIMProperty(CIMName ("ClassName"), String("TestSoftwarePkg"))); cimInstance3.addProperty(CIMProperty(CIMName ("Namespaces"), namespaces)); cimInstance3.addProperty(CIMProperty(CIMName ("ProviderType"), providerType)); cimInstance3.addProperty(CIMProperty(CIMName ("SupportedMethods"), supportedMethods)); cimInstance3.addProperty(CIMProperty(CIMName ("SupportedProperties"), supportedProperties)); CIMObjectPath instanceName3 = cimInstance3.buildPath(cimClass3); instanceName3.setNameSpace(NAMESPACE); instanceName3.setClassName(CLASSNAME3); try { returnRef3 = prmanager.createInstance(instanceName3, cimInstance3); } catch(const CIMException&) { throw; } // create CIMObjectPath Array<CIMKeyBinding> keys; CIMKeyBinding kb1(CIMName ("ProviderModuleName"), "providersModule1", CIMKeyBinding::STRING); CIMKeyBinding kb2(CIMName ("ProviderName"), "PG_ProviderInstance1", CIMKeyBinding::STRING); CIMKeyBinding kb3(CIMName ("CapabilityID"), "capability1", CIMKeyBinding::STRING); keys.append(kb1); keys.append(kb2); keys.append(kb3); instanceName3.setKeyBindings(keys); Array <String> supportedMethods2; Array <String> namespaces2; Array<CIMName> propertyList; // create new instance which will replace cimInstance3 CIMInstance cimInstance4(CLASSNAME3); namespaces2.append("root/cimv4"); namespaces2.append("root/cimv5"); supportedMethods2.append("test_method2"); supportedMethods2.append("test_method3"); cimInstance4.addProperty(CIMProperty(CIMName ("Namespaces"), namespaces2)); cimInstance4.addProperty(CIMProperty(CIMName ("SupportedMethods"), supportedMethods2)); propertyList.append(CIMName ("Namespaces")); propertyList.append(CIMName ("SupportedMethods")); try { prmanager.modifyInstance(instanceName3, cimInstance4, false, propertyList); } catch(const CIMException&) { throw; } }
void _generateIndication ( IndicationResponseHandler * handler, const CIMName methodName) { if (_enabled) { CIMInstance indicationInstance; if (methodName.equal ("SendTestIndicationSubclass")) { CIMInstance theIndication (CIMName ("RT_TestIndicationSubclass")); indicationInstance = theIndication; } else { CIMInstance theIndication (CIMName ("RT_TestIndication")); indicationInstance = theIndication; } CIMObjectPath path; if (methodName.equal ("SendTestIndicationUnmatchingNamespace")) { // // For SendTestIndicationUnmatchingNamespace, generate an // indication instance with namespace that does not match the // subscription instance name included in the operation context // (nor does it match the namespace for which provider has // registered) // path.setNameSpace ("root/cimv2"); path.setClassName ("RT_TestIndication"); } else if (methodName.equal ("SendTestIndicationUnmatchingClassName")) { // the indication class name and object path class must match indicationInstance = CIMInstance("CIM_AlertIndication"); // // For SendTestIndicationUnmatchingClassName, generate an // indication instance with classname that does not match the // subscription instance name included in the operation context // (nor does it match the classname for which provider has // registered) // path.setNameSpace ("root/SampleProvider"); path.setClassName ("CIM_AlertIndication"); } else if (methodName.equal ("SendTestIndicationSubclass")) { // // For SendTestIndicationSubclass, generate an indication instance // of a the RT_TestIndicationSubclass subclass // path.setNameSpace ("root/SampleProvider"); path.setClassName ("RT_TestIndicationSubclass"); } else { path.setNameSpace("root/SampleProvider"); path.setClassName("RT_TestIndication"); } indicationInstance.setPath(path); char buffer[32]; sprintf(buffer, "%d", _nextUID++); indicationInstance.addProperty (CIMProperty ("IndicationIdentifier",String(buffer))); CIMDateTime currentDateTime = CIMDateTime::getCurrentDateTime (); indicationInstance.addProperty (CIMProperty ("IndicationTime", currentDateTime)); // // For SendTestIndicationMissingProperty, leave out the // CorrelatedIndications property // if (!methodName.equal ("SendTestIndicationMissingProperty")) { Array <String> correlatedIndications; indicationInstance.addProperty (CIMProperty ("CorrelatedIndications", correlatedIndications)); } if ((methodName.equal ("SendTestIndicationNormal")) || (methodName.equal ("SendTestIndicationSubclass")) || (methodName.equal ("SendTestIndicationMissingProperty")) || (methodName.equal ("SendTestIndicationExtraProperty")) || (methodName.equal ("SendTestIndicationMatchingInstance")) || (methodName.equal ("SendTestIndicationUnmatchingNamespace")) || (methodName.equal ("SendTestIndicationUnmatchingClassName"))) { indicationInstance.addProperty (CIMProperty ("MethodName", CIMValue (methodName.getString()))); } else { indicationInstance.addProperty (CIMProperty ("MethodName", CIMValue (String ("generateIndication")))); } // // For SendTestIndicationExtraProperty, add an extra property, // ExtraProperty, that is not a member of the indication class // if (methodName.equal ("SendTestIndicationExtraProperty")) { indicationInstance.addProperty (CIMProperty ("ExtraProperty", CIMValue (String ("extraProperty")))); } CIMIndication cimIndication (indicationInstance); // // For SendTestIndicationSubclass, // SendTestIndicationMatchingInstance, // SendTestIndicationUnmatchingNamespace or // SendTestIndicationUnmatchingClassName, include // SubscriptionInstanceNamesContainer in operation context // if ((methodName.equal ("SendTestIndicationSubclass")) || (methodName.equal ("SendTestIndicationMatchingInstance")) || (methodName.equal ("SendTestIndicationUnmatchingNamespace")) || (methodName.equal ("SendTestIndicationUnmatchingClassName"))) { Array <CIMObjectPath> subscriptionInstanceNames; Array <CIMKeyBinding> subscriptionKeyBindings; String filterString; filterString.append ("CIM_IndicationFilter.CreationClassName=\"CIM_IndicationFilter\",Name=\"PIFilter01\",SystemCreationClassName=\""); filterString.append (System::getSystemCreationClassName ()); filterString.append ("\",SystemName=\""); filterString.append (System::getFullyQualifiedHostName ()); filterString.append ("\""); subscriptionKeyBindings.append (CIMKeyBinding ("Filter", filterString, CIMKeyBinding::REFERENCE)); String handlerString; handlerString.append ("CIM_IndicationHandlerCIMXML.CreationClassName=\"CIM_IndicationHandlerCIMXML\",Name=\"PIHandler01\",SystemCreationClassName=\""); handlerString.append (System::getSystemCreationClassName ()); handlerString.append ("\",SystemName=\""); handlerString.append (System::getFullyQualifiedHostName ()); handlerString.append ("\""); subscriptionKeyBindings.append (CIMKeyBinding ("Handler", handlerString, CIMKeyBinding::REFERENCE)); CIMObjectPath subscriptionPath ("", CIMNamespaceName ("root/PG_InterOp"), CIMName ("CIM_IndicationSubscription"), subscriptionKeyBindings); subscriptionInstanceNames.append (subscriptionPath); OperationContext context; context.insert (SubscriptionInstanceNamesContainer (subscriptionInstanceNames)); handler->deliver (context, indicationInstance); } else { // deliver an indication without trapOid handler->deliver (indicationInstance); } // // Only deliver extra indication with trapOid for SendTestIndication // if ((!methodName.equal ("SendTestIndicationNormal")) && (!methodName.equal ("SendTestIndicationSubclass")) && (!methodName.equal ("SendTestIndicationMissingProperty")) && (!methodName.equal ("SendTestIndicationExtraProperty")) && (!methodName.equal ("SendTestIndicationMatchingInstance")) && (!methodName.equal ("SendTestIndicationUnmatchingNamespace")) && (!methodName.equal ("SendTestIndicationUnmatchingClassName"))) { // deliver another indication with a trapOid which contains in the // operationContext container OperationContext context; // add trap OID to the context context.insert (SnmpTrapOidContainer("1.3.6.1.4.1.900.2.3.9002.9600")); handler->deliver (context, indicationInstance); } } }
// // 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 *)propertyList.toString().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; } TARGET_CLASS classEnum = translateClassInput(opClass); CIMInstance retInstance; switch(classEnum) { case PG_SOFTWAREIDENTITY: { retInstance = getSoftwareIdentityInstance(instanceName); normalizeInstance( retInstance, instanceName, false, false, propertyList); } break; case PG_NAMESPACE: { retInstance = getNameSpaceInstance(instanceName); normalizeInstance( retInstance, instanceName, false, false, propertyList); } break; // ATTN: Implement getIntstance for all other classes. Currently // this method calls localEnumerateInstances() to select instance // which is too expensive. default: { // 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); ConstArrayIterator<CIMInstance> instancesIter(instances); // deliver a single instance if found. bool found = false; for(Uint32 i = 0; i < instancesIter.size(); i++) { CIMObjectPath currentInstRef = instancesIter[i].getPath(); currentInstRef.setHost(instanceName.getHost()); currentInstRef.setNameSpace(instanceName.getNameSpace()); if(instanceName == currentInstRef) { retInstance = instancesIter[i]; found = true; break; } } if (!found) { PEG_METHOD_EXIT(); throw CIMObjectNotFoundException(instanceName.toString()); } } } PEG_METHOD_EXIT(); return retInstance; }
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); } }
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; } } } break; } } PEG_METHOD_EXIT(); return referencedInstances; }