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 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(); }
void UNIX_BGPEndpointStatisticsProvider::invokeMethod( const OperationContext& context, const CIMObjectPath& objectReference, const CIMName& methodName, const Array<CIMParamValue>& inParameters, MethodResultResponseHandler& handler) { if (!objectReference.getClassName().equal("UNIX_BGPEndpointStatistics") && !objectReference.getClassName().equal("CIM_BGPEndpointStatistics")) { String classMessage; classMessage.append("UNIX_BGPEndpointStatistics Provider"); classMessage.append (" does not support class "); classMessage.append (objectReference.getClassName().getString()); throw CIMNotSupportedException(classMessage); } handler.processing(); // Make cimom handle invokeMethod request with input parameters. CIMObjectPath localReference = CIMObjectPath( String(""), CIMNamespaceName("root/cimv2"), objectReference.getClassName(), objectReference.getKeyBindings()); if (methodName.equal("ResetSelectedStats")) { if (inParameters.size() != 1) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking ResetSelectedStats method. Uint32 invokeResetSelectedStatsReturnValue; Array<String> inSelectedStatistics; for(Uint32 pi = 0; pi < inParameters.size(); pi++) { CIMParamValue p = inParameters[pi]; if (String::equalNoCase(p.getParameterName(), "SelectedStatistics")) { p.getValue().get(inSelectedStatistics); } } _p.initialize(); _p.find(localReference.getKeyBindings()); invokeResetSelectedStatsReturnValue = _p.invokeResetSelectedStats( inSelectedStatistics ); _p.finalize(); handler.deliver(invokeResetSelectedStatsReturnValue); } else { String message; message.append("UNIX_BGPEndpointStatistics"); message.append (" does not support invokeMethod"); throw CIMNotSupportedException(message); } }
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 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); }
PEGASUS_NAMESPACE_BEGIN /* ATTN: This method provider is used by ProviderRegistrationProvider to update InteropProvider Cache. If SLP is enabled we invoke SLPProvider's 'update' method to update registrations in this method. Note that 'updateCache' method is not defined as part of class PG_ProviderProfileCapabilities. This method is used purely for internal purpose for the communication between InteropProvider and ProviderRegistrationProvider. */ void InteropProvider::invokeMethod( const OperationContext & context, const CIMObjectPath & objectReference, const CIMName & methodName, const Array<CIMParamValue> & inParameters, MethodResultResponseHandler & handler) { if(objectReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP) && objectReference.getClassName().equal( PEGASUS_CLASSNAME_PG_PROVIDERPROFILECAPABILITIES) && methodName.equal("updateCache")) { handler.processing(); #ifdef PEGASUS_ENABLE_SLP sendUpdateRegMessageToSLPProvider(context); #endif updateProfileCache++; handler.complete(); } else { throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, objectReference.getNameSpace().getString()); } }
// CIMMethodProvider interface void DynamicIndicationProvider::invokeMethod( const OperationContext& context, const CIMObjectPath& objectReference, const CIMName& methodName, const Array<CIMParamValue>& inParameters, MethodResultResponseHandler& handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "DynamicIndicationProvider::invokeMethod"); Uint32 severity; String classname; String description; char buf[256]; PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4,"Class %s", (const char*)objectReference.toString().getCString())); PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4,"Method %s", (const char*)methodName.getString().getCString())); handler.processing(); if (String::equal( objectReference.getClassName().getString(), _DynamicIndicationClassName)) { if (String::equal(methodName.getString(), _DynamicIndicationMethod)) { try { ((inParameters[0]).getValue()).get(severity); ((inParameters[1]).getValue()).get(classname); ((inParameters[2]).getValue()).get(description); PEG_TRACE(( TRC_CONTROLPROVIDER, Tracer::LEVEL4, "severity:!%d!, classname!%s! description!%s!\n", severity, (const char*)classname.getCString(), (const char*)description.getCString())); } catch (...) { PEG_METHOD_EXIT(); throw CIMException(CIM_ERR_INVALID_PARAMETER); } } else { PEG_METHOD_EXIT(); throw CIMException(CIM_ERR_METHOD_NOT_FOUND); } } else { PEG_METHOD_EXIT(); throw CIMException(CIM_ERR_INVALID_CLASS); } sendIndication(severity, classname, description); unsigned int execStatus = 0; CIMValue cimRetValue(execStatus); handler.deliver(cimRetValue); handler.complete(); PEG_METHOD_EXIT(); }
void UNIX_AutonomousSystemProvider::invokeMethod( const OperationContext& context, const CIMObjectPath& objectReference, const CIMName& methodName, const Array<CIMParamValue>& inParameters, MethodResultResponseHandler& handler) { if (!objectReference.getClassName().equal("UNIX_AutonomousSystem") && !objectReference.getClassName().equal("CIM_AutonomousSystem")) { String classMessage; classMessage.append("UNIX_AutonomousSystem Provider"); classMessage.append (" does not support class "); classMessage.append (objectReference.getClassName().getString()); throw CIMNotSupportedException(classMessage); } handler.processing(); // Make cimom handle invokeMethod request with input parameters. CIMObjectPath localReference = CIMObjectPath( String(""), CIMNamespaceName("root/cimv2"), objectReference.getClassName(), objectReference.getKeyBindings()); if (methodName.equal("RequestStateChange")) { if (inParameters.size() != 3) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking RequestStateChange method. Uint32 invokeRequestStateChangeReturnValue; Uint16 inRequestedState; CIMInstance inJob; CIMDateTime inTimeoutPeriod; for(Uint32 pi = 0; pi < inParameters.size(); pi++) { CIMParamValue p = inParameters[pi]; if (String::equalNoCase(p.getParameterName(), "RequestedState")) { p.getValue().get(inRequestedState); } if (String::equalNoCase(p.getParameterName(), "Job")) { p.getValue().get(inJob); } if (String::equalNoCase(p.getParameterName(), "TimeoutPeriod")) { p.getValue().get(inTimeoutPeriod); } } _p.initialize(); _p.find(localReference.getKeyBindings()); invokeRequestStateChangeReturnValue = _p.invokeRequestStateChange( inRequestedState, inJob, inTimeoutPeriod ); _p.finalize(); handler.deliver(invokeRequestStateChangeReturnValue); } else { String message; message.append("UNIX_AutonomousSystem"); message.append (" does not support invokeMethod"); throw CIMNotSupportedException(message); } }
void UNIX_CPUDiagnosticTestProvider::invokeMethod( const OperationContext& context, const CIMObjectPath& objectReference, const CIMName& methodName, const Array<CIMParamValue>& inParameters, MethodResultResponseHandler& handler) { if (!objectReference.getClassName().equal("UNIX_CPUDiagnosticTest") && !objectReference.getClassName().equal("CIM_CPUDiagnosticTest")) { String classMessage; classMessage.append("UNIX_CPUDiagnosticTest Provider"); classMessage.append (" does not support class "); classMessage.append (objectReference.getClassName().getString()); throw CIMNotSupportedException(classMessage); } handler.processing(); // Make cimom handle invokeMethod request with input parameters. CIMObjectPath localReference = CIMObjectPath( String(""), CIMNamespaceName("root/cimv2"), objectReference.getClassName(), objectReference.getKeyBindings()); if (methodName.equal("RunTest")) { if (inParameters.size() != 3) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking RunTest method. Uint32 invokeRunTestReturnValue; CIMInstance inSystemElement; CIMInstance inSetting; CIMInstance inResult; for(Uint32 pi = 0; pi < inParameters.size(); pi++) { CIMParamValue p = inParameters[pi]; if (String::equalNoCase(p.getParameterName(), "SystemElement")) { p.getValue().get(inSystemElement); } if (String::equalNoCase(p.getParameterName(), "Setting")) { p.getValue().get(inSetting); } if (String::equalNoCase(p.getParameterName(), "Result")) { p.getValue().get(inResult); } } _p.initialize(); _p.find(localReference.getKeyBindings()); invokeRunTestReturnValue = _p.invokeRunTest( inSystemElement, inSetting, inResult ); _p.finalize(); handler.deliver(invokeRunTestReturnValue); } else if (methodName.equal("ClearResults")) { if (inParameters.size() != 2) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking ClearResults method. Uint32 invokeClearResultsReturnValue; CIMInstance inSystemElement; Array<String> inResultsNotCleared; for(Uint32 pi = 0; pi < inParameters.size(); pi++) { CIMParamValue p = inParameters[pi]; if (String::equalNoCase(p.getParameterName(), "SystemElement")) { p.getValue().get(inSystemElement); } if (String::equalNoCase(p.getParameterName(), "ResultsNotCleared")) { p.getValue().get(inResultsNotCleared); } } _p.initialize(); _p.find(localReference.getKeyBindings()); invokeClearResultsReturnValue = _p.invokeClearResults( inSystemElement, inResultsNotCleared ); _p.finalize(); handler.deliver(invokeClearResultsReturnValue); } else if (methodName.equal("DiscontinueTest")) { if (inParameters.size() != 3) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking DiscontinueTest method. Uint32 invokeDiscontinueTestReturnValue; CIMInstance inSystemElement; CIMInstance inResult; Boolean inTestingStopped; for(Uint32 pi = 0; pi < inParameters.size(); pi++) { CIMParamValue p = inParameters[pi]; if (String::equalNoCase(p.getParameterName(), "SystemElement")) { p.getValue().get(inSystemElement); } if (String::equalNoCase(p.getParameterName(), "Result")) { p.getValue().get(inResult); } if (String::equalNoCase(p.getParameterName(), "TestingStopped")) { p.getValue().get(inTestingStopped); } } _p.initialize(); _p.find(localReference.getKeyBindings()); invokeDiscontinueTestReturnValue = _p.invokeDiscontinueTest( inSystemElement, inResult, inTestingStopped ); _p.finalize(); handler.deliver(invokeDiscontinueTestReturnValue); } else if (methodName.equal("RunDiagnostic")) { if (inParameters.size() != 4) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking RunDiagnostic method. Uint32 invokeRunDiagnosticReturnValue; CIMInstance inManagedElement; CIMInstance inDiagSetting; CIMInstance inJobSetting; CIMInstance inJob; for(Uint32 pi = 0; pi < inParameters.size(); pi++) { CIMParamValue p = inParameters[pi]; if (String::equalNoCase(p.getParameterName(), "ManagedElement")) { p.getValue().get(inManagedElement); } if (String::equalNoCase(p.getParameterName(), "DiagSetting")) { p.getValue().get(inDiagSetting); } if (String::equalNoCase(p.getParameterName(), "JobSetting")) { p.getValue().get(inJobSetting); } if (String::equalNoCase(p.getParameterName(), "Job")) { p.getValue().get(inJob); } } _p.initialize(); _p.find(localReference.getKeyBindings()); invokeRunDiagnosticReturnValue = _p.invokeRunDiagnostic( inManagedElement, inDiagSetting, inJobSetting, inJob ); _p.finalize(); handler.deliver(invokeRunDiagnosticReturnValue); } else if (methodName.equal("RunDiagnosticService")) { if (inParameters.size() != 4) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking RunDiagnosticService method. Uint32 invokeRunDiagnosticServiceReturnValue; CIMInstance inManagedElement; String inDiagnosticSettings; String inJobSettings; CIMInstance inJob; for(Uint32 pi = 0; pi < inParameters.size(); pi++) { CIMParamValue p = inParameters[pi]; if (String::equalNoCase(p.getParameterName(), "ManagedElement")) { p.getValue().get(inManagedElement); } if (String::equalNoCase(p.getParameterName(), "DiagnosticSettings")) { p.getValue().get(inDiagnosticSettings); } if (String::equalNoCase(p.getParameterName(), "JobSettings")) { p.getValue().get(inJobSettings); } if (String::equalNoCase(p.getParameterName(), "Job")) { p.getValue().get(inJob); } } _p.initialize(); _p.find(localReference.getKeyBindings()); invokeRunDiagnosticServiceReturnValue = _p.invokeRunDiagnosticService( inManagedElement, inDiagnosticSettings, inJobSettings, inJob ); _p.finalize(); handler.deliver(invokeRunDiagnosticServiceReturnValue); } else if (methodName.equal("StartService")) { if (inParameters.size() != 0) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking StartService method. Uint32 invokeStartServiceReturnValue; _p.initialize(); _p.find(localReference.getKeyBindings()); invokeStartServiceReturnValue = _p.invokeStartService(); _p.finalize(); handler.deliver(invokeStartServiceReturnValue); } else if (methodName.equal("StopService")) { if (inParameters.size() != 0) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking StopService method. Uint32 invokeStopServiceReturnValue; _p.initialize(); _p.find(localReference.getKeyBindings()); invokeStopServiceReturnValue = _p.invokeStopService(); _p.finalize(); handler.deliver(invokeStopServiceReturnValue); } else if (methodName.equal("ChangeAffectedElementsAssignedSequence")) { if (inParameters.size() != 3) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking ChangeAffectedElementsAssignedSequence method. Uint32 invokeChangeAffectedElementsAssignedSequenceReturnValue; CIMInstance inManagedElements; Array<Uint16> inAssignedSequence; CIMInstance inJob; for(Uint32 pi = 0; pi < inParameters.size(); pi++) { CIMParamValue p = inParameters[pi]; if (String::equalNoCase(p.getParameterName(), "ManagedElements")) { p.getValue().get(inManagedElements); } if (String::equalNoCase(p.getParameterName(), "AssignedSequence")) { p.getValue().get(inAssignedSequence); } if (String::equalNoCase(p.getParameterName(), "Job")) { p.getValue().get(inJob); } } _p.initialize(); _p.find(localReference.getKeyBindings()); invokeChangeAffectedElementsAssignedSequenceReturnValue = _p.invokeChangeAffectedElementsAssignedSequence( inManagedElements, inAssignedSequence, inJob ); _p.finalize(); handler.deliver(invokeChangeAffectedElementsAssignedSequenceReturnValue); } else if (methodName.equal("RequestStateChange")) { if (inParameters.size() != 3) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking RequestStateChange method. Uint32 invokeRequestStateChangeReturnValue; Uint16 inRequestedState; CIMInstance inJob; CIMDateTime inTimeoutPeriod; for(Uint32 pi = 0; pi < inParameters.size(); pi++) { CIMParamValue p = inParameters[pi]; if (String::equalNoCase(p.getParameterName(), "RequestedState")) { p.getValue().get(inRequestedState); } if (String::equalNoCase(p.getParameterName(), "Job")) { p.getValue().get(inJob); } if (String::equalNoCase(p.getParameterName(), "TimeoutPeriod")) { p.getValue().get(inTimeoutPeriod); } } _p.initialize(); _p.find(localReference.getKeyBindings()); invokeRequestStateChangeReturnValue = _p.invokeRequestStateChange( inRequestedState, inJob, inTimeoutPeriod ); _p.finalize(); handler.deliver(invokeRequestStateChangeReturnValue); } else { String message; message.append("UNIX_CPUDiagnosticTest"); message.append (" does not support invokeMethod"); throw CIMNotSupportedException(message); } }
// // Invoke Method, used to modify user's password // void UserAuthProvider::invokeMethod( const OperationContext & context, const CIMObjectPath & ref, const CIMName & methodName, const Array<CIMParamValue> & inParams, MethodResultResponseHandler & handler) { PEG_METHOD_ENTER(TRC_USER_MANAGER,"UserAuthProvider::invokeMethod"); // // get userName // String user; try { IdentityContainer container = context.get(IdentityContainer::NAME); user= container.getUserName(); } catch (...) { user= String::EMPTY; } // // verify user authorizations // if ( user != String::EMPTY || user != "" ) { _verifyAuthorization(user); } #ifndef PEGASUS_NO_PASSWORDFILE String userName; String password; String newPassword; Array<CIMKeyBinding> kbArray; // Begin processing the request handler.processing(); // Check if the class name is PG_USER if (!ref.getClassName().equal (CLASS_NAME_PG_USER)) { handler.complete(); throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, ref.getClassName().getString()); } // Check if the method name is correct if (!methodName.equal (METHOD_NAME_MODIFY_PASSWORD)) { handler.complete(); PEG_METHOD_EXIT(); //l10n //throw PEGASUS_CIM_EXCEPTION ( //CIM_ERR_FAILED, //"Unsupported method name, " + methodName.getString()); MessageLoaderParms parms("ControlProviders.UserAuthProvider.UNSUPPORTED_METHOD_NAME", "Unsupported method name, $0", methodName.getString()); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,parms); } // Check if all the input parameters are passed. if ( inParams.size() < 2 ) { handler.complete(); PEG_METHOD_EXIT(); //l10n // throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER, // "Input parameters are not valid."); MessageLoaderParms parms("ControlProviders.UserAuthProvider.INPUT_PARAMETERS_NOT_VALID", "Input parameters are not valid."); throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_INVALID_PARAMETER, parms); } try { kbArray = ref.getKeyBindings(); if ( !kbArray.size() ) { PEG_METHOD_EXIT(); //l10n //throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER, // "Unable to find Key Property Username"); MessageLoaderParms parms("ControlProviders.UserAuthProvider.UNABLE_TO_FIND_KEY_PROPERTY_USERNAME", "Unable to find Key Property Username"); throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_INVALID_PARAMETER,parms); } // // Get the user name // if ( kbArray[0].getName() == PROPERTY_NAME_USERNAME ) { userName = kbArray[0].getValue(); } else { PEG_METHOD_EXIT(); MessageLoaderParms parms( "ControlProviders.UserAuthProvider.UNEXPECTED_KEY_PROPERTY", "Unexpected key property"); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER, parms); } // // Get the old and the new password params // for ( Uint32 i=0; i < 2; i++) { // // check the param name // if ( inParams[i].getParameterName() == OLD_PASSWORD ) { inParams[i].getValue().get(password); } if ( inParams[i].getParameterName() == NEW_PASSWORD ) { inParams[i].getValue().get(newPassword); } } // Modify the user's password in User Manager _userManager->modifyUser( userName, password, newPassword); } catch ( const CIMException& ) { handler.complete(); PEG_METHOD_EXIT(); throw; } catch (const Exception& e) { handler.complete(); PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } // Return zero as there is no error Uint32 retCode = 0; handler.deliver(CIMValue(retCode)); // complete processing the request handler.complete(); PEG_METHOD_EXIT(); return; #else PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, ref.getClassName().getString()); #endif }
void UNIX_AggregatePSExtentProvider::invokeMethod( const OperationContext& context, const CIMObjectPath& objectReference, const CIMName& methodName, const Array<CIMParamValue>& inParameters, MethodResultResponseHandler& handler) { if (!objectReference.getClassName().equal("UNIX_AggregatePSExtent") && !objectReference.getClassName().equal("CIM_AggregatePSExtent")) { String classMessage; classMessage.append("UNIX_AggregatePSExtent Provider"); classMessage.append (" does not support class "); classMessage.append (objectReference.getClassName().getString()); throw CIMNotSupportedException(classMessage); } handler.processing(); // Make cimom handle invokeMethod request with input parameters. CIMObjectPath localReference = CIMObjectPath( String(""), CIMNamespaceName("root/cimv2"), objectReference.getClassName(), objectReference.getKeyBindings()); if (methodName.equal("SetPowerState")) { if (inParameters.size() != 2) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking SetPowerState method. Uint32 invokeSetPowerStateReturnValue; Uint16 inPowerState; CIMDateTime inTime; for(Uint32 pi = 0; pi < inParameters.size(); pi++) { CIMParamValue p = inParameters[pi]; if (String::equalNoCase(p.getParameterName(), "PowerState")) { p.getValue().get(inPowerState); } if (String::equalNoCase(p.getParameterName(), "Time")) { p.getValue().get(inTime); } } _p.initialize(); _p.find(localReference.getKeyBindings()); invokeSetPowerStateReturnValue = _p.invokeSetPowerState( inPowerState, inTime ); _p.finalize(); handler.deliver(invokeSetPowerStateReturnValue); } else if (methodName.equal("Reset")) { if (inParameters.size() != 0) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking Reset method. Uint32 invokeResetReturnValue; _p.initialize(); _p.find(localReference.getKeyBindings()); invokeResetReturnValue = _p.invokeReset(); _p.finalize(); handler.deliver(invokeResetReturnValue); } else if (methodName.equal("EnableDevice")) { if (inParameters.size() != 1) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking EnableDevice method. Uint32 invokeEnableDeviceReturnValue; Boolean inEnabled; for(Uint32 pi = 0; pi < inParameters.size(); pi++) { CIMParamValue p = inParameters[pi]; if (String::equalNoCase(p.getParameterName(), "Enabled")) { p.getValue().get(inEnabled); } } _p.initialize(); _p.find(localReference.getKeyBindings()); invokeEnableDeviceReturnValue = _p.invokeEnableDevice( inEnabled ); _p.finalize(); handler.deliver(invokeEnableDeviceReturnValue); } else if (methodName.equal("OnlineDevice")) { if (inParameters.size() != 1) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking OnlineDevice method. Uint32 invokeOnlineDeviceReturnValue; Boolean inOnline; for(Uint32 pi = 0; pi < inParameters.size(); pi++) { CIMParamValue p = inParameters[pi]; if (String::equalNoCase(p.getParameterName(), "Online")) { p.getValue().get(inOnline); } } _p.initialize(); _p.find(localReference.getKeyBindings()); invokeOnlineDeviceReturnValue = _p.invokeOnlineDevice( inOnline ); _p.finalize(); handler.deliver(invokeOnlineDeviceReturnValue); } else if (methodName.equal("QuiesceDevice")) { if (inParameters.size() != 1) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking QuiesceDevice method. Uint32 invokeQuiesceDeviceReturnValue; Boolean inQuiesce; for(Uint32 pi = 0; pi < inParameters.size(); pi++) { CIMParamValue p = inParameters[pi]; if (String::equalNoCase(p.getParameterName(), "Quiesce")) { p.getValue().get(inQuiesce); } } _p.initialize(); _p.find(localReference.getKeyBindings()); invokeQuiesceDeviceReturnValue = _p.invokeQuiesceDevice( inQuiesce ); _p.finalize(); handler.deliver(invokeQuiesceDeviceReturnValue); } else if (methodName.equal("SaveProperties")) { if (inParameters.size() != 0) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking SaveProperties method. Uint32 invokeSavePropertiesReturnValue; _p.initialize(); _p.find(localReference.getKeyBindings()); invokeSavePropertiesReturnValue = _p.invokeSaveProperties(); _p.finalize(); handler.deliver(invokeSavePropertiesReturnValue); } else if (methodName.equal("RestoreProperties")) { if (inParameters.size() != 0) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking RestoreProperties method. Uint32 invokeRestorePropertiesReturnValue; _p.initialize(); _p.find(localReference.getKeyBindings()); invokeRestorePropertiesReturnValue = _p.invokeRestoreProperties(); _p.finalize(); handler.deliver(invokeRestorePropertiesReturnValue); } else if (methodName.equal("RequestStateChange")) { if (inParameters.size() != 3) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking RequestStateChange method. Uint32 invokeRequestStateChangeReturnValue; Uint16 inRequestedState; CIMInstance inJob; CIMDateTime inTimeoutPeriod; for(Uint32 pi = 0; pi < inParameters.size(); pi++) { CIMParamValue p = inParameters[pi]; if (String::equalNoCase(p.getParameterName(), "RequestedState")) { p.getValue().get(inRequestedState); } if (String::equalNoCase(p.getParameterName(), "Job")) { p.getValue().get(inJob); } if (String::equalNoCase(p.getParameterName(), "TimeoutPeriod")) { p.getValue().get(inTimeoutPeriod); } } _p.initialize(); _p.find(localReference.getKeyBindings()); invokeRequestStateChangeReturnValue = _p.invokeRequestStateChange( inRequestedState, inJob, inTimeoutPeriod ); _p.finalize(); handler.deliver(invokeRequestStateChangeReturnValue); } else { String message; message.append("UNIX_AggregatePSExtent"); message.append (" does not support invokeMethod"); throw CIMNotSupportedException(message); } }
void UNIX_BatchJobProvider::invokeMethod( const OperationContext& context, const CIMObjectPath& objectReference, const CIMName& methodName, const Array<CIMParamValue>& inParameters, MethodResultResponseHandler& handler) { if (!objectReference.getClassName().equal("UNIX_BatchJob") && !objectReference.getClassName().equal("CIM_BatchJob")) { String classMessage; classMessage.append("UNIX_BatchJob Provider"); classMessage.append (" does not support class "); classMessage.append (objectReference.getClassName().getString()); throw CIMNotSupportedException(classMessage); } handler.processing(); // Make cimom handle invokeMethod request with input parameters. CIMObjectPath localReference = CIMObjectPath( String(""), CIMNamespaceName("root/cimv2"), objectReference.getClassName(), objectReference.getKeyBindings()); if (methodName.equal("RequestStateChange")) { if (inParameters.size() != 0) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking RequestStateChange method. Uint32 invokeRequestStateChangeReturnValue; Uint16 inRequestedState; CIMDateTime inTimeoutPeriod; for(Uint32 pi = 0; pi < inParameters.size(); pi++) { CIMParamValue p = inParameters[pi]; if (String::equalNoCase(p.getParameterName(), "RequestedState")) { p.getValue().get(inRequestedState); } if (String::equalNoCase(p.getParameterName(), "TimeoutPeriod")) { p.getValue().get(inTimeoutPeriod); } } _p.initialize(); _p.find(localReference.getKeyBindings()); invokeRequestStateChangeReturnValue = _p.invokeRequestStateChange( inRequestedState, inTimeoutPeriod ); _p.finalize(); handler.deliver(invokeRequestStateChangeReturnValue); } else if (methodName.equal("GetError")) { if (inParameters.size() != 0) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking GetError method. Uint32 invokeGetErrorReturnValue; String inError; for(Uint32 pi = 0; pi < inParameters.size(); pi++) { CIMParamValue p = inParameters[pi]; if (String::equalNoCase(p.getParameterName(), "Error")) { p.getValue().get(inError); } } _p.initialize(); _p.find(localReference.getKeyBindings()); invokeGetErrorReturnValue = _p.invokeGetError( inError ); _p.finalize(); handler.deliver(invokeGetErrorReturnValue); } else if (methodName.equal("GetErrors")) { if (inParameters.size() != 0) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking GetErrors method. Uint32 invokeGetErrorsReturnValue; Array<String> inErrors; for(Uint32 pi = 0; pi < inParameters.size(); pi++) { CIMParamValue p = inParameters[pi]; if (String::equalNoCase(p.getParameterName(), "Errors")) { p.getValue().get(inErrors); } } _p.initialize(); _p.find(localReference.getKeyBindings()); invokeGetErrorsReturnValue = _p.invokeGetErrors( inErrors ); _p.finalize(); handler.deliver(invokeGetErrorsReturnValue); } else if (methodName.equal("ResumeWithAction")) { if (inParameters.size() != 0) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking ResumeWithAction method. Uint32 invokeResumeWithActionReturnValue; _p.initialize(); _p.find(localReference.getKeyBindings()); invokeResumeWithActionReturnValue = _p.invokeResumeWithAction(); _p.finalize(); handler.deliver(invokeResumeWithActionReturnValue); } else if (methodName.equal("ResumeWithInput")) { if (inParameters.size() != 0) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking ResumeWithInput method. Uint32 invokeResumeWithInputReturnValue; Array<String> inInputs; for(Uint32 pi = 0; pi < inParameters.size(); pi++) { CIMParamValue p = inParameters[pi]; if (String::equalNoCase(p.getParameterName(), "Inputs")) { p.getValue().get(inInputs); } } _p.initialize(); _p.find(localReference.getKeyBindings()); invokeResumeWithInputReturnValue = _p.invokeResumeWithInput( inInputs ); _p.finalize(); handler.deliver(invokeResumeWithInputReturnValue); } else if (methodName.equal("KillJob")) { if (inParameters.size() != 1) { throw new CIMOperationFailedException("Incorrect in parameters"); } //Invoking KillJob method. Uint32 invokeKillJobReturnValue; Boolean inDeleteOnKill; for(Uint32 pi = 0; pi < inParameters.size(); pi++) { CIMParamValue p = inParameters[pi]; if (String::equalNoCase(p.getParameterName(), "DeleteOnKill")) { p.getValue().get(inDeleteOnKill); } } _p.initialize(); _p.find(localReference.getKeyBindings()); invokeKillJobReturnValue = _p.invokeKillJob( inDeleteOnKill ); _p.finalize(); handler.deliver(invokeKillJobReturnValue); } else { String message; message.append("UNIX_BatchJob"); message.append (" does not support invokeMethod"); throw CIMNotSupportedException(message); } }
/** When the "PropagateError" method is invoked, this function will read a CIM_Error embedded instance from the inParameters and use that instance to create an InstMethodIndication populating the Error[] property with the CIM_Error parameter and errorInstance stored in this class (if it's been created already). The output parameter of this method will contain the embedded instance received as input, and the newly created InstMethodIndication will be sent by the provider to any registered listeners. */ void EmbeddedInstanceProvider::invokeMethod( const OperationContext& context, const CIMObjectPath& objectReference, const CIMName& methodName, const Array<CIMParamValue>& inParameters, MethodResultResponseHandler& handler) { // This should start sending indications with the stored Job instance // embedded in the InstMethodIndication handler.processing(); if (!methodName.equal(CIMName("PropagateError"))) throw CIMException(CIM_ERR_METHOD_NOT_AVAILABLE); if (inParameters.size() != 1) { throw CIMException( CIM_ERR_INVALID_PARAMETER, "Did not receive exactly 1 parameter"); } CIMParamValue errorParam = inParameters[0]; if (!String::equal(errorParam.getParameterName(), String("error"))) { throw CIMException( CIM_ERR_INVALID_PARAMETER, "Did not find \"error\" parameter"); } CIMInstance errorParamInst; errorParam.getValue().get(errorParamInst); if (errorParamInst.getPath().getClassName() != "PG_EmbeddedError") { throw CIMException(CIM_ERR_INVALID_PARAMETER); } errorParamInst.setPath(errorInstance->getPath()); Array<CIMName> propList; for (unsigned int i = 0, n = errorParamInst.getPropertyCount(); i < n; i++) { propList.append(errorParamInst.getProperty(i).getName()); } CIMInstance tmpErrorInstance(errorInstance->clone()); if (!tmpErrorInstance.identical(errorParamInst)) { throw Exception("Did not receive expected ErrorInstance"); } // Build new indication instance CIMObjectPath indicationPath(System::getHostName(), CIMNamespaceName("test/EmbeddedInstance/Dynamic"), CIMName("PG_InstMethodIndication")); indicationInstance.reset(new CIMInstance("PG_InstMethodIndication")); indicationInstance->setPath(indicationPath); indicationInstance->addProperty(CIMProperty("MethodName", CIMValue(String("PropagateError")))); indicationInstance->addProperty(CIMProperty("PreCall", CIMValue(Boolean(false)))); indicationInstance->addProperty(CIMProperty("SourceInstance", CIMValue(CIMObject(*errorInstance)))); Array<CIMInstance> errorInstances; errorInstances.append(*errorInstance); errorInstances.append(*errorInstance); indicationInstance->addProperty(CIMProperty("Error", CIMValue(errorInstances))); handler.deliverParamValue(CIMParamValue(String("sameError"), CIMValue(errorParamInst))); handler.deliver(CIMValue(Uint32(1))); handler.complete(); indicationHandler->deliver(*indicationInstance); }
void ConfigSettingProvider::invokeMethod( const OperationContext & context, const CIMObjectPath & cimObjectPath, const CIMName & methodName, const Array<CIMParamValue> & inParams, MethodResultResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONFIG, "ConfigSettingProvider::invokeMethod"); if (!methodName.equal(METHOD_UPDATE_PROPERTY_VALUE)) { throw CIMException( CIM_ERR_METHOD_NOT_FOUND, methodName.getString()); } // Prepare the instance for modification. String propValue; Boolean resetValue = false; Boolean currentValueSet = false; Boolean plannedValueSet = false; Uint32 timeoutSeconds = 0; Array<CIMName> propertyList; for (Uint32 i = 0, n = inParams.size(); i < n ; ++i) { CIMName name = inParams[i].getParameterName(); if (name.equal(PARAM_PROPERTYVALUE)) { inParams[i].getValue().get(propValue); } else if (name.equal(PARAM_RESETVALUE)) { inParams[i].getValue().get(resetValue); } else if (name.equal(PARAM_UPDATECURRENTVALUE)) { inParams[i].getValue().get(currentValueSet); } else if (name.equal(PARAM_UPDATEPLANNEDVALUE)) { inParams[i].getValue().get(plannedValueSet); } else if (name.equal(PARAM_TIMEOUTPERIOD)) { inParams[i].getValue().get(timeoutSeconds); } else { throw CIMException( CIM_ERR_INVALID_PARAMETER, name.getString()); } } CIMInstance modifiedInst(PG_CONFIG_SETTING); if (currentValueSet) { if (!resetValue) { CIMProperty prop = CIMProperty(CURRENT_VALUE, CIMValue(propValue)); modifiedInst.addProperty(prop); } propertyList.append(CURRENT_VALUE); } if (plannedValueSet) { if (!resetValue) { CIMProperty prop = CIMProperty(PLANNED_VALUE, CIMValue(propValue)); modifiedInst.addProperty(prop); } propertyList.append(PLANNED_VALUE); } handler.processing(); _modifyInstance( context, cimObjectPath, modifiedInst, propertyList, timeoutSeconds); handler.deliver(CIMValue(true)); handler.complete(); PEG_METHOD_EXIT(); }
void ClientProvider::invokeMethod( const OperationContext & context, const CIMObjectPath & objectReference, const CIMName & methodName, const Array<CIMParamValue> & inParameters, MethodResultResponseHandler & handler) { handler.processing(); if (objectReference.getClassName().equal ("Sample_ClientProviderClass")) { if (methodName.equal ("DoConnect")) { if( inParameters.size() > 0 ) { String connectType = String::EMPTY; CIMValue paramVal; CIMClient client; paramVal = inParameters[0].getValue(); paramVal.get( connectType ); if( connectType == "Local" ) { client.connectLocal(); // Enumerate Instances. Array<CIMObjectPath> instanceNames = client.enumerateInstanceNames( "root/cimv2", "CIM_ManagedElement"); client.disconnect(); handler.deliver(CIMValue(0)); } else if ( connectType == "Remote" ) { String HOST = "localhost"; Uint32 PORT = 5989; String USER = "******"; String PASSWORD = "******"; const char* pegasusHome = getenv("PEGASUS_HOME"); String certpath = FileSystem::getAbsolutePath( pegasusHome, PEGASUS_SSLCLIENT_CERTIFICATEFILE); String randFile = String::EMPTY; randFile = FileSystem::getAbsolutePath( pegasusHome, PEGASUS_SSLCLIENT_RANDOMFILE); SSLContext sslcontext( certpath, verifyCertificate, randFile); client.connect( HOST, PORT, sslcontext, USER, PASSWORD ); } // Enumerate Instances. Array<CIMObjectPath> instanceNames = client.enumerateInstanceNames( "root/cimv2", "CIM_ManagedElement"); client.disconnect(); handler.deliver(CIMValue(0)); } else { handler.deliver(CIMValue(1)); } } } handler.complete(); }