void TestGroupingProvider2::invokeMethod( const OperationContext& context, const CIMObjectPath& objectReference, const CIMName& methodName, const Array<CIMParamValue>& inParameters, MethodResultResponseHandler& handler) { if (!objectReference.getClassName().equal("Test_GroupingClass2")) { throw CIMNotSupportedException( objectReference.getClassName().getString()); } handler.processing(); if (methodName.equal("getNextIdentifier")) { handler.deliver(CIMValue(Uint32(getNextIdentifier()))); } else if (methodName.equal("getSubscriptionCount")) { handler.deliver(CIMValue(_subscriptionCount)); } handler.complete(); }
CIMObjectPath _createHandlerInstance( CIMClient & client, const String & name, const String & targetHost, const String & securityName, const Uint16 targetHostFormat, const Uint16 snmpVersion) { CIMInstance handlerInstance (PEGASUS_CLASSNAME_INDHANDLER_SNMP); handlerInstance.addProperty (CIMProperty (CIMName ("SystemCreationClassName"), System::getSystemCreationClassName ())); handlerInstance.addProperty (CIMProperty (CIMName ("SystemName"), System::getFullyQualifiedHostName ())); handlerInstance.addProperty (CIMProperty (CIMName ("CreationClassName"), PEGASUS_CLASSNAME_INDHANDLER_SNMP.getString ())); handlerInstance.addProperty (CIMProperty (CIMName ("Name"), name)); handlerInstance.addProperty (CIMProperty (CIMName ("TargetHost"), targetHost)); handlerInstance.addProperty (CIMProperty (CIMName ("TargetHostFormat"), CIMValue ((Uint16) targetHostFormat))); handlerInstance.addProperty (CIMProperty (CIMName ("SNMPSecurityName"), securityName)); handlerInstance.addProperty (CIMProperty (CIMName ("SnmpVersion"), CIMValue ((Uint16) snmpVersion))); handlerInstance.addProperty (CIMProperty (CIMName ("PortNumber"), CIMValue ((Uint32) PORT_NUMBER))); return client.createInstance( PEGASUS_NAMESPACENAME_INTEROP, handlerInstance); }
void testInstanceCollection() { Buffer expected; FileSystem::loadFileToMemory(expected, "./instanceCollection.json"); if (verbose) cout << "Expected: " << expected.getData() << endl; Buffer outputBuffer; JSONWriter writer(outputBuffer); CIMName className = "className"; Array<CIMObject> instances; for (Uint32 i = 0; i < 10; i++) { CIMInstance x(className); x.addProperty(CIMProperty(CIMName("boolProp"), CIMValue(true))); x.addProperty(CIMProperty(CIMName("intProp"), CIMValue(i))); x.addProperty(CIMProperty( CIMName("stringProp"), CIMValue(String("hello world")))); Buffer objPath; objPath << className.getString() << ".intProp=" << i; x.setPath(CIMObjectPath(objPath.getData())); instances.append(x); } writer._append(instances); if (verbose) cout << "Got: " << outputBuffer.getData() << endl; PEGASUS_TEST_ASSERT( System::strcasecmp( expected.getData(), outputBuffer.getData()) == 0); }
CIMInstance IBM_CIMOMStatDataProvider::getInstance(Uint16 type) { StatisticalData* sd = StatisticalData::current(); char buffer[32]; sprintf(buffer, "%u", type); CIMInstance requestedInstance("IBM_CIMOMStatData"); requestedInstance.addProperty( CIMProperty("Description", CIMValue(String("CIMOM performance statistics for CIM request type <reqx>")))); requestedInstance.addProperty(CIMProperty("Caption", CIMValue(String("CIMOM performance statistics for CIM request type <reqx>")))); requestedInstance.addProperty(CIMProperty("InstanceID", CIMValue("IBM_CIMOMStatData"+String(buffer)))); requestedInstance.addProperty(CIMProperty("Name", CIMValue(StatisticalData::requestName[type]))); requestedInstance.addProperty(CIMProperty("requestType", CIMValue(type))); requestedInstance.addProperty(CIMProperty("NumberOfRequests", CIMValue(sd->numCalls[type]))); requestedInstance.addProperty(CIMProperty("TotalCimomTime", CIMValue(sd->cimomTime[type]))); requestedInstance.addProperty(CIMProperty("TotalProviderTime", CIMValue(sd->providerTime[type]))); requestedInstance.addProperty(CIMProperty("TotalRequestSize", CIMValue(sd->requestSize[type]))); requestedInstance.addProperty(CIMProperty("TotalResponseSize", CIMValue(sd->responseSize[type]))); return requestedInstance; }
void OOPModuleFailureTestProvider::invokeMethod ( const OperationContext & context, const CIMObjectPath & objectReference, const CIMName & methodName, const Array <CIMParamValue> & inParameters, MethodResultResponseHandler & handler) { Boolean sendIndication = false; String identifier; handler.processing (); if (objectReference.getClassName ().equal ("FailureTestIndication") && _enabled) { if (methodName.equal ("SendTestIndication")) { if ((inParameters.size() > 0) && (inParameters[0].getParameterName () == "identifier")) { inParameters[0].getValue().get(identifier); } sendIndication = true; handler.deliver (CIMValue (0)); } } else { handler.deliver (CIMValue (1)); PEGASUS_STD (cout) << "Provider is not enabled." << PEGASUS_STD (endl); } handler.complete (); if (sendIndication) { _generateIndication (_handler, identifier); } // // If I am the OOPModuleInvokeFailureTestProvider, fail (i.e. exit) // if (String::equalNoCase (_providerName, "OOPModuleInvokeFailureTestProvider")) { if (methodName.equal ("Fail")) { exit (-1); } } }
void MethodProvider::invokeMethod( const OperationContext & context, const CIMObjectPath & objectReference, const CIMName & methodName, const Array<CIMParamValue> & inParameters, MethodResultResponseHandler & handler) { // convert a fully qualified reference into a local reference // (class name and keys only). CIMObjectPath localReference = CIMObjectPath( String(), CIMNamespaceName(), objectReference.getClassName(), objectReference.getKeyBindings()); handler.processing(); if (objectReference.getClassName().equal("Sample_MethodProviderClass")) { if (methodName.equal("SayHello")) { String outString = "Hello"; if (inParameters.size() > 0) { CIMValue paramVal = inParameters[0].getValue(); if (!paramVal.isNull()) { String replyName; paramVal.get(replyName); if (replyName != String::EMPTY) { outString.append(", " + replyName + "!"); } } handler.deliverParamValue( CIMParamValue("Place", CIMValue(String("From Neverland")))); handler.deliver(CIMValue(outString)); } else { handler.deliver(CIMValue(outString)); } } } handler.complete(); }
void testArrayType(const Array<T>& x) { WsmToCimRequestMapper mapper((CIMRepository*) 0); // Create a NULL CIMValue of the appropriate type. Normally type // info is retrieved from the repository. CIMValue tmp(x); CIMValue cimValue(tmp.getType(), tmp.isArray()); // Create WsmValue out of the given array Array<String> arr; for (Uint32 i = 0; i < x.size(); i++) { String str = CIMValue(x[i]).toString(); if (tmp.getType() == CIMTYPE_BOOLEAN) { str.toLower(); } arr.append(str); } WsmValue wsmValue(arr); mapper.convertWsmToCimValue(wsmValue, CIMNamespaceName(), cimValue); PEGASUS_TEST_ASSERT(tmp == cimValue); }
void IndicationStressTestProvider::invokeMethod( const OperationContext & context, const CIMObjectPath & objectReference, const CIMName & methodName, const Array<CIMParamValue> & inParameters, MethodResultResponseHandler & handler) { Boolean sendIndication = false; Uint32 indicationSendCount; CIMIndication indicationInstance; char UIDbuffer[32]; handler.processing(); inParameters[0].getValue().get(indicationSendCount); if (_enabled) { handler.deliver( CIMValue( 0 ) ); } handler.complete(); if (indicationSendCount > 0) { sprintf(UIDbuffer, "%d", _nextUID++); for (Uint32 seqNum = 1; seqNum < indicationSendCount+1; seqNum++) { SendIndication(seqNum, UIDbuffer); } } }
void SendIndication(int seqNum, char *UIDbuffer) { CIMInstance indicationInstance (CIMName ("IndicationStressTestClass")); indicationInstance.setPath(path); indicationInstance.addProperty (CIMProperty ("IndicationIdentifier",String(UIDbuffer))); indicationInstance.addProperty (CIMProperty ("CorrelatedIndications", correlatedIndications)); CIMDateTime currentDateTime = CIMDateTime::getCurrentDateTime (); indicationInstance.addProperty (CIMProperty ("IndicationTime", currentDateTime)); indicationInstance.addProperty (CIMProperty ("IndicationSequenceNumber", CIMValue(Uint64(seqNum)))); // cout << "IndicationStressTestProvider instance = " << ((CIMObject)indicationInstance).toString() << endl; _indication_handler->deliver (indicationInstance); return; }
void setPropertyValue(CIMInstance& instance, const CIMName& propertyName, const Uint32 value) { Uint32 pos; PEGASUS_ASSERT(pos = instance.findProperty(propertyName) != PEG_NOT_FOUND); instance.getProperty(pos).setValue(CIMValue(value)); }
CIMObjectPath _getSubscriptionObjectPath( const String & filterName, const String & handlerName) { CIMObjectPath filterObjectPath = _getFilterObjectPath(filterName); CIMObjectPath handlerObjectPath = _getHandlerObjectPath(handlerName); Array<CIMKeyBinding> subscriptionKeyBindings; subscriptionKeyBindings.append (CIMKeyBinding ("Filter", CIMValue(filterObjectPath))); subscriptionKeyBindings.append (CIMKeyBinding ("Handler", CIMValue(handlerObjectPath))); return(CIMObjectPath("", CIMNamespaceName (), PEGASUS_CLASSNAME_INDSUBSCRIPTION, subscriptionKeyBindings)); }
void _sendTestIndication( CIMClient* client, const CIMName & methodName, Uint32 indicationSendCount) { // // Invoke method to send test indication // Array <CIMParamValue> inParams; Array <CIMParamValue> outParams; Array <CIMKeyBinding> keyBindings; Sint32 result; CIMObjectPath className (String::EMPTY, CIMNamespaceName (), CIMName ("Test_IndicationProviderClass"), keyBindings); inParams.append(CIMParamValue(String("indicationSendCount"), CIMValue(indicationSendCount))); CIMValue retValue = client->invokeMethod (SOURCE_NAMESPACE, className, methodName, inParams, outParams); retValue.get (result); PEGASUS_TEST_ASSERT (result == 0); }
void benchmarkProvider::enumerateInstanceNames( const OperationContext & context, const CIMObjectPath & classReference, ObjectPathResponseHandler & handler) { CIMObjectPath _instanceName; Uint32 numberOfProperties; Uint32 sizeOfPropertyValue; Uint32 numberOfInstances; CIMName className = classReference.getClassName(); test.getConfiguration(className, numberOfProperties, sizeOfPropertyValue, numberOfInstances); // begin processing the request handler.processing(); for (Uint32 i = 1; i <= numberOfInstances; i++) { _instanceName = _buildObjectPath(className, CIMKeyBinding(CIMName("Identifier"), CIMValue(i))); handler.deliver(_instanceName); } // complete processing the request handler.complete(); }
void benchmarkProvider::enumerateInstances( const OperationContext & context, const CIMObjectPath & classReference, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList & propertyList, InstanceResponseHandler & handler) { CIMInstance _instance; Uint32 numberOfProperties; Uint32 sizeOfPropertyValue; Uint32 numberOfInstances; CIMName className = classReference.getClassName(); test.getConfiguration(className, numberOfProperties, sizeOfPropertyValue, numberOfInstances); // begin processing the request handler.processing(); for (Uint32 i = 1; i <= numberOfInstances; i++) { _instance = _buildInstance(className, numberOfProperties, sizeOfPropertyValue , CIMValue(i)); handler.deliver(_instance); } // complete processing the request handler.complete(); }
void testModifyInstance(CIMClient& client, const char* ns) { Array<CIMInstance> instances; instances = client.enumerateInstances(ns, CIM_QUERYCAPCLASS_NAME); CIMProperty prop; Uint32 pos = instances[0].findProperty(PROPERTY_NAME_CAPTION); prop = instances[0].getProperty(pos); instances[0].removeProperty(pos); prop.setValue(CIMValue(String("MODIFIED CAPTION"))); instances[0].addProperty(prop); try { client.modifyInstance(ns, instances[0]); } catch(Exception) { // Do nothing. This is expected since modifyInstance is NOT // supported. return; } throw Exception("modifyInstance is supported"); }
void RT_IndicationProvider::invokeMethod( const OperationContext & context, const CIMObjectPath & objectReference, const CIMName & methodName, const Array<CIMParamValue> & inParameters, MethodResultResponseHandler & handler) { Boolean sendIndication = false; handler.processing(); if (objectReference.getClassName().equal ("RT_TestIndication") && _enabled) { if ((methodName.equal ("SendTestIndication")) || (methodName.equal ("SendTestIndicationNormal")) || (methodName.equal ("SendTestIndicationMissingProperty")) || (methodName.equal ("SendTestIndicationExtraProperty")) || (methodName.equal ("SendTestIndicationMatchingInstance")) || (methodName.equal ("SendTestIndicationUnmatchingNamespace")) || (methodName.equal ("SendTestIndicationUnmatchingClassName"))) { sendIndication = true; handler.deliver( CIMValue( 0 ) ); } } else if ((objectReference.getClassName ().equal ("RT_TestIndicationSubclass")) && _enabled) { if (methodName.equal ("SendTestIndicationSubclass")) { sendIndication = true; handler.deliver( CIMValue( 0 ) ); } } else { handler.deliver( CIMValue( 1 ) ); PEGASUS_STD(cout) << "Provider is not enabled." << PEGASUS_STD(endl); } handler.complete(); if (sendIndication) _generateIndication(_handler, methodName); }
void DefaultProviderManager::unloadIdleProviders() { PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "DefaultProviderManager::unloadIdleProviders"); try { struct timeval now; Time::gettimeofday(&now); // Make a copy of the table so it is not locked during provider calls Array<ProviderMessageHandler*> providerList; { AutoMutex lock(_providerTableMutex); for (ProviderTable::Iterator i = _providers.start(); i != 0; i++) { providerList.append(i.value()); } } for (Uint32 i = 0; i < providerList.size(); i++) { ProviderMessageHandler* provider = providerList[i]; AutoMutex lock(provider->status.getStatusMutex()); if (!provider->status.isInitialized()) { continue; } struct timeval providerTime = {0, 0}; provider->status.getLastOperationEndTime(&providerTime); PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL4, "provider->status.isIdle() returns: %s", (const char*)CIMValue(provider->status.isIdle()) .toString().getCString())); if (provider->status.isIdle() && ((now.tv_sec - providerTime.tv_sec) > ((Sint32)PEGASUS_PROVIDER_IDLE_TIMEOUT_SECONDS))) { PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL3, "Unloading idle provider: %s", (const char*)provider->getName().getCString())); _unloadProvider(provider); } } } catch (...) { PEG_TRACE_CSTRING(TRC_PROVIDERMANAGER, Tracer::LEVEL1, "Caught unexpected exception in unloadIdleProviders."); } PEG_METHOD_EXIT(); }
ObjectNormalizer::ObjectNormalizer( const CIMClass& cimClass, Boolean includeQualifiers, Boolean includeClassOrigin, const CIMNamespaceName& nameSpace, SharedPtr<NormalizerContext>& context) : _cimClass(cimClass), _includeQualifiers(includeQualifiers), _includeClassOrigin(includeClassOrigin), _context(context), _nameSpace(nameSpace) { if (!_cimClass.isUninitialized()) { // ATTN: the following code is intended to expedite normalizing // instances and instance object paths by establishing the keys // once now rather than multiple times later. it is biased // toward providers that return many instances with many properties. // build a reference object path within the class Array<CIMKeyBinding> keys; for (Uint32 i = 0, n = _cimClass.getPropertyCount(); i < n; i++) { CIMConstProperty referenceProperty = _cimClass.getProperty(i); Uint32 pos = referenceProperty.findQualifier("key"); if ((pos != PEG_NOT_FOUND) && (referenceProperty.getQualifier(pos).getValue().equal( CIMValue(true)))) { if (referenceProperty.getType() == CIMTYPE_REFERENCE) { // ATTN: a fake reference is inserted in the key so that // the _BubbleSort() method in CIMObjectPath does not // throw and exception. It implicitly validates keys of // type REFERENCE so just place a dummy value for now. // The value will be replaced by the normalized object // later. keys.append(CIMKeyBinding(referenceProperty.getName(), "class.key=\"value\"", CIMKeyBinding::REFERENCE)); } else { keys.append(CIMKeyBinding(referenceProperty.getName(), referenceProperty.getValue())); } } } // update class object path CIMObjectPath cimObjectPath(_cimClass.getPath()); cimObjectPath.setKeyBindings(keys); _cimClass.setPath(cimObjectPath); } }
CIMValue CIMHelper::getPropertyValue(const CIMInstance &instanceObject, String name) { CIMName cname(name); Uint32 index = instanceObject.findProperty(cname); if (index == PEG_NOT_FOUND) return CIMValue(); CIMConstProperty property = instanceObject.getProperty(index); return property.getValue(); }
/* Build an instance of the test class */ CIMInstance buildInstance(CIMClient& client, String& instanceId) { CIMClass cl = client.getClass(PROVIDERNS, TEST_CLASS); CIMInstance inst = cl.buildInstance(false, false, CIMPropertyList()); setPropertyValue(inst, "Id", CIMValue(instanceId)); return inst; }
Array<CIMKeyBinding> UNIX_CalculationBasedOnQueueProvider::constructKeyBindings(const UNIX_CalculationBasedOnQueue& _p) { Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding( PROPERTY_ANTECEDENT, CIMValue(_p.getAntecedent()).toString(), CIMKeyBinding::REFERENCE)); keys.append(CIMKeyBinding( PROPERTY_DEPENDENT, CIMValue(_p.getDependent()).toString(), CIMKeyBinding::REFERENCE)); return keys; }
Array<CIMKeyBinding> UNIX_AssociatedJobMethodResultProvider::constructKeyBindings(const UNIX_AssociatedJobMethodResult& _p) { Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding( PROPERTY_JOB, CIMValue(_p.getJob()).toString(), CIMKeyBinding::REFERENCE)); keys.append(CIMKeyBinding( PROPERTY_JOB_PARAMETERS, CIMValue(_p.getJobParameters()).toString(), CIMKeyBinding::REFERENCE)); return keys; }
Array<CIMKeyBinding> UNIX_BGPPeerUsesRouteMapProvider::constructKeyBindings(const UNIX_BGPPeerUsesRouteMap& _p) { Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding( PROPERTY_COLLECTION, CIMValue(_p.getCollection()).toString(), CIMKeyBinding::REFERENCE)); keys.append(CIMKeyBinding( PROPERTY_MEMBER, CIMValue(_p.getMember()).toString(), CIMKeyBinding::REFERENCE)); return keys; }
Array<CIMKeyBinding> UNIX_ClassifierElementInClassifierServiceProvider::constructKeyBindings(const UNIX_ClassifierElementInClassifierService& _p) { Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding( PROPERTY_GROUP_COMPONENT, CIMValue(_p.getGroupComponent()).toString(), CIMKeyBinding::REFERENCE)); keys.append(CIMKeyBinding( PROPERTY_PART_COMPONENT, CIMValue(_p.getPartComponent()).toString(), CIMKeyBinding::REFERENCE)); return keys; }
Array<CIMKeyBinding> UNIX_ComputerSystemMappedIOProvider::constructKeyBindings(const UNIX_ComputerSystemMappedIO& _p) { Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding( PROPERTY_GROUP_COMPONENT, CIMValue(_p.getGroupComponent()).toString(), CIMKeyBinding::REFERENCE)); keys.append(CIMKeyBinding( PROPERTY_PART_COMPONENT, CIMValue(_p.getPartComponent()).toString(), CIMKeyBinding::REFERENCE)); return keys; }
Array<CIMKeyBinding> UNIX_CollectedSoftwareFeaturesProvider::constructKeyBindings(const UNIX_CollectedSoftwareFeatures& _p) { Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding( PROPERTY_COLLECTION, CIMValue(_p.getCollection()).toString(), CIMKeyBinding::REFERENCE)); keys.append(CIMKeyBinding( PROPERTY_MEMBER, CIMValue(_p.getMember()).toString(), CIMKeyBinding::REFERENCE)); return keys; }
Array<CIMKeyBinding> UNIX_AreaOfConfigurationProvider::constructKeyBindings(const UNIX_AreaOfConfiguration& _p) { Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding( PROPERTY_ANTECEDENT, CIMValue(_p.getAntecedent()).toString(), CIMKeyBinding::REFERENCE)); keys.append(CIMKeyBinding( PROPERTY_DEPENDENT, CIMValue(_p.getDependent()).toString(), CIMKeyBinding::REFERENCE)); return keys; }
Array<CIMKeyBinding> UNIX_AggregateRedundancyComponentProvider::constructKeyBindings(const UNIX_AggregateRedundancyComponent& _p) { Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding( PROPERTY_GROUP_COMPONENT, CIMValue(_p.getGroupComponent()).toString(), CIMKeyBinding::REFERENCE)); keys.append(CIMKeyBinding( PROPERTY_PART_COMPONENT, CIMValue(_p.getPartComponent()).toString(), CIMKeyBinding::REFERENCE)); return keys; }
Array<CIMKeyBinding> UNIX_AssociatedDatabaseSystemProvider::constructKeyBindings(const UNIX_AssociatedDatabaseSystem& _p) { Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding( PROPERTY_ANTECEDENT, CIMValue(_p.getAntecedent()).toString(), CIMKeyBinding::REFERENCE)); keys.append(CIMKeyBinding( PROPERTY_DEPENDENT, CIMValue(_p.getDependent()).toString(), CIMKeyBinding::REFERENCE)); return keys; }
Array<CIMKeyBinding> UNIX_BootServiceAccessBySAPProvider::constructKeyBindings(const UNIX_BootServiceAccessBySAP& _p) { Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding( PROPERTY_ANTECEDENT, CIMValue(_p.getAntecedent()).toString(), CIMKeyBinding::REFERENCE)); keys.append(CIMKeyBinding( PROPERTY_DEPENDENT, CIMValue(_p.getDependent()).toString(), CIMKeyBinding::REFERENCE)); return keys; }