CIMClass CIMClientRep::getClass( const CIMNamespaceName& nameSpace, const CIMName& className, Boolean localOnly, Boolean includeQualifiers, Boolean includeClassOrigin, const CIMPropertyList& propertyList ) { AutoPtr<CIMRequestMessage> request(new CIMGetClassRequestMessage( String::EMPTY, nameSpace, className, localOnly, includeQualifiers, includeClassOrigin, propertyList, QueueIdStack())); Message* message = _doRequest(request, CIM_GET_CLASS_RESPONSE_MESSAGE); CIMGetClassResponseMessage* response = (CIMGetClassResponseMessage*)message; AutoPtr<CIMGetClassResponseMessage> destroyer(response); return(response->cimClass); }
CIMInstance CIMClientRep::getInstance( const CIMNamespaceName& nameSpace, const CIMObjectPath& instanceName, Boolean localOnly, Boolean includeQualifiers, Boolean includeClassOrigin, const CIMPropertyList& propertyList ) { compareObjectPathtoCurrentConnection(instanceName); AutoPtr<CIMRequestMessage> request(new CIMGetInstanceRequestMessage( String::EMPTY, nameSpace, instanceName, localOnly, includeQualifiers, includeClassOrigin, propertyList, QueueIdStack())); Message* message = _doRequest(request, CIM_GET_INSTANCE_RESPONSE_MESSAGE); CIMGetInstanceResponseMessage* response = (CIMGetInstanceResponseMessage*)message; AutoPtr<CIMGetInstanceResponseMessage> destroyer(response); return(response->cimInstance); }
Array<CIMName> CIMClientRep::enumerateClassNames( const CIMNamespaceName& nameSpace, const CIMName& className, Boolean deepInheritance ) { AutoPtr<CIMRequestMessage> request(new CIMEnumerateClassNamesRequestMessage( String::EMPTY, nameSpace, className, deepInheritance, QueueIdStack())); Message* message = _doRequest(request, CIM_ENUMERATE_CLASS_NAMES_RESPONSE_MESSAGE); CIMEnumerateClassNamesResponseMessage* response = (CIMEnumerateClassNamesResponseMessage*)message; AutoPtr<CIMEnumerateClassNamesResponseMessage> destroyer(response); // Temporary code until internal structures use CIMName instead of String Array<CIMName> classNameArray; classNameArray.reserveCapacity(response->classNames.size()); for (Uint32 i=0; i<response->classNames.size(); i++) { classNameArray.append(response->classNames[i]); } return(classNameArray); }
Array<CIMInstance> CIMClientRep::enumerateInstances( const CIMNamespaceName& nameSpace, const CIMName& className, Boolean deepInheritance, Boolean localOnly, Boolean includeQualifiers, Boolean includeClassOrigin, const CIMPropertyList& propertyList ) { AutoPtr<CIMRequestMessage> request(new CIMEnumerateInstancesRequestMessage( String::EMPTY, nameSpace, className, deepInheritance, localOnly, includeQualifiers, includeClassOrigin, propertyList, QueueIdStack())); Message* message = _doRequest(request, CIM_ENUMERATE_INSTANCES_RESPONSE_MESSAGE); CIMEnumerateInstancesResponseMessage* response = (CIMEnumerateInstancesResponseMessage*)message; AutoPtr<CIMEnumerateInstancesResponseMessage> destroyer(response); return(response->cimNamedInstances); }
Array<CIMObject> CIMClientRep::references( const CIMNamespaceName& nameSpace, const CIMObjectPath& objectName, const CIMName& resultClass, const String& role, Boolean includeQualifiers, Boolean includeClassOrigin, const CIMPropertyList& propertyList ) { compareObjectPathtoCurrentConnection(objectName); AutoPtr<CIMRequestMessage> request(new CIMReferencesRequestMessage( String::EMPTY, nameSpace, objectName, resultClass, role, includeQualifiers, includeClassOrigin, propertyList, QueueIdStack())); Message* message = _doRequest(request, CIM_REFERENCES_RESPONSE_MESSAGE); CIMReferencesResponseMessage* response = (CIMReferencesResponseMessage*)message; AutoPtr<CIMReferencesResponseMessage> destroyer(response); return(response->cimObjects); }
Array<CIMObjectPath> CIMClientRep::referenceNames( const CIMNamespaceName& nameSpace, const CIMObjectPath& objectName, const CIMName& resultClass, const String& role ) { compareObjectPathtoCurrentConnection(objectName); AutoPtr<CIMRequestMessage> request(new CIMReferenceNamesRequestMessage( String::EMPTY, nameSpace, objectName, resultClass, role, QueueIdStack())); Message* message = _doRequest(request, CIM_REFERENCE_NAMES_RESPONSE_MESSAGE); CIMReferenceNamesResponseMessage* response = (CIMReferenceNamesResponseMessage*)message; AutoPtr<CIMReferenceNamesResponseMessage> destroyer(response); return(response->objectNames); }
void CIMExportClient::exportIndication( const String& url, const CIMInstance& instanceName, const ContentLanguageList& contentLanguages) { PEG_METHOD_ENTER (TRC_EXPORT_CLIENT, "CIMExportClient::exportIndication()"); try { // encode request CIMRequestMessage* request = new CIMExportIndicationRequestMessage( String::EMPTY, url, instanceName, QueueIdStack(), String::EMPTY, String::EMPTY); request->operationContext.set (ContentLanguageListContainer(contentLanguages)); PEG_TRACE ((TRC_INDICATION_GENERATION, Tracer::LEVEL4, "Exporting %s Indication for destination %s:%d%s", (const char*)(instanceName.getClassName().getString(). getCString()), (const char*)(_connectHost.getCString()), _connectPortNumber, (const char*)(url.getCString()))); Message* message = _doRequest(request, CIM_EXPORT_INDICATION_RESPONSE_MESSAGE); PEG_TRACE ((TRC_INDICATION_GENERATION, Tracer::LEVEL4, "%s Indication for destination %s:%d%s exported successfully", (const char*)(instanceName.getClassName().getString(). getCString()), (const char*)(_connectHost.getCString()), _connectPortNumber, (const char*)(url.getCString()))); CIMExportIndicationResponseMessage* response = (CIMExportIndicationResponseMessage*)message; AutoPtr<CIMExportIndicationResponseMessage> ap(response); } catch (const Exception& e) { PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1, "Failed to export indication: %s", (const char*)e.getMessage().getCString())); throw; } catch (...) { PEG_TRACE_CSTRING (TRC_DISCARDED_DATA, Tracer::LEVEL1, "Failed to export indication"); throw; } PEG_METHOD_EXIT(); }
// // Send notify config change message to provider manager service // This code was borrowed from the ConfigSettingProvider and should // be kept in sync. // The purpose is to ensure that OOP agents also get the update. // TBD, or is it for other reasons as well? // void ZOSConsoleManager::_sendNotifyConfigChangeMessage( const String& propertyName, const String& newPropertyValue, Boolean currentValueModified) { PEG_METHOD_ENTER(TRC_SERVER, "ZOSConsoleManager::_sendNotifyConfigChangeMessage"); ModuleController* controller = ModuleController::getModuleController(); MessageQueue * queue = MessageQueue::lookup( PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP); MessageQueueService * service = dynamic_cast<MessageQueueService *>(queue); if (service != NULL) { // create CIMNotifyConfigChangeRequestMessage CIMNotifyConfigChangeRequestMessage * notify_req = new CIMNotifyConfigChangeRequestMessage ( XmlWriter::getNextMessageId (), propertyName, newPropertyValue, currentValueModified, QueueIdStack(service->getQueueId())); notify_req->operationContext.insert( IdentityContainer(System::getEffectiveUserName())); // create request envelope AsyncLegacyOperationStart asyncRequest( NULL, service->getQueueId(), notify_req); AutoPtr<AsyncReply> asyncReply( controller->ClientSendWait(service->getQueueId(), &asyncRequest)); AutoPtr<CIMNotifyConfigChangeResponseMessage> response( reinterpret_cast<CIMNotifyConfigChangeResponseMessage *>( (static_cast<AsyncLegacyOperationResult *> (asyncReply.get()))->get_result())); if (response->cimException.getCode() != CIM_ERR_SUCCESS) { CIMException e = response->cimException; const CString exMsg = e.getMessage().getCString(); PEG_TRACE((TRC_SERVER, Tracer::LEVEL1, "Notify config changed failed with rc=%d, message = %s", e.getCode(), (const char*)exMsg)); PEG_METHOD_EXIT(); } } PEG_METHOD_EXIT(); }
SCMOClass ProviderAgent::_scmoClassCache_GetClass( const CIMNamespaceName& nameSpace, const CIMName& className) { PEG_METHOD_ENTER(TRC_PROVIDERAGENT, "ProviderAgent::_scmoClassCache_GetClass"); // create message ProvAgtGetScmoClassRequestMessage* message = new ProvAgtGetScmoClassRequestMessage( XmlWriter::getNextMessageId(), nameSpace, className, QueueIdStack()); // Send the request for the SCMOClass to the server _providerAgent->_writeResponse(message); delete message; // Wait for semaphore signaled by _readAndProcessRequest() if (!_scmoClassDelivered.time_wait( PEGASUS_DEFAULT_CLIENT_TIMEOUT_MILLISECONDS)) { PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1, "Timed-out waiting for SCMOClass for " "Name Space Name '%s' Class Name '%s'", (const char*)nameSpace.getString().getCString(), (const char*)className.getString().getCString())); PEG_METHOD_EXIT(); return SCMOClass("",""); } if ( 0 == _transferSCMOClass) { PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1, "No SCMOClass received for Name Space Name '%s' Class Name '%s'", (const char*)nameSpace.getString().getCString(), (const char*)className.getString().getCString())); PEG_METHOD_EXIT(); return SCMOClass("",""); } // Create a local copy. SCMOClass ret = SCMOClass(*_transferSCMOClass); // Delete the transferred instance. delete _transferSCMOClass; _transferSCMOClass = 0; PEG_METHOD_EXIT(); return ret; }
// // send notify config change message to provider manager service // void ConfigSettingProvider::_sendNotifyConfigChangeMessage( const String& propertyName, const String& newPropertyValue, const String& userName, const char *queueName, Boolean currentValueModified) { PEG_METHOD_ENTER(TRC_CONFIG, "ConfigSettingProvider::_sendNotifyConfigChangeMessage"); ModuleController* controller = ModuleController::getModuleController(); MessageQueue * queue = MessageQueue::lookup(queueName); MessageQueueService * service = dynamic_cast<MessageQueueService *>(queue); if (service != NULL) { // create CIMNotifyConfigChangeRequestMessage CIMNotifyConfigChangeRequestMessage * notify_req = new CIMNotifyConfigChangeRequestMessage ( XmlWriter::getNextMessageId (), propertyName, newPropertyValue, currentValueModified, QueueIdStack(service->getQueueId())); notify_req->operationContext.insert( IdentityContainer(userName)); // create request envelope AsyncLegacyOperationStart asyncRequest( NULL, service->getQueueId(), notify_req); AutoPtr<AsyncReply> asyncReply( controller->ClientSendWait(service->getQueueId(), &asyncRequest)); AutoPtr<CIMNotifyConfigChangeResponseMessage> response( reinterpret_cast<CIMNotifyConfigChangeResponseMessage *>( (static_cast<AsyncLegacyOperationResult *> (asyncReply.get()))->get_result())); if (response->cimException.getCode() != CIM_ERR_SUCCESS) { CIMException e = response->cimException; throw (e); } } }
Array<CIMQualifierDecl> CIMClientRep::enumerateQualifiers( const CIMNamespaceName& nameSpace ) { AutoPtr<CIMRequestMessage> request(new CIMEnumerateQualifiersRequestMessage( String::EMPTY, nameSpace, QueueIdStack())); Message* message = _doRequest(request, CIM_ENUMERATE_QUALIFIERS_RESPONSE_MESSAGE); CIMEnumerateQualifiersResponseMessage* response = (CIMEnumerateQualifiersResponseMessage*)message; AutoPtr<CIMEnumerateQualifiersResponseMessage> destroyer(response); return(response->qualifierDeclarations); }
void CIMClientRep::setQualifier( const CIMNamespaceName& nameSpace, const CIMQualifierDecl& qualifierDeclaration ) { AutoPtr<CIMRequestMessage> request(new CIMSetQualifierRequestMessage( String::EMPTY, nameSpace, qualifierDeclaration, QueueIdStack())); Message* message = _doRequest(request, CIM_SET_QUALIFIER_RESPONSE_MESSAGE); CIMSetQualifierResponseMessage* response = (CIMSetQualifierResponseMessage*)message; AutoPtr<CIMSetQualifierResponseMessage> destroyer(response); }
void CIMClientRep::modifyClass( const CIMNamespaceName& nameSpace, const CIMClass& modifiedClass ) { AutoPtr<CIMRequestMessage> request(new CIMModifyClassRequestMessage( String::EMPTY, nameSpace, modifiedClass, QueueIdStack())); Message* message = _doRequest(request, CIM_MODIFY_CLASS_RESPONSE_MESSAGE); CIMModifyClassResponseMessage* response = (CIMModifyClassResponseMessage*)message; AutoPtr<CIMModifyClassResponseMessage> destroyer(response); }
void CIMClientRep::deleteQualifier( const CIMNamespaceName& nameSpace, const CIMName& qualifierName ) { AutoPtr<CIMRequestMessage> request(new CIMDeleteQualifierRequestMessage( String::EMPTY, nameSpace, qualifierName, QueueIdStack())); Message* message = _doRequest(request, CIM_DELETE_QUALIFIER_RESPONSE_MESSAGE); CIMDeleteQualifierResponseMessage* response = (CIMDeleteQualifierResponseMessage*)message; AutoPtr<CIMDeleteQualifierResponseMessage> destroyer(response); }
void CIMClientRep::createClass( const CIMNamespaceName& nameSpace, const CIMClass& newClass ) { AutoPtr<CIMRequestMessage> request(new CIMCreateClassRequestMessage( String::EMPTY, nameSpace, newClass, QueueIdStack())); Message* message = _doRequest(request, CIM_CREATE_CLASS_RESPONSE_MESSAGE); CIMCreateClassResponseMessage* response = (CIMCreateClassResponseMessage*)message; AutoPtr<CIMCreateClassResponseMessage> destroyer(response); }
void CIMClientRep::deleteClass( const CIMNamespaceName& nameSpace, const CIMName& className ) { AutoPtr<CIMRequestMessage> request(new CIMDeleteClassRequestMessage( String::EMPTY, nameSpace, className, QueueIdStack())); Message* message = _doRequest(request, CIM_DELETE_CLASS_RESPONSE_MESSAGE); CIMDeleteClassResponseMessage* response = (CIMDeleteClassResponseMessage*)message; AutoPtr<CIMDeleteClassResponseMessage> destroyer(response); }
void CIMClientRep::deleteInstance( const CIMNamespaceName& nameSpace, const CIMObjectPath& instanceName ) { compareObjectPathtoCurrentConnection(instanceName); AutoPtr<CIMRequestMessage> request(new CIMDeleteInstanceRequestMessage( String::EMPTY, nameSpace, instanceName, QueueIdStack())); Message* message = _doRequest(request, CIM_DELETE_INSTANCE_RESPONSE_MESSAGE); CIMDeleteInstanceResponseMessage* response = (CIMDeleteInstanceResponseMessage*)message; AutoPtr<CIMDeleteInstanceResponseMessage> destroyer(response); }
Array<CIMObjectPath> CIMClientRep::enumerateInstanceNames( const CIMNamespaceName& nameSpace, const CIMName& className ) { AutoPtr<CIMRequestMessage> request(new CIMEnumerateInstanceNamesRequestMessage( String::EMPTY, nameSpace, className, QueueIdStack())); Message* message = _doRequest(request, CIM_ENUMERATE_INSTANCE_NAMES_RESPONSE_MESSAGE); CIMEnumerateInstanceNamesResponseMessage* response = (CIMEnumerateInstanceNamesResponseMessage*)message; AutoPtr<CIMEnumerateInstanceNamesResponseMessage> destroyer(response); return(response->instanceNames); }
CIMQualifierDecl CIMClientRep::getQualifier( const CIMNamespaceName& nameSpace, const CIMName& qualifierName ) { AutoPtr<CIMRequestMessage> request(new CIMGetQualifierRequestMessage( String::EMPTY, nameSpace, qualifierName, QueueIdStack())); Message* message = _doRequest(request, CIM_GET_QUALIFIER_RESPONSE_MESSAGE); CIMGetQualifierResponseMessage* response = (CIMGetQualifierResponseMessage*)message; AutoPtr<CIMGetQualifierResponseMessage> destroyer(response); return(response->cimQualifierDecl); }
CIMObjectPath CIMClientRep::createInstance( const CIMNamespaceName& nameSpace, const CIMInstance& newInstance ) { compareObjectPathtoCurrentConnection(newInstance.getPath()); AutoPtr<CIMRequestMessage> request(new CIMCreateInstanceRequestMessage( String::EMPTY, nameSpace, newInstance, QueueIdStack())); Message* message = _doRequest(request, CIM_CREATE_INSTANCE_RESPONSE_MESSAGE); CIMCreateInstanceResponseMessage* response = (CIMCreateInstanceResponseMessage*)message; AutoPtr<CIMCreateInstanceResponseMessage> destroyer(response); return(response->instanceName); }
CIMExportIndicationRequestMessage* CIMExportRequestDecoder::decodeExportIndicationRequest( Uint32 queueId, XmlParser& parser, const String& messageId, const String& requestUri) { CIMInstance instanceName; String destStr = requestUri.subString( requestUri.find("/CIMListener") + 12, PEG_NOT_FOUND); for (const char* name; XmlReader::getEParamValueTag(parser, name);) { if (System::strcasecmp(name, "NewIndication") == 0) { XmlReader::getInstanceElement(parser, instanceName); } else { MessageLoaderParms mlParms( "ExportServer.CIMExportRequestDecoder." "UNRECOGNIZED_EXPPARAMVALUE_NAME", "Unrecognized EXPPARAMVALUE Name $0", name); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, mlParms); } XmlReader::expectEndTag(parser, "EXPPARAMVALUE"); } CIMExportIndicationRequestMessage* request = new CIMExportIndicationRequestMessage( messageId, destStr, instanceName, QueueIdStack(queueId, _returnQueueId)); return request; }
Array<CIMObject> CIMClientRep::execQuery( const CIMNamespaceName& nameSpace, const String& queryLanguage, const String& query ) { AutoPtr<CIMRequestMessage> request(new CIMExecQueryRequestMessage( String::EMPTY, nameSpace, queryLanguage, query, QueueIdStack())); Message* message = _doRequest(request, CIM_EXEC_QUERY_RESPONSE_MESSAGE); CIMExecQueryResponseMessage* response = (CIMExecQueryResponseMessage*)message; AutoPtr<CIMExecQueryResponseMessage> destroyer(response); return(response->cimObjects); }
void CIMClientRep::modifyInstance( const CIMNamespaceName& nameSpace, const CIMInstance& modifiedInstance, Boolean includeQualifiers, const CIMPropertyList& propertyList ) { compareObjectPathtoCurrentConnection(modifiedInstance.getPath()); AutoPtr<CIMRequestMessage> request(new CIMModifyInstanceRequestMessage( String::EMPTY, nameSpace, modifiedInstance, includeQualifiers, propertyList, QueueIdStack())); Message* message = _doRequest(request, CIM_MODIFY_INSTANCE_RESPONSE_MESSAGE); CIMModifyInstanceResponseMessage* response = (CIMModifyInstanceResponseMessage*)message; AutoPtr<CIMModifyInstanceResponseMessage> destroyer(response); }
void CIMClientRep::setProperty( const CIMNamespaceName& nameSpace, const CIMObjectPath& instanceName, const CIMName& propertyName, const CIMValue& newValue ) { compareObjectPathtoCurrentConnection(instanceName); AutoPtr<CIMRequestMessage> request(new CIMSetPropertyRequestMessage( String::EMPTY, nameSpace, instanceName, propertyName, newValue, QueueIdStack())); Message* message = _doRequest(request, CIM_SET_PROPERTY_RESPONSE_MESSAGE); CIMSetPropertyResponseMessage* response = (CIMSetPropertyResponseMessage*)message; AutoPtr<CIMSetPropertyResponseMessage> destroyer(response); }
CIMValue CIMClientRep::invokeMethod( const CIMNamespaceName& nameSpace, const CIMObjectPath& instanceName, const CIMName& methodName, const Array<CIMParamValue>& inParameters, Array<CIMParamValue>& outParameters ) { // ATTN-RK-P2-20020301: Does it make sense to have a nameSpace parameter // when the namespace should already be included in the instanceName? // ATTN-RK-P3-20020301: Do we need to make sure the caller didn't specify // a host name in the instanceName? // solved with PEP#139 Stage1 as other CIMOMs contained in the object path // will cause a TypeMisMatchException compareObjectPathtoCurrentConnection(instanceName); AutoPtr<CIMRequestMessage> request(new CIMInvokeMethodRequestMessage( String::EMPTY, nameSpace, instanceName, methodName, inParameters, QueueIdStack())); Message* message = _doRequest(request, CIM_INVOKE_METHOD_RESPONSE_MESSAGE); CIMInvokeMethodResponseMessage* response = (CIMInvokeMethodResponseMessage*)message; AutoPtr<CIMInvokeMethodResponseMessage> destroyer(response); outParameters = response->outParameters; return(response->retValue); }
void ShutdownService::_shutdownProviders() { PEG_METHOD_ENTER(TRC_SHUTDOWN, "ShutdownService::_shutdownProviders"); // // get provider manager service // MessageQueue * queue = MessageQueue::lookup(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP); if (queue == 0) { PEG_METHOD_EXIT(); return; } MessageQueueService * _service = dynamic_cast<MessageQueueService *>(queue); Uint32 _queueId = _service->getQueueId(); // // create stop all providers request // CIMStopAllProvidersRequestMessage * stopRequest = new CIMStopAllProvidersRequestMessage( XmlWriter::getNextMessageId (), QueueIdStack(_queueId)); // // create async request message // AsyncLegacyOperationStart * asyncRequest = new AsyncLegacyOperationStart ( _service->get_next_xid(), NULL, _queueId, stopRequest, _queueId); // Use SendWait, which is serialiazed and waits. Do not use asynchronous callback // as the response might be received _after_ the provider or this service has // been deleted. AsyncReply * asyncReply = _controller->ClientSendWait(*_client_handle, _queueId, asyncRequest); CIMStopAllProvidersResponseMessage * response = reinterpret_cast<CIMStopAllProvidersResponseMessage *>( (static_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result()); if (response->cimException.getCode() != CIM_ERR_SUCCESS) { // l10n Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, "Server.ShutdownService.CIM_PROVIDER_SHUTDOWN", "$0 - CIM provider shutdown exception has occurred.", "ShutdownService::_shutdownProviders"); // Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, // "ShutdownService::_shutdownProviders - CIM provider shutdown exception has occurred."); CIMException e = response->cimException; delete stopRequest; delete asyncRequest; delete asyncReply; delete response; PEG_METHOD_EXIT(); throw (e); } //delete stopRequest; delete asyncRequest; delete asyncReply; delete response; PEG_METHOD_EXIT(); return; }
void ProviderAgent::run() { PEG_METHOD_ENTER(TRC_PROVIDERAGENT, "ProviderAgent::run"); // Enable the signal handler to terminate gracefully on SIGHUP and SIGTERM getSigHandle()->registerHandler(PEGASUS_SIGHUP, _terminateSignalHandler); getSigHandle()->activate(PEGASUS_SIGHUP); getSigHandle()->registerHandler(PEGASUS_SIGTERM, _terminateSignalHandler); getSigHandle()->activate(PEGASUS_SIGTERM); // Restore the SIGCHLD signal behavior to its default action getSigHandle()->defaultAction(PEGASUS_SIGCHLD); #ifdef PEGASUS_OS_ZOS // Establish handling signal send to us on USS shutdown getSigHandle()->registerHandler(PEGASUS_SIGDANGER, _terminateSignalHandler); getSigHandle()->activate(PEGASUS_SIGDANGER); // enable process to receive SIGDANGER on USS shutdown __shutdown_registration(_SDR_NOTIFY, _SDR_REGPROCESS, _SDR_SENDSIGDANGER); #endif #ifdef PEGASUS_OS_PASE // PASE environment need more signal handler getSigHandle()->registerHandler(SIGFPE, _synchronousSignalHandler); getSigHandle()->activate(SIGFPE); getSigHandle()->registerHandler(SIGILL, _synchronousSignalHandler); getSigHandle()->activate(SIGILL); getSigHandle()->registerHandler(SIGSEGV, _synchronousSignalHandler); getSigHandle()->activate(SIGSEGV); getSigHandle()->registerHandler(SIGIO, _asynchronousSignalHandler); getSigHandle()->activate(SIGIO); #endif while (!_terminating) { Boolean active = true; try { // // Read and process the next request // active = _readAndProcessRequest(); } catch (Exception& e) { PEG_TRACE((TRC_PROVIDERAGENT, Tracer::LEVEL1, "Unexpected Exception from _readAndProcessRequest(): %s", (const char*)e.getMessage().getCString())); _terminating = true; } catch (...) { PEG_TRACE_CSTRING(TRC_PROVIDERAGENT, Tracer::LEVEL1, "Unexpected exception from _readAndProcessRequest()."); _terminating = true; } if (_terminating) { if (!_providersStopped) { // // Stop all providers // CIMStopAllProvidersRequestMessage stopRequest("0", QueueIdStack(0)); AutoPtr<Message> stopResponse(_processRequest(&stopRequest)); // If there are agent threads running exit from here.If provider // is not responding cimprovagt may loop forever in ThreadPool // destructor waiting for running threads to become idle. if (_threadPool.runningCount()) { PEG_TRACE_CSTRING(TRC_PROVIDERAGENT, Tracer::LEVEL1, "Agent threads are running, terminating forcibly."); exit(1); } } } else if (!active) { // // Stop agent process when no more providers are loaded // try { if (!_providerManagerRouter.hasActiveProviders() && (_threadPool.runningCount() == 0)) { PEG_TRACE_CSTRING(TRC_PROVIDERAGENT, Tracer::LEVEL2, "No active providers. Exiting."); _terminating = true; } else { _threadPool.cleanupIdleThreads(); } } catch (...) { // Do not terminate the agent on this exception PEG_TRACE_CSTRING(TRC_PROVIDERAGENT, Tracer::LEVEL1, "Unexpected exception from hasActiveProviders()"); } } } // Notify the cimserver that the provider agent is exiting cleanly. Uint32 messageLength = 0; _pipeToServer->writeBuffer((const char*)&messageLength, sizeof(Uint32)); PEG_METHOD_EXIT(); }
void EnableIndicationsResponseHandler::deliver( const OperationContext& context, const CIMIndication& cimIndication) { if (cimIndication.isUninitialized()) { MessageLoaderParms message( "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION", "The object is not initialized."); throw CIMException(CIM_ERR_FAILED, message); } // ATTN: temporarily convert indication to instance CIMInstance cimInstance(cimIndication); // Get list of subscription instance names from context Array<CIMObjectPath> subscriptionInstanceNames; if (context.contains(SubscriptionInstanceNamesContainer::NAME)) { SubscriptionInstanceNamesContainer container = context.get(SubscriptionInstanceNamesContainer::NAME); subscriptionInstanceNames = container.getInstanceNames(); } else { subscriptionInstanceNames.clear(); } ContentLanguageList contentLangs; if (context.contains(ContentLanguageListContainer::NAME)) { // Get the Content-Language for this indication. The provider // does not have to add specify a language for the indication. ContentLanguageListContainer langContainer = context.get(ContentLanguageListContainer::NAME); contentLangs = langContainer.getLanguages(); } else { // The provider did not explicitly set a Content-Language for // the indication. Fall back to the lang set in this object. contentLangs = getLanguages(); } Uint32 timeoutMilliSec = 0; if (context.contains(TimeoutContainer::NAME)) { TimeoutContainer timeoutContainer = context.get(TimeoutContainer::NAME); timeoutMilliSec = timeoutContainer.getTimeOut(); } // create message CIMProcessIndicationRequestMessage* request = new CIMProcessIndicationRequestMessage( XmlWriter::getNextMessageId(), cimInstance.getPath().getNameSpace(), cimInstance, subscriptionInstanceNames, _provider, QueueIdStack(), // Must be filled in by the callback function timeoutMilliSec); request->operationContext = context; if (request->operationContext.contains(ContentLanguageListContainer::NAME)) { request->operationContext.set( ContentLanguageListContainer(contentLangs)); } else { request->operationContext.insert( ContentLanguageListContainer(contentLangs)); } _indicationCallback(request); }
void DefaultPropertyOwner::_requestIndicationServiceStateChange( const String& userName, Boolean enable, Uint32 timeoutSeconds) { MessageQueue *queue = MessageQueue::lookup( PEGASUS_QUEUENAME_INDICATIONSERVICE); // Return if indication service can not be found if (!queue) { return; } Uint32 queueId = queue->getQueueId(); const String METHOD_NAME = "RequestStateChange"; const String PARAMNAME_REQUESTEDSTATE = "RequestedState"; const String PARAMNAME_TIMEOUTPERIOD = "TimeoutPeriod"; const Uint16 STATE_ENABLED = 2; const Uint16 STATE_DISABLED = 3; String referenceStr("//", 2); referenceStr.append(System::getHostName()); referenceStr.append("/"); referenceStr.append(PEGASUS_NAMESPACENAME_INTEROP.getString()); referenceStr.append(":"); referenceStr.append( PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE.getString()); CIMObjectPath reference(referenceStr); Array<CIMParamValue> inParams; Array<CIMParamValue> outParams; inParams.append(CIMParamValue(PARAMNAME_REQUESTEDSTATE, CIMValue(enable ? STATE_ENABLED : STATE_DISABLED))); inParams.append(CIMParamValue(PARAMNAME_TIMEOUTPERIOD, CIMValue(CIMDateTime(timeoutSeconds * 1000000, true)))); MessageQueueService *controller = ModuleController::getModuleController(); try { CIMInvokeMethodRequestMessage* request = new CIMInvokeMethodRequestMessage( XmlWriter::getNextMessageId(), PEGASUS_NAMESPACENAME_INTEROP, referenceStr, CIMNameCast(METHOD_NAME), inParams, QueueIdStack(queueId)); request->operationContext.insert( IdentityContainer(userName)); AsyncLegacyOperationStart *asyncRequest = new AsyncLegacyOperationStart( 0, queueId, request); AsyncReply * asyncReply = controller->SendWait(asyncRequest); CIMInvokeMethodResponseMessage * response = reinterpret_cast<CIMInvokeMethodResponseMessage *>( (static_cast<AsyncLegacyOperationResult *>( asyncReply))->get_result()); CIMException e = response->cimException; delete response; delete asyncRequest; delete asyncReply; if (e.getCode() != CIM_ERR_SUCCESS) { throw e; } } catch(const Exception &e) { PEG_TRACE((TRC_CONFIG,Tracer::LEVEL1, "Exception caught while invoking CIM_IndicationService." "RequestStateChange() method: %s", (const char*)e.getMessage().getCString())); throw; } catch(...) { PEG_TRACE_CSTRING(TRC_CONFIG,Tracer::LEVEL1, "Unknown exception caught while invoking CIM_IndicationService." "RequestStateChange() method"); throw; } }
CIMHandleIndicationResponseMessage* IndicationHandlerService::_handleIndication( CIMHandleIndicationRequestMessage* request) { PEG_METHOD_ENTER (TRC_IND_HANDLE, "IndicationHandlerService::_handleIndication"); CIMException cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_SUCCESS, String::EMPTY); CIMName className = request->handlerInstance.getClassName(); CIMNamespaceName nameSpace = request->nameSpace; CIMInstance indication = request->indicationInstance; CIMInstance handler = request->handlerInstance; Uint32 pos = PEG_NOT_FOUND; if (className.equal (PEGASUS_CLASSNAME_INDHANDLER_CIMXML) || className.equal (PEGASUS_CLASSNAME_LSTNRDST_CIMXML)) { pos = handler.findProperty(PEGASUS_PROPERTYNAME_LSTNRDST_DESTINATION); if (pos == PEG_NOT_FOUND) { cimException = PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms("HandlerService.IndicationHandlerService." "CIMXML_HANDLER_WITHOUT_DESTINATION", "CIMXml Handler missing Destination property")); } else { CIMProperty prop = handler.getProperty(pos); String destination = prop.getValue().toString(); if (destination.size() == 0) { cimException = PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms("HandlerService.IndicationHandlerService." "INVALID_DESTINATION", "invalid destination")); } //compared index 10 is not : else if (destination.subString(0, 10) == String("localhost/")) { Array<Uint32> exportServer; find_services(PEGASUS_QUEUENAME_EXPORTREQDISPATCHER, 0, 0, &exportServer); // Listener is build with Cimom, so send message to ExportServer AutoPtr<CIMExportIndicationRequestMessage> exportmessage( new CIMExportIndicationRequestMessage( XmlWriter::getNextMessageId(), destination.subString(21), //taking localhost/CIMListener portion out from reg indication, QueueIdStack(exportServer[0], getQueueId()), String::EMPTY, String::EMPTY)); exportmessage->operationContext.set( request->operationContext.get( ContentLanguageListContainer::NAME)); AutoPtr<AsyncOpNode> op( this->get_op()); AutoPtr<AsyncLegacyOperationStart> asyncRequest( new AsyncLegacyOperationStart( get_next_xid(), op.get(), exportServer[0], exportmessage.get(), _queueId)); exportmessage.release(); PEG_TRACE_STRING(TRC_IND_HANDLE, Tracer::LEVEL4, "Indication handler forwarding message to " + ((MessageQueue::lookup(exportServer[0])) ? String( ((MessageQueue::lookup(exportServer[0]))-> getQueueName()) ) : String("BAD queue name"))); //SendAsync(op, // exportServer[0], // IndicationHandlerService::_handleIndicationCallBack, // this, // (void *)request->queueIds.top()); AutoPtr<AsyncReply> asyncReply(SendWait(asyncRequest.get())); asyncRequest.release(); // Return the ExportIndication results in HandleIndication //response AutoPtr<CIMExportIndicationResponseMessage> exportResponse( reinterpret_cast<CIMExportIndicationResponseMessage *>( (static_cast<AsyncLegacyOperationResult *>( asyncReply.get()))->get_result())); cimException = exportResponse->cimException; op->release(); this->return_op(op.release()); } else { _loadHandler(request, cimException); } } } else if (className.equal (PEGASUS_CLASSNAME_INDHANDLER_SNMP)) { pos = handler.findProperty(PEGASUS_PROPERTYNAME_LSTNRDST_TARGETHOST); if (pos == PEG_NOT_FOUND) { cimException = PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms("HandlerService.IndicationHandlerService." "SNMP_HANDLER_WITHOUT_TARGETHOST", "Snmp Handler missing Targethost property")); } else { CIMProperty prop = handler.getProperty(pos); String destination = prop.getValue().toString(); if (destination.size() == 0) { cimException = PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms("HandlerService.IndicationHandlerService." "INVALID_TARGETHOST", "invalid targethost")); } else { _loadHandler(request, cimException); } } } else if ((className.equal (PEGASUS_CLASSNAME_LSTNRDST_SYSTEM_LOG)) || (className.equal (PEGASUS_CLASSNAME_LSTNRDST_EMAIL))) { _loadHandler(request, cimException); } CIMHandleIndicationResponseMessage* response = new CIMHandleIndicationResponseMessage( request->messageId, cimException, request->queueIds.copyAndPop()); delete request; return response; }