1 //%/////////////////////////////////////////////////////////////////////////////
3 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
4 // The Open Group, Tivoli Systems
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to
8 // deal in the Software without restriction, including without limitation the
9 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 // sell copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
13 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
14 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
15 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
16 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
18 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 //==============================================================================
24 // Author: Yi Zhou (yi_zhou@hp.com)
26 // Modified By: Chip Vincent (cvincent@us.ibm.com)
27 // Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
28 // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
29 // Carol Ann Krug Graves, Hewlett-Packard Company
30 // (carolann_graves@hp.com)
32 //%/////////////////////////////////////////////////////////////////////////////
34 #include "ProviderRegistrationProvider.h"
36 #include <Pegasus/Common/PegasusVersion.h>
37 #include <Pegasus/Common/XmlWriter.h>
38 #include <Pegasus/Common/Constants.h>
39 #include <Pegasus/Common/CIMMessage.h>
40 #include <Pegasus/Common/OperationContext.h>
41 #include <Pegasus/Common/System.h>
43 PEGASUS_NAMESPACE_BEGIN
46 The name of the CapabilityID property for provider capabilities class
48 static const CIMName _PROPERTY_CAPABILITYID = CIMName ("CapabilityID");
53 static const Uint16 _MODULE_OK = 2;
56 stopping provider method
58 static const CIMName _STOP_PROVIDER = CIMName ("Stop");
61 starting provider method
63 static const CIMName _START_PROVIDER = CIMName ("Start");
68 static const Uint16 _MODULE_STOPPING = 9;
70 static const Uint16 _MODULE_STOPPED = 10;
72 ProviderRegistrationProvider::ProviderRegistrationProvider(
73 ProviderRegistrationManager * providerRegistrationManager)
74 :_id(peg_credential_types::PROVIDER)
76 _providerRegistrationManager = providerRegistrationManager;
78 _controller = &(ModuleController::get_client_handle(_id, &_client_handle));
79 if(_client_handle == NULL)
80 throw UninitializedObjectException();
83 ProviderRegistrationProvider::~ProviderRegistrationProvider(void)
85 if (_providerRegistrationManager)
87 delete _providerRegistrationManager;
92 delete _client_handle;
97 void ProviderRegistrationProvider::initialize(CIMOMHandle & cimom)
99 // This method should not be called because this is a control provider
100 // and is not dynamically loaded through the provider manager
103 void ProviderRegistrationProvider::terminate(void)
107 // get registered provider
108 void ProviderRegistrationProvider::getInstance(
109 const OperationContext & context,
110 const CIMObjectPath & instanceReference,
111 const Boolean includeQualifiers,
112 const Boolean includeClassOrigin,
113 const CIMPropertyList & propertyList,
114 InstanceResponseHandler & handler)
117 if(!instanceReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
119 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
120 instanceReference.getNameSpace().getString());
123 // ensure the class existing in the specified namespace
124 CIMName className = instanceReference.getClassName();
126 if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
127 !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
128 !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
130 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
131 className.getString());
134 // begin processing the request
135 handler.processing();
137 CIMInstance instance;
141 instance = _providerRegistrationManager->getInstance(instanceReference);
143 catch(CIMException& e)
148 handler.deliver(instance);
150 // complete processing the request
154 // get all registered providers
155 void ProviderRegistrationProvider::enumerateInstances(
156 const OperationContext & context,
157 const CIMObjectPath & classReference,
158 const Boolean includeQualifiers,
159 const Boolean includeClassOrigin,
160 const CIMPropertyList & propertyList,
161 InstanceResponseHandler & handler)
163 if(!classReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
165 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
166 classReference.getNameSpace().getString());
169 // ensure the class existing in the specified namespace
170 CIMName className = classReference.getClassName();
172 if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
173 !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
174 !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
176 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
177 className.getString());
180 // begin processing the request
181 handler.processing();
183 Array<CIMInstance> enumInstances;
187 enumInstances = _providerRegistrationManager->enumerateInstances(classReference);
189 catch(CIMException& e)
194 handler.deliver(enumInstances);
196 // complete processing the request
200 // get all registered provider names
201 void ProviderRegistrationProvider::enumerateInstanceNames(
202 const OperationContext & context,
203 const CIMObjectPath & classReference,
204 ObjectPathResponseHandler & handler)
206 if(!classReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
208 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
209 classReference.getNameSpace().getString());
212 // ensure the class existing in the specified namespace
213 CIMName className = classReference.getClassName();
215 if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
216 !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
217 !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
219 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
220 className.getString());
223 // begin processing the request
224 handler.processing();
226 Array<CIMObjectPath> enumInstanceNames;
228 // get all instance names from repository
232 _providerRegistrationManager->enumerateInstanceNames(classReference);
234 catch(CIMException& e)
239 handler.deliver(enumInstanceNames);
241 // complete processing the request
245 // change properties for the registered provider
246 // only support to change property of Namespaces, property of
247 // SupportedProperties, and property of SupportedMethods
248 void ProviderRegistrationProvider::modifyInstance(
249 const OperationContext & context,
250 const CIMObjectPath & instanceReference,
251 const CIMInstance & instanceObject,
252 const Boolean includeQualifiers,
253 const CIMPropertyList & propertyList,
254 ResponseHandler & handler)
256 // get userName and only privileged user can execute this operation
260 IdentityContainer container = context.get(IdentityContainer::NAME);
261 userName = container.getUserName();
265 userName = String::EMPTY;
268 if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
270 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,
271 "You must have superuser privilege to modify the registration.");
274 if(!instanceReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
276 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
277 instanceReference.getNameSpace().getString());
281 // only support to modify the instance of PG_ProviderCapabilities
283 if (!instanceReference.getClassName().equal
284 (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES))
286 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
287 instanceReference.getClassName().getString());
291 // only can modify the property of Namespaces, property of
292 // SupportedProperties, and property of SupportedMethods
294 if (propertyList.isNull())
296 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
297 "Only can modify Namespaces, SupportedProperties, and SupportedMethods.");
300 Array<CIMName> propertyArray = propertyList.getPropertyNameArray();
301 for (Uint32 i=0; i<propertyArray.size(); i++)
303 if (!propertyArray[i].equal (_PROPERTY_NAMESPACES) &&
304 !propertyArray[i].equal (_PROPERTY_SUPPORTEDPROPERTIES) &&
305 !propertyArray[i].equal (_PROPERTY_SUPPORTEDMETHODS))
307 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
308 propertyArray[i].getString());
312 // begin processing the request
313 handler.processing();
317 _providerRegistrationManager->modifyInstance(instanceReference,
318 instanceObject, includeQualifiers, propertyArray);
320 catch(CIMException& e)
325 // complete processing the request
329 // register a provider
330 void ProviderRegistrationProvider::createInstance(
331 const OperationContext & context,
332 const CIMObjectPath & instanceReference,
333 const CIMInstance & instanceObject,
334 ObjectPathResponseHandler & handler)
336 // get userName and only privileged user can execute this operation
340 IdentityContainer container = context.get(IdentityContainer::NAME);
341 userName = container.getUserName();
345 userName = String::EMPTY;
348 if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
350 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,
351 "You must have superuser privilege to register providers.");
354 CIMName className = instanceReference.getClassName();
355 CIMNamespaceName nameSpace = instanceReference.getNameSpace();
357 CIMObjectPath returnReference;
359 CIMInstance instance = instanceObject;
361 if(!nameSpace.equal (PEGASUS_NAMESPACENAME_INTEROP))
363 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
364 nameSpace.getString());
367 // ensure the class existing in the specified namespace
368 if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
369 !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
370 !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
372 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
373 className.getString());
377 // Check all required properties are set
379 if (className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
382 // Name, Version, InterfaceType, InterfaceVersion, and Location
383 // properties must be set
384 // OperationalStatus property needs to be set. If not, set to default
386 if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULE_NAME) ==
389 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
390 "Missing Name which is required property in PG_ProviderModule class.");
393 if (instanceObject.findProperty(_PROPERTY_VENDOR) == PEG_NOT_FOUND)
395 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
396 "Missing Vendor which is required property in PG_ProviderModule class.");
399 if (instanceObject.findProperty(_PROPERTY_VERSION) == PEG_NOT_FOUND)
401 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
402 "Missing Version which is required property in PG_ProviderModule class.");
405 Uint32 ifcTypeIndex =
406 instanceObject.findProperty(_PROPERTY_INTERFACETYPE);
407 if (ifcTypeIndex == PEG_NOT_FOUND)
409 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
410 "Missing InterfaceType which is required property in PG_ProviderModule class.");
412 String ifcTypeString;
413 instanceObject.getProperty(ifcTypeIndex).getValue().
415 if (ifcTypeString != "C++Default" || ifcTypeString != "CMPI" )
417 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
418 "Unsupported InterfaceType value: \"" + ifcTypeString + "\"");
421 Uint32 ifcVersionIndex =
422 instanceObject.findProperty(_PROPERTY_INTERFACEVERSION);
423 if (ifcVersionIndex == PEG_NOT_FOUND)
425 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
426 "Missing InterfaceVersion which is required property in PG_ProviderModule class.");
428 String ifcVersionString;
429 instanceObject.getProperty(ifcVersionIndex).getValue().
430 get(ifcVersionString);
431 if ((ifcVersionString != "2.1.0") &&
432 (ifcVersionString != "2.2.0"))
434 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
435 "Unsupported InterfaceVersion value: \"" + ifcVersionString +
439 if (instanceObject.findProperty(_PROPERTY_LOCATION) == PEG_NOT_FOUND)
441 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
442 "Missing Location which is required property in PG_ProviderModule class.");
445 if (instanceObject.findProperty(_PROPERTY_OPERATIONALSTATUS) ==
448 Array<Uint16> _operationalStatus;
449 _operationalStatus.append(_MODULE_OK);
450 instance.addProperty (CIMProperty
451 (_PROPERTY_OPERATIONALSTATUS, _operationalStatus));
454 else if (className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES))
457 // ProviderModuleName, ProviderName, InstanceID, ClassName,
458 // Namespaces, and ProviderType properties must be set
461 if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULENAME) ==
464 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
465 "Missing ProviderModuleName which is required property in PG_ProviderCapabilities class.");
468 if (instanceObject.findProperty(_PROPERTY_PROVIDERNAME) ==
471 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
472 "Missing ProviderName which is required property in PG_ProviderCapabilities class.");
475 if (instanceObject.findProperty(_PROPERTY_CAPABILITYID) ==
478 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
479 "Missing CapabilityID which is required property in PG_ProviderCapabilities class.");
482 if (instanceObject.findProperty(_PROPERTY_CLASSNAME) == PEG_NOT_FOUND)
484 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
485 "Missing ClassName which is required property in PG_ProviderCapabilities class.");
488 if (instanceObject.findProperty(_PROPERTY_NAMESPACES) == PEG_NOT_FOUND)
490 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
491 "Missing Namespaces which is required property in PG_ProviderCapabilities class.");
494 if (instanceObject.findProperty(_PROPERTY_PROVIDERTYPE) == PEG_NOT_FOUND)
496 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
497 "Missing ProviderType which is required property in PG_ProviderCapabilities class.");
500 else // PEGASUS_CLASSNAME_PROVIDER
503 // Name and ProviderModuleName properties must be set
505 if (instanceObject.findProperty(_PROPERTY_PROVIDER_NAME) == PEG_NOT_FOUND)
507 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
508 "Missing Name which is required property in PG_Provider class.");
511 if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULENAME) ==
514 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
515 "Missing ProviderModuleName which is required property in PG_Provider class.");
519 // begin processing the request
520 handler.processing();
525 _providerRegistrationManager->createInstance(instanceReference, instance);
527 catch(CIMException& e)
532 handler.deliver(returnReference);
534 // complete processing request
538 // Unregister a provider
539 void ProviderRegistrationProvider::deleteInstance(
540 const OperationContext & context,
541 const CIMObjectPath & instanceReference,
542 ResponseHandler & handler)
544 // get userName and only privileged user can execute this operation
548 IdentityContainer container = context.get(IdentityContainer::NAME);
549 userName = container.getUserName();
553 userName = String::EMPTY;
556 if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
558 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,
559 "You must have superuser privilege to unregister providers.");
562 if(!instanceReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
564 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
565 instanceReference.getNameSpace().getString());
568 CIMName className = instanceReference.getClassName();
570 // ensure the class existing in the specified namespace
571 if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
572 !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
573 !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
575 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
576 className.getString());
579 // begin processing the request
580 handler.processing();
583 Boolean moduleFound = false;
584 Array<CIMKeyBinding> keys = instanceReference.getKeyBindings();
587 // disable provider before delete provider
588 // registration if the class is PG_Provider
590 if (className.equal (PEGASUS_CLASSNAME_PROVIDER))
592 // get module name from reference
594 for(Uint32 i=0; i<keys.size() ; i++)
596 if(keys[i].getName().equal (_PROPERTY_PROVIDERMODULENAME))
598 moduleName = keys[i].getValue();
603 // if _PROPERTY_PROVIDERMODULENAME key not found
606 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
607 "key ProviderModuleName was not found");
611 // disable the provider
616 // if the provider disable failed
618 if (_disableModule(instanceReference, moduleName, true) == -1)
620 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
621 "disable the provider failed.");
631 // disable provider module before remove provider registration
632 // if the class is PG_ProviderModule
635 if (className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
637 // get module name from reference
639 for(Uint32 i=0; i<keys.size() ; i++)
641 if(keys[i].getName().equal (_PROPERTY_PROVIDERMODULE_NAME))
643 moduleName = keys[i].getValue();
648 // if _PROPERTY_PROVIDERMODULE_NAME key not found
651 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
652 "key Name was not found");
656 // disable the provider module
661 // if the provider module disable failed
663 if (_disableModule(instanceReference, moduleName, false) == -1)
665 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
666 "disable the provider module failed.");
669 catch(CIMException& e)
677 _providerRegistrationManager->deleteInstance(instanceReference);
679 catch(CIMException& e)
684 // complete processing the request
688 // Block a provider, unblock a provider, and stop a provider
689 void ProviderRegistrationProvider::invokeMethod(
690 const OperationContext & context,
691 const CIMObjectPath & objectReference,
692 const CIMName & methodName,
693 const Array<CIMParamValue> & inParameters,
694 MethodResultResponseHandler & handler)
696 // get userName and only privileged user can execute this operation
700 IdentityContainer container = context.get(IdentityContainer::NAME);
701 userName = container.getUserName();
705 userName = String::EMPTY;
708 if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
710 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,
711 "You must have superuser privilege to disable or enable providers.");
714 if(!objectReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
716 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
717 objectReference.getNameSpace().getString());
721 Boolean moduleFound = false;
723 // get module name from reference
724 Array<CIMKeyBinding> keys = objectReference.getKeyBindings();
726 for(Uint32 i=0; i<keys.size() ; i++)
728 if(keys[i].getName().equal (_PROPERTY_PROVIDERMODULE_NAME))
730 moduleName = keys[i].getValue();
735 // if _PROPERTY_PROVIDERMODULE_NAME key not found
738 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
739 "key Name was not found");
742 handler.processing();
746 if(methodName.equal(_STOP_PROVIDER))
751 ret_value = _disableModule(objectReference, moduleName, false);
753 catch(CIMException& e)
758 CIMValue retValue(ret_value);
759 handler.deliver(retValue);
763 else if(methodName.equal(_START_PROVIDER))
768 Array<Uint16> _OperationalStatus =
769 _providerRegistrationManager->getProviderModuleStatus( moduleName);
771 for (Uint32 i = 0; i<_OperationalStatus.size(); i++)
773 // retValue equals 1 if module is already enabled
774 if (_OperationalStatus[i] == _MODULE_OK)
777 CIMValue retValue(ret_value);
778 handler.deliver(retValue);
783 // retValue equals 2 if module is stopping
784 // at this stage, module can not be started
785 if (_OperationalStatus[i] == _MODULE_STOPPING)
788 CIMValue retValue(ret_value);
789 handler.deliver(retValue);
795 // get module instance
796 CIMInstance mInstance =
797 _providerRegistrationManager->getInstance(objectReference);
800 // get provider manager service
802 MessageQueueService * _service = _getProviderManagerService();
804 if (_service != NULL)
806 // create CIMEnableModuleRequestMessage
807 CIMEnableModuleRequestMessage * enable_req =
808 new CIMEnableModuleRequestMessage(
809 XmlWriter::getNextMessageId (),
811 QueueIdStack(_service->getQueueId()));
813 Array<Uint16> _opStatus;
814 _opStatus = _sendEnableMessageToProviderManager(enable_req);
816 for (Uint32 i = 0; i<_opStatus.size(); i++)
818 if (_opStatus[i] == _MODULE_OK)
820 // module was enabled successfully
822 CIMValue retValue(ret_value);
823 handler.deliver(retValue);
832 CIMValue retValue(ret_value);
833 handler.deliver(retValue);
839 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_METHOD_NOT_AVAILABLE, String::EMPTY);
843 // get provider manager service
844 MessageQueueService * ProviderRegistrationProvider::_getProviderManagerService()
846 MessageQueue * queue = MessageQueue::lookup(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP);
847 MessageQueueService * _service = dynamic_cast<MessageQueueService *>(queue);
852 ProviderRegistrationProvider & ProviderRegistrationProvider::operator=(const ProviderRegistrationProvider & handle)
862 Array<Uint16> ProviderRegistrationProvider::_sendDisableMessageToProviderManager(
863 CIMDisableModuleRequestMessage * disable_req)
865 MessageQueueService * _service = _getProviderManagerService();
866 Uint32 _queueId = _service->getQueueId();
868 callback_data *cb_data = new callback_data(this);
870 // create request envelope
871 AsyncLegacyOperationStart * asyncRequest =
872 new AsyncLegacyOperationStart (
873 _service->get_next_xid(),
879 AsyncReply * asyncReply = _controller->ClientSendWait(*_client_handle,
882 CIMDisableModuleResponseMessage * response =
883 reinterpret_cast<CIMDisableModuleResponseMessage *>(
884 (static_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result());
885 if (response->cimException.getCode() != CIM_ERR_SUCCESS)
887 CIMException e = response->cimException;
894 Array<Uint16> operationalStatus = response->operationalStatus;
900 return(operationalStatus);
903 Array<Uint16> ProviderRegistrationProvider::_sendEnableMessageToProviderManager(
904 CIMEnableModuleRequestMessage * enable_req)
906 MessageQueueService * _service = _getProviderManagerService();
907 Uint32 _queueId = _service->getQueueId();
909 callback_data *cb_data = new callback_data(this);
911 // create request envelope
912 AsyncLegacyOperationStart * asyncRequest =
913 new AsyncLegacyOperationStart (
914 _service->get_next_xid(),
920 AsyncReply * asyncReply = _controller->ClientSendWait(*_client_handle,
923 CIMEnableModuleResponseMessage * response =
924 reinterpret_cast<CIMEnableModuleResponseMessage *>(
925 (static_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result());
926 if (response->cimException.getCode() != CIM_ERR_SUCCESS)
928 CIMException e = response->cimException;
935 Array<Uint16> operationalStatus = response->operationalStatus;
941 return(operationalStatus);
944 // send termination message to subscription service
945 void ProviderRegistrationProvider::_sendTerminationMessageToSubscription(
946 const CIMObjectPath & ref, const String & moduleName,
947 const Boolean disableProviderOnly)
949 CIMInstance instance;
951 Array<CIMInstance> instances;
953 if (!disableProviderOnly)
955 CIMObjectPath reference("", PEGASUS_NAMESPACENAME_INTEROP,
956 PEGASUS_CLASSNAME_PROVIDER, ref.getKeyBindings());
958 Array<CIMObjectPath> instanceNames =
959 _providerRegistrationManager->enumerateInstanceNames(reference);
961 // find all the instances which have same module name as moduleName
962 for (Uint32 i = 0, n=instanceNames.size(); i < n; i++)
965 // get provider module name from reference
968 Array<CIMKeyBinding> keys = instanceNames[i].getKeyBindings();
970 for(Uint32 j=0; j < keys.size(); j++)
972 if(keys[j].getName().equal (_PROPERTY_PROVIDERMODULENAME))
974 _moduleName = keys[j].getValue();
978 if (String::equalNoCase(moduleName, _moduleName))
980 reference.setKeyBindings(keys);
981 instance = _providerRegistrationManager->getInstance(reference);
982 instances.append(instance);
988 instance = _providerRegistrationManager->getInstance(ref);
989 instances.append(instance);
993 // get indication server queueId
995 MessageQueueService * _service = _getIndicationService();
997 if (_service != NULL)
999 Uint32 _queueId = _service->getQueueId();
1001 CIMNotifyProviderTerminationRequestMessage * termination_req =
1002 new CIMNotifyProviderTerminationRequestMessage(
1003 XmlWriter::getNextMessageId (),
1005 QueueIdStack(_service->getQueueId()));
1007 // create request envelope
1008 AsyncLegacyOperationStart * asyncRequest =
1009 new AsyncLegacyOperationStart (
1010 _service->get_next_xid(),
1016 if( false == _controller->ClientSendForget(
1021 delete asyncRequest;
1022 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_FOUND, String::EMPTY);
1027 // get indication service
1028 MessageQueueService * ProviderRegistrationProvider::_getIndicationService()
1030 MessageQueue * queue = MessageQueue::lookup(
1031 PEGASUS_QUEUENAME_INDICATIONSERVICE);
1033 MessageQueueService * _service =
1034 dynamic_cast<MessageQueueService *>(queue);
1038 // disable provider module, return 0 if module is disabled successfully,
1039 // return 1 if module is already disabled, otherwise, return -1
1040 Sint16 ProviderRegistrationProvider::_disableModule(
1041 const CIMObjectPath & objectReference,
1042 const String & moduleName,
1043 Boolean disableProviderOnly)
1046 // get module status
1048 Array<Uint16> _OperationalStatus =
1049 _providerRegistrationManager->getProviderModuleStatus( moduleName);
1051 for (Uint32 i = 0; i<_OperationalStatus.size(); i++)
1053 // retValue equals 1 if module is already disabled
1054 if (_OperationalStatus[i] == _MODULE_STOPPED ||
1055 _OperationalStatus[i] == _MODULE_STOPPING)
1061 CIMInstance instance;
1062 Array<CIMInstance> instances;
1063 CIMInstance mInstance;
1066 CIMObjectPath providerRef;
1068 // disable a provider module or delete a provider module
1069 if (!disableProviderOnly)
1071 providerRef = CIMObjectPath(objectReference.getHost(),
1072 objectReference.getNameSpace(),
1073 PEGASUS_CLASSNAME_PROVIDER,
1074 objectReference.getKeyBindings());
1076 // get module instance
1078 _providerRegistrationManager->getInstance(objectReference);
1081 else // disable a provider
1083 // get module instance
1084 Array <CIMKeyBinding> moduleKeyBindings;
1085 moduleKeyBindings.append (CIMKeyBinding
1086 (_PROPERTY_PROVIDERMODULE_NAME, moduleName,
1087 CIMKeyBinding::STRING));
1089 CIMObjectPath moduleRef(objectReference.getHost(),
1090 objectReference.getNameSpace(),
1091 PEGASUS_CLASSNAME_PROVIDERMODULE,
1095 _providerRegistrationManager->getInstance(moduleRef);
1098 if (!disableProviderOnly)
1100 // get all provider instances which have same module name as
1102 Array<CIMObjectPath> instanceNames =
1103 _providerRegistrationManager->enumerateInstanceNames(providerRef);
1105 for(Uint32 i = 0, n=instanceNames.size(); i < n; i++)
1108 // get provider module name from reference
1111 Array<CIMKeyBinding> keys = instanceNames[i].getKeyBindings();
1113 for(Uint32 j=0; j < keys.size(); j++)
1115 if(keys[j].getName().equal (_PROPERTY_PROVIDERMODULENAME))
1117 _moduleName = keys[j].getValue();
1121 if (String::equalNoCase(_moduleName, moduleName))
1123 providerRef.setKeyBindings(keys);
1124 instance = _providerRegistrationManager->getInstance
1126 instances.append(instance);
1133 instances.append(_providerRegistrationManager->getInstance
1138 // get provider manager service
1140 MessageQueueService * _service = _getProviderManagerService();
1142 if (_service != NULL)
1144 // create CIMDisableModuleRequestMessage
1145 CIMDisableModuleRequestMessage * disable_req =
1146 new CIMDisableModuleRequestMessage(
1147 XmlWriter::getNextMessageId (),
1150 disableProviderOnly,
1151 QueueIdStack(_service->getQueueId()));
1153 Array<Uint16> _opStatus =
1154 _sendDisableMessageToProviderManager(disable_req);
1156 if (!disableProviderOnly) // disable provider module
1158 for (Uint32 i = 0; i<_opStatus.size(); i++)
1160 // module was disabled successfully
1161 if (_opStatus[i] == _MODULE_STOPPED)
1163 // send termination message to subscription service
1164 _sendTerminationMessageToSubscription(objectReference,
1170 else // disable provider
1172 _sendTerminationMessageToSubscription(objectReference,
1182 PEGASUS_NAMESPACE_END