void LargeDataProvider::enumerateInstances( const OperationContext & context, const CIMObjectPath & classReference, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList & propertyList, InstanceResponseHandler & handler) { char buffer[NO_OF_INSTANCES]; CIMInstance Instances[NO_OF_INSTANCES]; CIMObjectPath References[NO_OF_INSTANCES]; cout << "-------------------------------------" << endl; cout << "LargeDataProvider::enumerateInstances" << endl; cout << "-------------------------------------" << endl; // announce operation processing. handler.processing(); // creating some instances in a loop for generating a large amount of data // The number of instances is controlled by the macro var. NO_OF_INSTANCES. // TODO:: Need to fix the way in which the value of this variable is passed cout << "Number of Instances = " << NO_OF_INSTANCES << endl; for (Uint32 i = 0; i < NO_OF_INSTANCES; i++) { sprintf(buffer, "%d", i); Instances[i] = CIMInstance("SampleClass"); References[i] = CIMObjectPath("SampleClass.Id="+String(buffer)); Instances[i].addProperty(CIMProperty("Id", Uint16(i))); Instances[i].addProperty(CIMProperty("Message", String(buffer))); Instances[i].addProperty(CIMProperty("ReqType", String("Local"))); Instances[i].addProperty(CIMProperty("RequestNumber", Uint16(i+10))); Instances[i].addProperty(CIMProperty("TimeSpent", Uint16(i+2))); Instances[i].addProperty(CIMProperty("TimeIdeal", Uint16(100))); Instances[i].addProperty( CIMProperty("Performance", String("OK \00><\00"))); Instances[i].addProperty(CIMProperty("EndPoint", String("Instance "+String(buffer)+" Ends"))); _instances.append(Instances[i]); _instanceNames.append(References[i]); } for(Uint32 i = 0; i < NO_OF_INSTANCES; i++) // deliver instance handler.deliver(_instances[i]); // complete processing the request handler.complete(); }
CIMInstance CIMHelper::extractInstanceParameter(const Array<CIMParamValue>& inParameters, String name) { for(Uint32 i = 0; i < inParameters.size(); i++) { CIMParamValue paramValue = inParameters[i]; CIMName paramName = paramValue.getParameterName(); if (paramName.equal(name)) { CIMInstance value; paramValue.getValue().get(value); return value; } } return CIMInstance(); }
void ExecQueryResponseHandler::transfer() { CIMExecQueryResponseMessage& msg = *static_cast<CIMExecQueryResponseMessage*>(getResponse()); Array<CIMObject> cimObjs= getObjects(); Array<SCMOInstance> scmoObjs= getSCMOObjects(); if (cimObjs.size() != 0) { // complete keybindings based on set property values CIMOperationRequestMessage * reqMsg = (CIMOperationRequestMessage*) _request; Boolean clsRead=false; for (Uint32 j = 0, m = cimObjs.size(); j < m; j++) { CIMObject & co=cimObjs[j]; CIMObjectPath op=co.getPath(); const Array<CIMKeyBinding>& kbs=op.getKeyBindings(); if (kbs.size()==0) { // no path set why ? if (clsRead==false || _cimClass.isUninitialized()) { SCMOClassCache * classCache = SCMOClassCache::getInstance(); CString nsName = reqMsg->nameSpace.getString().getCString(); CString clName = reqMsg->className.getString().getCString(); SCMOClass theClass = classCache->getSCMOClass( nsName, strlen(nsName), clName, strlen(clName)); theClass.getCIMClass(_cimClass); clsRead=true; } op = CIMInstance(co).buildPath(_cimClass); } op.setNameSpace(reqMsg->nameSpace); op.setHost(System::getHostName()); co.setPath(op); } msg.getResponseData().setObjects(cimObjs); } if (scmoObjs.size() != 0) { msg.getResponseData().setSCMO(scmoObjs); } }
CIMInstance UNIX_AssociatedIndicatorLED::getDependent() const { return CIMInstance(CIMName("CIM_Dependency")); }
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); } }
CIMInstance UNIX_AuthenticateForUse::getDependent() const { return CIMInstance(CIMName("CIM_Dependency")); }
CIMInstance UNIX_AssociatedProtocolController::getDependent() const { return CIMInstance(CIMName("CIM_Dependency")); }
CIMInstance UNIX_BGPAdminDistance::getDependent() const { return CIMInstance(CIMName("CIM_Dependency")); }
CIMInstance UNIX_ComputerSystemProcessor::getGroupComponent() const { return CIMInstance(CIMName("CIM_Component")); }
CIMInstance UNIX_CalculationServiceForDropper::getDependent() const { return CIMInstance(CIMName("CIM_Dependency")); }
void TestAssociations(CIMRepository& r) { String nameSpace = "root"; { CIMObjectPath instanceName = CIMObjectPath ("X.key=\"John Smith\""); Array<CIMObjectPath> names = r.associatorNames( nameSpace, instanceName, CIMName ("A"), CIMName ("Y"), "left", "right"); assert(names.size() == 1); Boolean cond = names[0] == CIMObjectPath("Y.key=\"John Jones\""); assert(cond); } { CIMObjectPath instanceName = CIMObjectPath ("X.key=\"John Smith\""); Array<CIMObject> result = r.associators( nameSpace, instanceName, CIMName ("a"), CIMName ("y"), "LEFT", "RIGHT"); assert(result.size() == 1); CIMObjectPath cimReference = result[0].getPath (); CIMInstance cimInstance = CIMInstance(result[0]); CIMClass tmpClass = r.getClass(nameSpace, cimInstance.getClassName()); CIMObjectPath tmpInstanceName = cimInstance.buildPath(tmpClass); Boolean t = tmpInstanceName == CIMObjectPath("Y.key=\"John Jones\""); assert(t); // result[0].print(); } { CIMObjectPath instanceName = CIMObjectPath ("X.key=\"John Smith\""); Array<CIMObjectPath> result = r.referenceNames( nameSpace, instanceName, CIMName ("A"), "left"); assert(result.size() == 1); CIMObjectPath tmp = CIMObjectPath ("A." "left=\"x.key=\\\"John Smith\\\"\"," "right=\"y.key=\\\"John Jones\\\"\""); Boolean cond = (result[0] == tmp); assert(cond); } { CIMObjectPath instanceName = CIMObjectPath ("X.key=\"John Smith\""); Array<CIMObject> result = r.references( nameSpace, instanceName, CIMName ("A"), "left"); assert(result.size() == 1); CIMClass tmpClass = r.getClass( nameSpace, CIMInstance(result[0]).getClassName()); CIMObjectPath tmpInstanceName = CIMInstance(result[0]).buildPath(tmpClass); CIMObjectPath tmp = CIMObjectPath ("A." "left=\"x.key=\\\"John Smith\\\"\"," "right=\"y.key=\\\"John Jones\\\"\""); Boolean cond = (tmpInstanceName == tmp); assert(cond); } // Delete all the object we created: { // First delete the association: CIMObjectPath assocInstanceName = CIMObjectPath ("A." "left=\"x.key=\\\"John Smith\\\"\"," "right=\"y.key=\\\"John Jones\\\"\""); r.deleteInstance(nameSpace, assocInstanceName); } }
// test null object checks void Test1(void) { if(verbose) { cout << "Test1()" << endl; } try { // create dummy request and response messages CIMGetInstanceRequestMessage request( String::EMPTY, CIMNamespaceName(), CIMObjectPath("dummy"), false, false, false, CIMPropertyList(), QueueIdStack()); CIMGetInstanceResponseMessage response( String::EMPTY, CIMException(), QueueIdStack(), CIMInstance()); GetInstanceResponseHandler handler(&request, &response); handler.processing(); CIMInstance cimInstance; handler.deliver(cimInstance); handler.complete(); throw Exception("Failed to detect null object in CIMGetInstanceResponseHandler::deliver()."); } catch(CIMException &) { // do nothing expected } try { // create dummy request and response messages CIMEnumerateInstancesRequestMessage request( String::EMPTY, CIMNamespaceName(), CIMName("dummy"), false, false, false, false, CIMPropertyList(), QueueIdStack()); CIMEnumerateInstancesResponseMessage response( String::EMPTY, CIMException(), QueueIdStack(), Array<CIMInstance>()); EnumerateInstancesResponseHandler handler(&request, &response); handler.processing(); CIMInstance cimInstance; handler.deliver(cimInstance); handler.complete(); throw Exception("Failed to detect null object in CIMEnumerateInstancesResponseHandler::deliver()."); } catch(CIMException &) { // do nothing expected } try { // create dummy request and response messages CIMEnumerateInstanceNamesRequestMessage request( String::EMPTY, CIMNamespaceName(), CIMName("dummy"), QueueIdStack()); CIMEnumerateInstanceNamesResponseMessage response( String::EMPTY, CIMException(), QueueIdStack(), Array<CIMObjectPath>()); EnumerateInstanceNamesResponseHandler handler(&request, &response); handler.processing(); CIMObjectPath cimObjectPath; handler.deliver(cimObjectPath); handler.complete(); throw Exception("Failed to detect null object in CIMEnumerateInstanceNamesResponseHandler::deliver()."); } catch(CIMException &) { // do nothing expected } try { // create dummy request and response messages CIMCreateInstanceRequestMessage request( String::EMPTY, CIMNamespaceName(), CIMInstance("dummy"), QueueIdStack()); CIMCreateInstanceResponseMessage response( String::EMPTY, CIMException(), QueueIdStack(), CIMObjectPath()); CreateInstanceResponseHandler handler(&request, &response); handler.processing(); CIMObjectPath cimObjectPath; handler.deliver(cimObjectPath); handler.complete(); throw Exception("Failed to detect null object in CIMCreateInstanceResponseHandler::deliver()."); } catch(CIMException &) { } }
// test too many or too few objects delivered void Test2(void) { if(verbose) { cout << "Test2()" << endl; } try { // create dummy request and response messages CIMGetInstanceRequestMessage request( String::EMPTY, CIMNamespaceName(), CIMObjectPath("dummy"), false, false, false, CIMPropertyList(), QueueIdStack()); CIMGetInstanceResponseMessage response( String::EMPTY, CIMException(), QueueIdStack(), CIMInstance()); GetInstanceResponseHandler handler(&request, &response); handler.processing(); handler.complete(); throw Exception("Failed to detect too few objects in CIMGetInstanceResponseHandler::complete()."); } catch(CIMException &) { // do nothing expected } try { // create dummy request and response messages CIMGetInstanceRequestMessage request( String::EMPTY, CIMNamespaceName(), CIMObjectPath("dummy"), false, false, false, CIMPropertyList(), QueueIdStack()); CIMGetInstanceResponseMessage response( String::EMPTY, CIMException(), QueueIdStack(), CIMInstance()); GetInstanceResponseHandler handler(&request, &response); handler.processing(); CIMInstance cimInstance1("dummy"); handler.deliver(cimInstance1); CIMInstance cimInstance2("dummy"); handler.deliver(cimInstance2); handler.complete(); throw Exception("Failed to detect too many objects in CIMGetInstanceResponseHandler::deliver()."); } catch(CIMException &) { // do nothing expected } try { // create dummy request and response messages CIMCreateInstanceRequestMessage request( String::EMPTY, CIMNamespaceName(), CIMInstance("dummy"), QueueIdStack()); CIMCreateInstanceResponseMessage response( String::EMPTY, CIMException(), QueueIdStack(), CIMObjectPath()); CreateInstanceResponseHandler handler(&request, &response); handler.processing(); handler.complete(); throw Exception("Failed to detect too few objects in CIMCreateInstanceResponseHandler::complete()."); } catch(CIMException &) { } try { // create dummy request and response messages CIMCreateInstanceRequestMessage request( String::EMPTY, CIMNamespaceName(), CIMInstance("dummy"), QueueIdStack()); CIMCreateInstanceResponseMessage response( String::EMPTY, CIMException(), QueueIdStack(), CIMObjectPath()); CreateInstanceResponseHandler handler(&request, &response); handler.processing(); CIMObjectPath cimObjectPath1("dummy"); handler.deliver(cimObjectPath1); CIMObjectPath cimObjectPath2("dummy"); handler.deliver(cimObjectPath2); handler.complete(); throw Exception("Failed to detect too many objects in CIMGetInstanceResponseHandler::deliver()."); } catch(CIMException &) { // do nothing expected } }
CIMInstance UNIX_BGPServiceStatistics::getElement() const { return CIMInstance(CIMName("CIM_ManagedElement")); }
CIMInstance UNIX_CollectionInSystem::getChild() const { return CIMInstance(CIMName("CIM_ManagedElement")); }
CIMInstance UNIX_AssociatedRemainingExtent::getPartComponent() const { return CIMInstance(CIMName("CIM_Component")); }
static void TestExceptionHandling(CIMHandler* handler) { CIMInstance indicationHandlerInstance; // Test "invalid IndicationHandlerSNMPMapper instance" exception CIMInstance indicationInstance(testClass1); indicationHandlerInstance = CreateHandlerInstance(); TestException(handler, indicationHandlerInstance, indicationInstance, CIM_ERR_FAILED); // Test "no required property TargetHostFormat" exception indicationInstance = CIMInstance(testClass1); indicationInstance.addProperty(CIMProperty( CIMName ("OidDataType"), String("OctetString"))); indicationHandlerInstance = CreateHandlerInstance(); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHost"), String("15.13.140.120"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPVersion"), Uint16(2))); TestException(handler, indicationHandlerInstance, indicationInstance, CIM_ERR_FAILED); // Test "no required property SNMPVersion" exception indicationInstance = CIMInstance(testClass1); indicationHandlerInstance = CreateHandlerInstance(); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHost"), String("15.13.140.120"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHostFormat"), Uint16(3))); TestException(handler, indicationHandlerInstance, indicationInstance, CIM_ERR_FAILED); // Test "unsupported snmp Version" exception indicationInstance = CIMInstance(testClass1); indicationHandlerInstance = CreateHandlerInstance(); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHost"), String("15.13.140.120"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHostFormat"), Uint16(3))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPVersion"), Uint16(5))); TestException(handler, indicationHandlerInstance, indicationInstance, CIM_ERR_FAILED); // Test "invalid MappingStrings Syntax" exception indicationInstance = CIMInstance(testClass8); indicationInstance.addProperty(CIMProperty( CIMName ("OidDataType"), String("OctetString"))); indicationHandlerInstance = CreateHandlerInstance(); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHost"), String("15.13.140.120"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHostFormat"), Uint16(3))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPVersion"), Uint16(2))); TestException(handler, indicationHandlerInstance, indicationInstance, CIM_ERR_FAILED); // Test "invalid MappingStrings value" exception indicationInstance = CIMInstance(testClass2); indicationInstance.addProperty(CIMProperty( CIMName ("OidDataType"), String("OctetString"))); indicationHandlerInstance = CreateHandlerInstance(); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHost"), String("15.13.140.120"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHostFormat"), Uint16(3))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPVersion"), Uint16(2))); TestException(handler, indicationHandlerInstance, indicationInstance, CIM_ERR_FAILED); // Test "no MappingStrings qualifier" exception indicationInstance = CIMInstance(testClass3); indicationHandlerInstance = CreateHandlerInstance(); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHost"), String("15.13.140.120"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHostFormat"), Uint16(3))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPVersion"), Uint16(2))); TestException(handler, indicationHandlerInstance, indicationInstance, CIM_ERR_FAILED); // Test "send trap failed" exception indicationInstance = CIMInstance(testClass4); indicationHandlerInstance = CreateHandlerInstance(); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHost"), String("15.13.140.120"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHostFormat"), Uint16(3))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPVersion"), Uint16(2))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPSecurityName"), String("t"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat"))); TestException(handler, indicationHandlerInstance, indicationInstance, CIM_ERR_FAILED); // Test "failed to add snmp variables to PDU", // Both a DiscardedData message and an error message // are logged to log file indicationInstance = CIMInstance(testClass5); indicationInstance.addProperty(CIMProperty( CIMName ("OidDataType"), String("OctetString"))); indicationHandlerInstance = CreateHandlerInstance(); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHost"), String("15.13.140.120"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHostFormat"), Uint16(3))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPVersion"), Uint16(2))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPSecurityName"), String("t"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat"))); TestError(handler, indicationHandlerInstance, indicationInstance); // Test "convert enterprise OID from numeric form to a list of" // "subidentifiers failed". // Both a DiscardedData message and an error message // are logged to log file indicationInstance = CIMInstance(testClass5); indicationInstance.addProperty(CIMProperty( CIMName ("OidDataType"), String("OctetString"))); indicationHandlerInstance = CreateHandlerInstance(); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHost"), String("15.13.140.120"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHostFormat"), Uint16(3))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPVersion"), Uint16(3))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPSecurityName"), String("t"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat"))); TestError(handler, indicationHandlerInstance, indicationInstance); // Test "convert property OID from numeric form to a list of" // "subidentifiers failed". // Both a DiscardedData message and an error message // are logged to log file indicationInstance = CIMInstance(testClass6); indicationInstance.addProperty(CIMProperty( CIMName ("OidDataType"), String("OctetString"))); indicationHandlerInstance = CreateHandlerInstance(); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHost"), String("15.13.140.120"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHostFormat"), Uint16(3))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPVersion"), Uint16(2))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat"))); TestError(handler, indicationHandlerInstance, indicationInstance); // Test "unsupported SNMP data type for the CIM property" // Both a DiscardedData message and an error message // are logged to log file indicationInstance = CIMInstance(testClass7); indicationInstance.addProperty(CIMProperty( CIMName ("OidDataType"), String("test"))); indicationHandlerInstance = CreateHandlerInstance(); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHost"), String("15.13.140.120"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHostFormat"), Uint16(3))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPVersion"), Uint16(2))); TestError(handler, indicationHandlerInstance, indicationInstance); }
CIMInstance CIMConstInstance::clone() const { return CIMInstance((CIMInstanceRep*)(_rep->clone())); }
CIMInstance UNIX_ClassifierFilterSet::getDependent() const { return CIMInstance(CIMName("CIM_Dependency")); }
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."); }
CIMInstance UNIX_CollectedSoftwareFeatures::getMember() const { return CIMInstance(CIMName("CIM_ManagedElement")); }
CIMInstance UNIX_BGPPeerGroupService::getDependent() const { return CIMInstance(CIMName("CIM_Dependency")); }
CIMInstance UNIX_ComputerSystemIRQ::getPartComponent() const { return CIMInstance(CIMName("CIM_Component")); }
CIMInstance UNIX_BGPServiceAttributes::getPartComponent() const { return CIMInstance(CIMName("CIM_Component")); }
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); } } }
CIMInstance UNIX_CardOnCard::getPartComponent() const { return CIMInstance(CIMName("CIM_Component")); }
CIMInstance UNIX_ApplicationSystemDependency::getDependent() const { return CIMInstance(CIMName("CIM_Dependency")); }
///////////////////////////////////////////////////////////////////////////// // WMIInstanceProvider::enumerateInstances // // /////////////////////////////////////////////////////////////////////////// Array<CIMInstance> WMIInstanceProvider::enumerateInstances( const String& nameSpace, const String& userName, const String& password, const String& className, Boolean deepInheritance, Boolean localOnly, Boolean includeQualifiers, Boolean includeClassOrigin, const CIMPropertyList& propertyList) { HRESULT hr; long lCount = 0; DWORD dwReturned; CComPtr<IEnumWbemClassObject> pInstEnum; CComPtr<IWbemClassObject> pInstance; Array<CIMInstance> namedInstances; PEG_METHOD_ENTER(TRC_WMIPROVIDER, "WMIInstanceProvider::enumerateInstances()"); setup(nameSpace, userName, password); PEG_TRACE((TRC_WMIPROVIDER, Tracer::LEVEL3, "enumerateInstances - deepInheritance %x, localOnly %x, " "includeQualifiers %x, includeClassOrigin %x", deepInheritance, localOnly, includeQualifiers, includeClassOrigin)); if (!m_bInitialized) { PEG_TRACE_CSTRING(TRC_WMIPROVIDER, Tracer::LEVEL1, "enumerateInstances - m_bInitialized is false; throw exception"); throw CIMException(CIM_ERR_FAILED); } // retrieve instance enumeration object if (!(_collector->getInstanceEnum(&pInstEnum, className, deepInheritance))) { if (pInstEnum) pInstEnum.Release(); throw CIMException(CIM_ERR_FAILED); } // set proxy security on pInstEnum bool bSecurity = _collector->setProxySecurity(pInstEnum); // Get the instances and append them to the array hr = pInstEnum->Next(WBEM_INFINITE, 1, &pInstance, &dwReturned); while (SUCCEEDED(hr) && (1 == dwReturned)) { //get class from the returned instance //it will avoid "type mismatch" exceptions //when deepInheritance is true and instances //of subclasses are returned CComVariant vTmpClassName; String strTmpClassName; if (pInstance->Get(L"__CLASS", 0, &vTmpClassName, NULL, NULL) == S_OK) { strTmpClassName = WMIString(vTmpClassName); } CIMInstance tempInst(strTmpClassName); if (_collector->getCIMInstance(pInstance, tempInst, localOnly, includeQualifiers, includeClassOrigin, propertyList, TRUE)) { //new code CIMObjectPath tempRef; CComVariant vAux; char* strAux=NULL; //set hostname if (pInstance->Get(L"__SERVER", 0, &vAux, NULL, NULL) != S_OK) throw CIMException(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); tempRef.setHost(strAux); delete [] strAux; strAux = NULL; vAux.Clear(); //set class name if (pInstance->Get(L"__CLASS", 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); tempRef.setClassName(strAux); delete [] strAux; 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); tempInst.setPath(tempRef); namedInstances.append(CIMInstance(tempInst)); } if (pInstance) pInstance.Release(); hr = pInstEnum->Next(WBEM_INFINITE, 1, &pInstance, &dwReturned); } if (pInstEnum) pInstEnum.Release(); PEG_TRACE((TRC_WMIPROVIDER, Tracer::LEVEL4, "WMIInstanceProvider::enumerateInstances() - " "Instance count is %d", lCount)); if (lCount == 0) { PEG_TRACE((TRC_WMIPROVIDER, Tracer::LEVEL2, "WMIInstanceProvider::enumerateInstances() - " "hResult value is %x", hr)); } PEG_METHOD_EXIT(); return namedInstances; }