1 karl 1.73 //%2004////////////////////////////////////////////////////////////////////////
|
2 kumpf 1.1 //
|
3 karl 1.73 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.57 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.73 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 kumpf 1.1 //
10 // Permission is hereby granted, free of charge, to any person obtaining a copy
11 // of this software and associated documentation files (the "Software"), to
12 // deal in the Software without restriction, including without limitation the
13 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
14 // sell copies of the Software, and to permit persons to whom the Software is
15 // furnished to do so, subject to the following conditions:
|
16 karl 1.57 //
|
17 kumpf 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
18 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
19 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
20 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
21 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 //
26 //==============================================================================
27 //
28 // Author: Yi Zhou (yi_zhou@hp.com)
29 //
30 // Modified By: Chip Vincent (cvincent@us.ibm.com)
31 // Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
32 // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
|
33 kumpf 1.20 // Carol Ann Krug Graves, Hewlett-Packard Company
34 // (carolann_graves@hp.com)
|
35 kumpf 1.71 // Seema Gupta (gseema@in.ibm.com) for PEP135
|
36 kumpf 1.1 //
37 //%/////////////////////////////////////////////////////////////////////////////
38
|
39 kumpf 1.5 #include "ProviderRegistrationProvider.h"
40
|
41 kumpf 1.4 #include <Pegasus/Common/PegasusVersion.h>
|
42 kumpf 1.5 #include <Pegasus/Common/XmlWriter.h>
|
43 kumpf 1.6 #include <Pegasus/Common/Constants.h>
44 #include <Pegasus/Common/CIMMessage.h>
|
45 se.gupta 1.67 #include <Pegasus/Common/OperationContextInternal.h>
|
46 kumpf 1.15 #include <Pegasus/Common/System.h>
|
47 humberto 1.48 #include <Pegasus/Common/MessageLoader.h> //l10n
|
48 kumpf 1.68 #include <Pegasus/Common/Constants.h>
|
49 kumpf 1.1
50 PEGASUS_NAMESPACE_BEGIN
51
52 /**
53 The name of the CapabilityID property for provider capabilities class
54 */
|
55 kumpf 1.36 static const CIMName _PROPERTY_CAPABILITYID = CIMName ("CapabilityID");
|
56 kumpf 1.1
57 /**
58 stopping provider method
59 */
|
60 kumpf 1.36 static const CIMName _STOP_PROVIDER = CIMName ("Stop");
|
61 kumpf 1.1
62 /**
63 starting provider method
64 */
|
65 kumpf 1.36 static const CIMName _START_PROVIDER = CIMName ("Start");
|
66 kumpf 1.1
67 ProviderRegistrationProvider::ProviderRegistrationProvider(
68 ProviderRegistrationManager * providerRegistrationManager)
|
69 kumpf 1.6 :_id(peg_credential_types::PROVIDER)
|
70 kumpf 1.1 {
71 _providerRegistrationManager = providerRegistrationManager;
|
72 kumpf 1.6
73 _controller = &(ModuleController::get_client_handle(_id, &_client_handle));
74 if(_client_handle == NULL)
|
75 kumpf 1.32 throw UninitializedObjectException();
|
76 kumpf 1.1 }
77
78 ProviderRegistrationProvider::~ProviderRegistrationProvider(void)
79 {
|
80 kumpf 1.6 if (_providerRegistrationManager)
81 {
82 delete _providerRegistrationManager;
83 }
84
85 if (_client_handle)
86 {
87 delete _client_handle;
88 }
89
|
90 kumpf 1.1 }
91
92 void ProviderRegistrationProvider::initialize(CIMOMHandle & cimom)
93 {
94 // This method should not be called because this is a control provider
95 // and is not dynamically loaded through the provider manager
96 }
97
98 void ProviderRegistrationProvider::terminate(void)
99 {
100 }
101
102 // get registered provider
103 void ProviderRegistrationProvider::getInstance(
104 const OperationContext & context,
|
105 kumpf 1.13 const CIMObjectPath & instanceReference,
|
106 kumpf 1.34 const Boolean includeQualifiers,
107 const Boolean includeClassOrigin,
|
108 kumpf 1.2 const CIMPropertyList & propertyList,
|
109 kumpf 1.33 InstanceResponseHandler & handler)
|
110 kumpf 1.1 {
111
|
112 kumpf 1.36 if(!instanceReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
|
113 kumpf 1.10 {
|
114 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
|
115 kumpf 1.36 instanceReference.getNameSpace().getString());
|
116 kumpf 1.10 }
117
|
118 kumpf 1.1 // ensure the class existing in the specified namespace
|
119 kumpf 1.36 CIMName className = instanceReference.getClassName();
|
120 kumpf 1.1
|
121 kumpf 1.36 if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
122 !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
|
123 kumpf 1.46 !className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES) &&
|
124 kumpf 1.36 !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
|
125 kumpf 1.1 {
|
126 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
127 className.getString());
|
128 kumpf 1.1 }
129
130 // begin processing the request
131 handler.processing();
132
133 CIMInstance instance;
134
135 try
136 {
|
137 kumpf 1.60 instance = _providerRegistrationManager->getInstance(instanceReference,
138 includeQualifiers,
139 includeClassOrigin,
140 propertyList);
|
141 kumpf 1.1 }
142 catch(CIMException& e)
143 {
|
144 kumpf 1.26 throw (e);
|
145 kumpf 1.1 }
146
147 handler.deliver(instance);
148
149 // complete processing the request
150 handler.complete();
151 }
152
153 // get all registered providers
154 void ProviderRegistrationProvider::enumerateInstances(
155 const OperationContext & context,
|
156 kumpf 1.13 const CIMObjectPath & classReference,
|
157 kumpf 1.34 const Boolean includeQualifiers,
158 const Boolean includeClassOrigin,
|
159 kumpf 1.2 const CIMPropertyList & propertyList,
|
160 kumpf 1.33 InstanceResponseHandler & handler)
|
161 kumpf 1.1 {
|
162 kumpf 1.36 if(!classReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
|
163 kumpf 1.10 {
|
164 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
165 classReference.getNameSpace().getString());
|
166 kumpf 1.10 }
167
|
168 kumpf 1.1 // ensure the class existing in the specified namespace
|
169 kumpf 1.36 CIMName className = classReference.getClassName();
|
170 kumpf 1.1
|
171 kumpf 1.36 if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
172 !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
|
173 kumpf 1.46 !className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES) &&
|
174 kumpf 1.36 !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
|
175 kumpf 1.1 {
|
176 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
177 className.getString());
|
178 kumpf 1.1 }
179
180 // begin processing the request
181 handler.processing();
182
|
183 kumpf 1.20 Array<CIMInstance> enumInstances;
|
184 kumpf 1.1
185 try
186 {
|
187 kumpf 1.60 enumInstances =
188 _providerRegistrationManager->enumerateInstances(classReference,
189 includeQualifiers,
190 includeClassOrigin,
191 propertyList);
|
192 kumpf 1.1 }
193 catch(CIMException& e)
194 {
|
195 kumpf 1.26 throw (e);
|
196 kumpf 1.1 }
197
|
198 kumpf 1.21 handler.deliver(enumInstances);
|
199 kumpf 1.1
200 // complete processing the request
201 handler.complete();
202 }
203
204 // get all registered provider names
205 void ProviderRegistrationProvider::enumerateInstanceNames(
206 const OperationContext & context,
|
207 kumpf 1.13 const CIMObjectPath & classReference,
|
208 kumpf 1.33 ObjectPathResponseHandler & handler)
|
209 kumpf 1.1 {
|
210 kumpf 1.36 if(!classReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
|
211 kumpf 1.10 {
|
212 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
213 classReference.getNameSpace().getString());
|
214 kumpf 1.10 }
215
|
216 kumpf 1.1 // ensure the class existing in the specified namespace
|
217 kumpf 1.36 CIMName className = classReference.getClassName();
|
218 kumpf 1.1
|
219 kumpf 1.36 if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
220 !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
|
221 kumpf 1.46 !className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES) &&
|
222 kumpf 1.36 !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
|
223 kumpf 1.1 {
|
224 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
225 className.getString());
|
226 kumpf 1.1 }
227
228 // begin processing the request
229 handler.processing();
230
|
231 kumpf 1.13 Array<CIMObjectPath> enumInstanceNames;
|
232 kumpf 1.1
233 // get all instance names from repository
234 try
235 {
236 enumInstanceNames =
237 _providerRegistrationManager->enumerateInstanceNames(classReference);
238 }
239 catch(CIMException& e)
240 {
|
241 kumpf 1.26 throw (e);
|
242 kumpf 1.1 }
243
244 handler.deliver(enumInstanceNames);
245
246 // complete processing the request
247 handler.complete();
248 }
249
250 // change properties for the registered provider
|
251 chip 1.24 // only support to change property of Namespaces, property of
|
252 kumpf 1.1 // SupportedProperties, and property of SupportedMethods
253 void ProviderRegistrationProvider::modifyInstance(
|
254 kumpf 1.15 const OperationContext & context,
|
255 kumpf 1.13 const CIMObjectPath & instanceReference,
|
256 kumpf 1.1 const CIMInstance & instanceObject,
|
257 kumpf 1.34 const Boolean includeQualifiers,
|
258 kumpf 1.2 const CIMPropertyList & propertyList,
|
259 kumpf 1.33 ResponseHandler & handler)
|
260 kumpf 1.1 {
|
261 kumpf 1.15 // get userName and only privileged user can execute this operation
|
262 kumpf 1.19 String userName;
263 try
264 {
|
265 kumpf 1.37 IdentityContainer container = context.get(IdentityContainer::NAME);
|
266 kumpf 1.19 userName = container.getUserName();
267 }
268 catch (...)
269 {
270 userName = String::EMPTY;
271 }
|
272 kumpf 1.15
|
273 chip 1.24 if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
|
274 kumpf 1.15 {
|
275 humberto 1.48 //l10n
276 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,
277 //"You must have superuser privilege to modify the registration.");
278 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED,MessageLoaderParms(
279 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.SUPERUSER_PRIVILEGE_REQUIRED_MODIFY_REGISTRATION",
280 "You must have superuser privilege to modify the registration."));
|
281 kumpf 1.15 }
282
|
283 kumpf 1.36 if(!instanceReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
|
284 kumpf 1.10 {
|
285 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
286 instanceReference.getNameSpace().getString());
|
287 kumpf 1.10 }
288
|
289 kumpf 1.1 //
290 // only support to modify the instance of PG_ProviderCapabilities
291 //
|
292 kumpf 1.36 if (!instanceReference.getClassName().equal
293 (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES))
|
294 kumpf 1.1 {
|
295 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
296 instanceReference.getClassName().getString());
|
297 kumpf 1.1 }
298
299 //
|
300 kumpf 1.2 // only can modify the property of Namespaces, property of
|
301 kumpf 1.1 // SupportedProperties, and property of SupportedMethods
302 //
|
303 kumpf 1.2 if (propertyList.isNull())
|
304 kumpf 1.1 {
|
305 humberto 1.48 //l10n
306 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
307 //"Only can modify Namespaces, SupportedProperties, and SupportedMethods.");
308 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED, MessageLoaderParms(
309 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.CAN_ONLY_MODIFY_ERR",
|
310 humberto 1.50 "Only can modify Namespaces, SupportedProperties, and SupportedMethods."));
|
311 kumpf 1.2 }
312
|
313 kumpf 1.28 Array<CIMName> propertyArray = propertyList.getPropertyNameArray();
|
314 kumpf 1.2 for (Uint32 i=0; i<propertyArray.size(); i++)
315 {
|
316 kumpf 1.36 if (!propertyArray[i].equal (_PROPERTY_NAMESPACES) &&
317 !propertyArray[i].equal (_PROPERTY_SUPPORTEDPROPERTIES) &&
318 !propertyArray[i].equal (_PROPERTY_SUPPORTEDMETHODS))
|
319 kumpf 1.1 {
|
320 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
321 propertyArray[i].getString());
|
322 kumpf 1.2 }
|
323 kumpf 1.1 }
324
325 // begin processing the request
326 handler.processing();
327
328 try
329 {
|
330 kumpf 1.60 _providerRegistrationManager->modifyInstance(instanceReference,
331 instanceObject,
332 includeQualifiers,
333 propertyArray);
|
334 kumpf 1.1 }
335 catch(CIMException& e)
336 {
|
337 kumpf 1.26 throw (e);
|
338 kumpf 1.1 }
339
340 // complete processing the request
341 handler.complete();
342 }
343
344 // register a provider
345 void ProviderRegistrationProvider::createInstance(
346 const OperationContext & context,
|
347 kumpf 1.13 const CIMObjectPath & instanceReference,
|
348 kumpf 1.1 const CIMInstance & instanceObject,
|
349 kumpf 1.33 ObjectPathResponseHandler & handler)
|
350 kumpf 1.1 {
|
351 kumpf 1.15 // get userName and only privileged user can execute this operation
|
352 kumpf 1.19 String userName;
353 try
354 {
|
355 kumpf 1.37 IdentityContainer container = context.get(IdentityContainer::NAME);
|
356 kumpf 1.19 userName = container.getUserName();
357 }
358 catch (...)
359 {
360 userName = String::EMPTY;
361 }
|
362 kumpf 1.15
|
363 chip 1.24 if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
|
364 kumpf 1.15 {
|
365 humberto 1.48 //l10n
366 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,
367 //"You must have superuser privilege to register providers.");
368 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED, MessageLoaderParms(
369 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.SUPERUSER_PRIVILEGE_REQUIRED_REGISTER_PROVIDERS",
370 "You must have superuser privilege to register providers."));
|
371 kumpf 1.15 }
372
|
373 kumpf 1.36 CIMName className = instanceReference.getClassName();
374 CIMNamespaceName nameSpace = instanceReference.getNameSpace();
|
375 kumpf 1.1
|
376 kumpf 1.13 CIMObjectPath returnReference;
|
377 kumpf 1.1
378 CIMInstance instance = instanceObject;
379
|
380 kumpf 1.36 if(!nameSpace.equal (PEGASUS_NAMESPACENAME_INTEROP))
|
381 kumpf 1.10 {
|
382 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
383 nameSpace.getString());
|
384 kumpf 1.10 }
385
|
386 kumpf 1.1 // ensure the class existing in the specified namespace
|
387 kumpf 1.36 if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
388 !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
|
389 kumpf 1.46 !className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES) &&
|
390 kumpf 1.36 !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
|
391 kumpf 1.1 {
|
392 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
393 className.getString());
|
394 kumpf 1.1 }
395
396 //
397 // Check all required properties are set
398 //
|
399 kumpf 1.36 if (className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
|
400 kumpf 1.1 {
401 //
402 // Name, Version, InterfaceType, InterfaceVersion, and Location
403 // properties must be set
404 // OperationalStatus property needs to be set. If not, set to default
405 //
|
406 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULE_NAME) ==
407 PEG_NOT_FOUND)
|
408 kumpf 1.1 {
|
409 humberto 1.53 //l10n 485
|
410 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
411 //"Missing Name which is required property in PG_ProviderModule class.");
412 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
413 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_NAME_IN_PG_PROVIDERMODULE",
414 "Missing Name which is required property in PG_ProviderModule class."));
|
415 kumpf 1.12 }
416
|
417 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_VENDOR) == PEG_NOT_FOUND)
|
418 kumpf 1.12 {
|
419 humberto 1.53 //l10n 485
|
420 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
421 //"Missing Vendor which is required property in PG_ProviderModule class.");
422 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
423 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_VENDOR_IN_PG_PROVIDERMODULE",
424 "Missing Vendor which is required property in PG_ProviderModule class."));
|
425 kumpf 1.1 }
426
|
427 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_VERSION) == PEG_NOT_FOUND)
|
428 kumpf 1.1 {
|
429 humberto 1.53 //l10n 485
|
430 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
431 //"Missing Version which is required property in PG_ProviderModule class.");
432 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
433 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_VERSION_IN_PG_PROVIDERMODULE",
434 "Missing Version which is required property in PG_ProviderModule class."));
|
435 kumpf 1.1 }
436
|
437 kumpf 1.41 Uint32 ifcTypeIndex =
438 instanceObject.findProperty(_PROPERTY_INTERFACETYPE);
439 if (ifcTypeIndex == PEG_NOT_FOUND)
|
440 kumpf 1.1 {
|
441 humberto 1.53 //l10n 485
|
442 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
443 //"Missing InterfaceType which is required property in PG_ProviderModule class.");
444 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
445 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_INTERFACETYPE_IN_PG_PROVIDERMODULE",
|
446 humberto 1.54 "Missing InterfaceType which is required property in PG_ProviderModule class."));
|
447 kumpf 1.1 }
|
448 kumpf 1.41 String ifcTypeString;
449 instanceObject.getProperty(ifcTypeIndex).getValue().
450 get(ifcTypeString);
|
451 mday 1.45
|
452 schuur 1.63 if (ifcTypeString != "C++Default"
|
453 se.gupta 1.72 #ifdef PEGASUS_ENABLE_CMPI_PROVIDER_MANAGER
|
454 schuur 1.63 && ifcTypeString != "CMPI"
455 #endif
456 )
|
457 kumpf 1.41 {
|
458 humberto 1.53 //l10n 485
|
459 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
460 //"Unsupported InterfaceType value: \"" + ifcTypeString + "\"");
461 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,MessageLoaderParms(
|
462 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.UNSUPPORTED_INTERFACETYPE_VALUE",
463 "Unsupported InterfaceType value: \"$0\"",ifcTypeString));
|
464 kumpf 1.41 }
|
465 kumpf 1.1
|
466 kumpf 1.41 Uint32 ifcVersionIndex =
467 instanceObject.findProperty(_PROPERTY_INTERFACEVERSION);
468 if (ifcVersionIndex == PEG_NOT_FOUND)
|
469 kumpf 1.1 {
|
470 humberto 1.53 //l10n 485
|
471 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
472 //"Missing InterfaceVersion which is required property in PG_ProviderModule class.");
473 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
474 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_INTERFACEVERSION_IN_PG_PROVIDERMODULE",
475 "Missing InterfaceVersion which is required property in PG_ProviderModule class."));
|
476 kumpf 1.41 }
477 String ifcVersionString;
478 instanceObject.getProperty(ifcVersionIndex).getValue().
479 get(ifcVersionString);
|
480 schuur 1.63 if (
|
481 se.gupta 1.72 #ifdef PEGASUS_ENABLE_CMPI_PROVIDER_MANAGER
|
482 schuur 1.63 (ifcTypeString == "CMPI" &&
483 ifcVersionString != "2.0.0") ||
484 #endif
485 (ifcTypeString == "C++Default" &&
486 ifcVersionString != "2.1.0" &&
487 ifcVersionString != "2.2.0" &&
488 ifcVersionString != "2.3.0"))
|
489 kumpf 1.41 {
|
490 humberto 1.53 //l10n 485
|
491 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
492 //"Unsupported InterfaceVersion value: \"" + ifcVersionString +
493 // "\"");
494 String unsupported = "InterfaceVersion";
495 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,MessageLoaderParms(
|
496 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.UNSUPPORTED_INTERFACEVERSION_VALUE",
497 "Unsupported InterfaceVersion value: \"$0\"",ifcVersionString));
|
498 kumpf 1.1 }
499
|
500 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_LOCATION) == PEG_NOT_FOUND)
|
501 kumpf 1.1 {
|
502 humberto 1.53 //l10n 485
|
503 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
504 //"Missing Location which is required property in PG_ProviderModule class.");
505 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
506 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_LOCATION_IN_PG_PROVIDERMODULE",
507 "Missing Location which is required property in PG_ProviderModule class."));
|
508 kumpf 1.1 }
509
|
510 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_OPERATIONALSTATUS) ==
511 PEG_NOT_FOUND)
|
512 kumpf 1.1 {
513 Array<Uint16> _operationalStatus;
|
514 kumpf 1.68 _operationalStatus.append(CIM_MSE_OPSTATUS_VALUE_OK);
|
515 kumpf 1.1 instance.addProperty (CIMProperty
516 (_PROPERTY_OPERATIONALSTATUS, _operationalStatus));
517 }
518 }
|
519 kumpf 1.36 else if (className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES))
|
520 kumpf 1.1 {
521 //
522 // ProviderModuleName, ProviderName, InstanceID, ClassName,
523 // Namespaces, and ProviderType properties must be set
524 //
525
|
526 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULENAME) ==
527 PEG_NOT_FOUND)
|
528 kumpf 1.1 {
|
529 humberto 1.53 //l10n 485
|
530 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
531 //"Missing ProviderModuleName which is required property in PG_ProviderCapabilities class.");
532 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
533 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDERMODULENAME_IN_PG_PROVIDERCAPABILITIES",
534 "Missing ProviderModuleName which is required property in PG_ProviderCapabilities class."));
|
535 kumpf 1.1 }
536
|
537 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_PROVIDERNAME) ==
538 PEG_NOT_FOUND)
|
539 kumpf 1.1 {
|
540 humberto 1.53 //l10n 485
|
541 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
542 //"Missing ProviderName which is required property in PG_ProviderCapabilities class.");
543 String missing = "ProviderName";
544 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
545 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_REQUIRED_PROPERTY",
|
546 humberto 1.53 "Missing ProviderName which is required property in PG_ProviderCapabilities class."));
|
547 kumpf 1.1 }
548
|
549 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_CAPABILITYID) ==
550 PEG_NOT_FOUND)
|
551 kumpf 1.1 {
|
552 humberto 1.53 //l10n 485
|
553 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
554 //"Missing CapabilityID which is required property in PG_ProviderCapabilities class.");
555 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
556 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSINGCAPABILITYID_IN_PG_PROVIDERCAPABILITIES",
557 "Missing CapabilityID which is required property in PG_ProviderCapabilities class."));
|
558 kumpf 1.1 }
559
|
560 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_CLASSNAME) == PEG_NOT_FOUND)
|
561 kumpf 1.1 {
|
562 humberto 1.53 //l10n 485
|
563 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
564 //"Missing ClassName which is required property in PG_ProviderCapabilities class.");
565 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
566 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_CLASSNAME_IN_PG_PROVIDERCAPABILITIES",
567 "Missing ClassName which is required property in PG_ProviderCapabilities class."));
|
568 kumpf 1.1 }
569
|
570 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_NAMESPACES) == PEG_NOT_FOUND)
|
571 kumpf 1.1 {
|
572 humberto 1.53 //l10n 485
|
573 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
574 //"Missing Namespaces which is required property in PG_ProviderCapabilities class.");
575 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
576 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_NAMESPACES_IN_PG_PROVIDERCAPABILITIES",
577 "Missing Namespaces which is required property in PG_ProviderCapabilities class."));
|
578 kumpf 1.1 }
579
|
580 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_PROVIDERTYPE) == PEG_NOT_FOUND)
|
581 kumpf 1.1 {
|
582 humberto 1.53 //l10n 485
|
583 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
584 //"Missing ProviderType which is required property in PG_ProviderCapabilities class.");
585 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
586 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDERTYPE_IN_PG_PROVIDERCAPABILITIES",
587 "Missing ProviderType which is required property in PG_ProviderCapabilities class."));
|
588 kumpf 1.1 }
589 }
|
590 kumpf 1.46 else if (className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES))
591 {
592 //
593 // ProviderModuleName, ProviderName, CapabilityID, ProviderType,
594 // and Destinations properties must be set
595 //
596
597 if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULENAME) ==
598 PEG_NOT_FOUND)
599 {
|
600 humberto 1.49 //L10N_ TODO DONE
601 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
602 //"Missing ProviderModuleName which is required property in PG_ConsumerCapabilities class.");
603 MessageLoaderParms parms(
604 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDER_MODULE_NAME_WHICH_IS_REQUIRED",
|
605 kumpf 1.46 "Missing ProviderModuleName which is required property in PG_ConsumerCapabilities class.");
|
606 humberto 1.49
607 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
|
608 kumpf 1.46 }
609
610 if (instanceObject.findProperty(_PROPERTY_PROVIDERNAME) ==
611 PEG_NOT_FOUND)
612 {
|
613 humberto 1.49 //L10N_ TODO DONE
614 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
615 //"Missing ProviderName which is required property in PG_ConsumerCapabilities class.");
616
617 MessageLoaderParms parms(
618 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDER_NAME_WHICH_IS_REQUIRED",
|
619 kumpf 1.46 "Missing ProviderName which is required property in PG_ConsumerCapabilities class.");
|
620 humberto 1.49
621 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
|
622 kumpf 1.46 }
623
624 if (instanceObject.findProperty(_PROPERTY_CAPABILITYID) ==
625 PEG_NOT_FOUND)
626 {
|
627 humberto 1.49 //L10N_ TODO DONE
628 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
629 //"Missing CapabilityID which is required property in PG_ConsumerCapabilities class.");
630
631 MessageLoaderParms parms(
632 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_CAPABILITY_ID_WHICH_IS_REQUIRED",
|
633 kumpf 1.46 "Missing CapabilityID which is required property in PG_ConsumerCapabilities class.");
|
634 humberto 1.49
635 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
|
636 kumpf 1.46 }
637
638 if (instanceObject.findProperty(_PROPERTY_PROVIDERTYPE) == PEG_NOT_FOUND)
639 {
|
640 humberto 1.49 //L10N_ TODO DONE
641 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
642 //"Missing ProviderType which is required property in PG_ConsumerCapabilities class.");
643
644 MessageLoaderParms parms(
645 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDER_TYPE_WHICH_IS_REQUIRED",
|
646 kumpf 1.46 "Missing ProviderType which is required property in PG_ConsumerCapabilities class.");
|
647 humberto 1.49
648 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
|
649 kumpf 1.46 }
650
651 if (instanceObject.findProperty(_PROPERTY_INDICATIONDESTINATIONS) ==
652 PEG_NOT_FOUND)
653 {
|
654 humberto 1.49 //L10N_ TODO DONE
655 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
656 //"Missing Destinations which is required property in PG_ConsumerCapabilities class.");
657
658 MessageLoaderParms parms(
659 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_DESTINATIONS_TYPE_WHICH_IS_REQUIRED",
|
660 kumpf 1.46 "Missing Destinations which is required property in PG_ConsumerCapabilities class.");
|
661 humberto 1.49
662 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
|
663 kumpf 1.46 }
664 }
|
665 kumpf 1.10 else // PEGASUS_CLASSNAME_PROVIDER
|
666 kumpf 1.1 {
667 //
668 // Name and ProviderModuleName properties must be set
669 //
|
670 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_PROVIDER_NAME) == PEG_NOT_FOUND)
|
671 kumpf 1.1 {
|
672 humberto 1.53 //l10n 485
|
673 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
674 //"Missing Name which is required property in PG_Provider class.");
675 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
676 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_REQUIRED_PROPERTY",
|
677 humberto 1.53 "Missing Name which is required property in PG_Provider class."));
|
678 kumpf 1.1 }
679
|
680 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULENAME) ==
681 PEG_NOT_FOUND)
|
682 kumpf 1.1 {
|
683 humberto 1.53 //l10n 485
|
684 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
685 //"Missing ProviderModuleName which is required property in PG_Provider class.");
686 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
687 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDERMODULENAME_IN_PG_PROVIDER",
688 "Missing ProviderModuleName which is required property in PG_Provider class."));
|
689 kumpf 1.1 }
690 }
691
692 // begin processing the request
693 handler.processing();
694
695 try
696 {
697 returnReference =
698 _providerRegistrationManager->createInstance(instanceReference, instance);
699 }
700 catch(CIMException& e)
701 {
|
702 kumpf 1.26 throw (e);
|
703 kumpf 1.1 }
704
705 handler.deliver(returnReference);
706
707 // complete processing request
708 handler.complete();
709 }
710
711 // Unregister a provider
712 void ProviderRegistrationProvider::deleteInstance(
713 const OperationContext & context,
|
714 kumpf 1.13 const CIMObjectPath & instanceReference,
|
715 kumpf 1.33 ResponseHandler & handler)
|
716 kumpf 1.1 {
|
717 kumpf 1.15 // get userName and only privileged user can execute this operation
|
718 kumpf 1.19 String userName;
719 try
720 {
|
721 kumpf 1.37 IdentityContainer container = context.get(IdentityContainer::NAME);
|
722 kumpf 1.19 userName = container.getUserName();
723 }
724 catch (...)
725 {
726 userName = String::EMPTY;
727 }
|
728 kumpf 1.15
|
729 chip 1.24 if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
|
730 kumpf 1.15 {
|
731 humberto 1.48 //l10n
732 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,
733 //"You must have superuser privilege to unregister providers.");
734 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED,MessageLoaderParms(
735 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.SUPERUSER_PRIVILEGE_REQUIRED_UNREGISTER_PROVIDERS",
736 "You must have superuser privilege to unregister providers."));
|
737 kumpf 1.15 }
738
|
739 kumpf 1.36 if(!instanceReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
|
740 kumpf 1.10 {
|
741 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
742 instanceReference.getNameSpace().getString());
|
743 kumpf 1.10 }
744
|
745 chuck 1.47
746 // l10n
747 // Get the client's list of preferred languages for the response
748 AcceptLanguages al = AcceptLanguages::EMPTY;
749 try
750 {
751 AcceptLanguageListContainer al_container =
752 (AcceptLanguageListContainer)context.get(AcceptLanguageListContainer::NAME);
753 al = al_container.getLanguages();
754 }
755 catch (...)
756 {
757 ; // Leave AcceptLanguages empty
758 }
759
|
760 kumpf 1.36 CIMName className = instanceReference.getClassName();
|
761 kumpf 1.1
762 // ensure the class existing in the specified namespace
|
763 kumpf 1.36 if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
764 !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
|
765 kumpf 1.46 !className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES) &&
|
766 kumpf 1.36 !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
|
767 kumpf 1.1 {
|
768 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
769 className.getString());
|
770 kumpf 1.1 }
771
772 // begin processing the request
773 handler.processing();
774
|
775 kumpf 1.43 String moduleName;
776 Boolean moduleFound = false;
777 Array<CIMKeyBinding> keys = instanceReference.getKeyBindings();
778
779 //
780 // disable provider before delete provider
781 // registration if the class is PG_Provider
782 //
783 if (className.equal (PEGASUS_CLASSNAME_PROVIDER))
784 {
785 // get module name from reference
786
787 for(Uint32 i=0; i<keys.size() ; i++)
788 {
789 if(keys[i].getName().equal (_PROPERTY_PROVIDERMODULENAME))
790 {
791 moduleName = keys[i].getValue();
792 moduleFound = true;
793 }
794 }
795
796 kumpf 1.43 // if _PROPERTY_PROVIDERMODULENAME key not found
797 if( !moduleFound)
798 {
|
799 humberto 1.53 //l10n 485
|
800 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
801 //"key ProviderModuleName was not found");
802 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,MessageLoaderParms(
|
803 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.PROVIDERMODULENAME_KEY_NOT_FOUND",
804 "key ProviderModuleName was not found"));
|
805 kumpf 1.43 }
806
807 //
808 // disable the provider
809 //
810 try
811 {
|
812 kumpf 1.51 Sint16 ret_value = _disableModule(instanceReference, moduleName, true, al);
813
|
814 kumpf 1.43 //
815 // if the provider disable failed
816 //
|
817 chuck 1.47 // l10n
|
818 kumpf 1.51 if (ret_value == -1)
|
819 kumpf 1.43 {
|
820 humberto 1.48 //l10n
821 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
822 //"disable the provider failed.");
823 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
824 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.DISABLE_PROVIDER_FAILED",
825 "disable the provider failed."));
|
826 kumpf 1.43 }
|
827 kumpf 1.51 //
828 // The provider disable failed since there are pending requests
829 //
830 if (ret_value == -2)
831 {
832 //L10N TODO
|
833 humberto 1.52 // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
834 //"disable the provider failed: Provider is busy.");
835 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
836 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.DISABLE_PROVIDER_FAILED_PROVIDER_BUSY",
837 "disable the provider failed: Provider is busy."));
|
838 kumpf 1.51 }
|
839 kumpf 1.43 }
840 catch(CIMException&)
841 {
842 throw;
843 }
844 }
845
846 //
847 // disable provider module before remove provider registration
848 // if the class is PG_ProviderModule
849 //
850
851 if (className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
852 {
853 // get module name from reference
854
855 for(Uint32 i=0; i<keys.size() ; i++)
856 {
857 if(keys[i].getName().equal (_PROPERTY_PROVIDERMODULE_NAME))
858 {
859 moduleName = keys[i].getValue();
860 kumpf 1.43 moduleFound = true;
861 }
862 }
863
864 // if _PROPERTY_PROVIDERMODULE_NAME key not found
865 if( !moduleFound)
866 {
|
867 humberto 1.53 //l10n 485
|
868 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
869 //"key Name was not found");
870 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,MessageLoaderParms(
|
871 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.NAME_KEY_NOT_FOUND",
872 "key Name was not found"));
|
873 kumpf 1.43 }
874
875 //
876 // disable the provider module
877 //
878 try
879 {
|
880 kumpf 1.51 Sint16 ret_value = _disableModule(instanceReference, moduleName, false, al);
881
|
882 kumpf 1.43 //
883 // if the provider module disable failed
884 //
|
885 chuck 1.47 // l10n
|
886 kumpf 1.51 if (ret_value == -1)
|
887 kumpf 1.43 {
|
888 humberto 1.48 //l10n
889 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
890 //"disable the provider module failed.");
891 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
892 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.DISABLE_PROVIDER_MODULE_FAILED",
893 "disable the provider module failed."));
|
894 kumpf 1.43 }
|
895 kumpf 1.51
896 //
897 // The provider module disable failed since there are pending requests
898 //
899 if (ret_value == -2)
900 {
901 //L10N TODO
|
902 humberto 1.52 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
903 // "disable the provider module failed: Provider is busy.");
904 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
905 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.DISABLE_PROVIDER_MODULE_FAILED_PROVIDER_BUSY",
906 "disable the provider module failed: Provider is busy."));
|
907 kumpf 1.51 }
|
908 kumpf 1.43 }
909 catch(CIMException& e)
910 {
911 throw (e);
912 }
913 }
914
|
915 kumpf 1.1 try
916 {
917 _providerRegistrationManager->deleteInstance(instanceReference);
918 }
919 catch(CIMException& e)
920 {
|
921 kumpf 1.26 throw (e);
|
922 kumpf 1.1 }
923
924 // complete processing the request
925 handler.complete();
926 }
927
928 // Block a provider, unblock a provider, and stop a provider
929 void ProviderRegistrationProvider::invokeMethod(
930 const OperationContext & context,
|
931 kumpf 1.13 const CIMObjectPath & objectReference,
|
932 kumpf 1.28 const CIMName & methodName,
|
933 kumpf 1.1 const Array<CIMParamValue> & inParameters,
|
934 kumpf 1.33 MethodResultResponseHandler & handler)
|
935 kumpf 1.1 {
|
936 kumpf 1.15 // get userName and only privileged user can execute this operation
|
937 kumpf 1.19 String userName;
938 try
939 {
|
940 kumpf 1.37 IdentityContainer container = context.get(IdentityContainer::NAME);
|
941 kumpf 1.19 userName = container.getUserName();
942 }
943 catch (...)
944 {
945 userName = String::EMPTY;
946 }
|
947 kumpf 1.15
|
948 chip 1.24 if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
|
949 mday 1.17 {
|
950 humberto 1.48 //l10n
951 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,
952 //"You must have superuser privilege to disable or enable providers.");
953 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED,MessageLoaderParms(
954 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.SUPERUSER_PRIVILEGE_REQUIRED_DISABLE_ENABLE_PROVIDERS",
955 "You must have superuser privilege to disable or enable providers."));
|
956 mday 1.17 }
|
957 kumpf 1.15
|
958 kumpf 1.36 if(!objectReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
|
959 kumpf 1.10 {
|
960 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
961 objectReference.getNameSpace().getString());
|
962 kumpf 1.10 }
963
|
964 chuck 1.47
965 // l10n
966 // Get the client's list of preferred languages for the response
967 AcceptLanguages al = AcceptLanguages::EMPTY;
968 try
969 {
970 AcceptLanguageListContainer al_container =
971 (AcceptLanguageListContainer)context.get(AcceptLanguageListContainer::NAME);
972 al = al_container.getLanguages();
973 }
974 catch (...)
975 {
976 ; // Leave AcceptLanguages empty
977 }
978
|
979 kumpf 1.5 String moduleName;
980 Boolean moduleFound = false;
|
981 kumpf 1.3
|
982 kumpf 1.5 // get module name from reference
|
983 kumpf 1.35 Array<CIMKeyBinding> keys = objectReference.getKeyBindings();
|
984 kumpf 1.1
|
985 kumpf 1.5 for(Uint32 i=0; i<keys.size() ; i++)
|
986 kumpf 1.1 {
|
987 kumpf 1.36 if(keys[i].getName().equal (_PROPERTY_PROVIDERMODULE_NAME))
|
988 kumpf 1.1 {
|
989 kumpf 1.5 moduleName = keys[i].getValue();
990 moduleFound = true;
|
991 kumpf 1.1 }
992 }
993
|
994 kumpf 1.5 // if _PROPERTY_PROVIDERMODULE_NAME key not found
995 if( !moduleFound)
|
996 kumpf 1.1 {
|
997 humberto 1.53 //l10n 485
|
998 humberto 1.48 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,MessageLoaderParms(
|
999 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.NAME_KEY_NOT_FOUND",
1000 "key Name was not found"));
|
1001 kumpf 1.1 }
1002
|
1003 kumpf 1.5 handler.processing();
1004
1005 Sint16 ret_value;
|
1006 kumpf 1.1
|
1007 kumpf 1.56 try
|
1008 kumpf 1.1 {
|
1009 kumpf 1.56 if(methodName.equal(_STOP_PROVIDER))
1010 {
1011 // disable module
|
1012 chuck 1.47 ret_value = _disableModule(objectReference, moduleName, false, al);
|
1013 kumpf 1.8 }
|
1014 kumpf 1.56 else if(methodName.equal(_START_PROVIDER))
|
1015 kumpf 1.43 {
|
1016 kumpf 1.56 // enable module
1017 ret_value = _enableModule(objectReference, moduleName, al);
|
1018 kumpf 1.1 }
|
1019 kumpf 1.56 else
1020 {
1021 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_METHOD_NOT_AVAILABLE, String::EMPTY);
1022 }
|
1023 kumpf 1.1 }
|
1024 kumpf 1.56 catch(CIMException& e)
|
1025 kumpf 1.1 {
|
1026 kumpf 1.56 throw (e);
|
1027 kumpf 1.1 }
|
1028 kumpf 1.56
1029 CIMValue retValue(ret_value);
1030 handler.deliver(retValue);
1031 handler.complete();
1032 return;
|
1033 kumpf 1.5 }
1034
1035 // get provider manager service
1036 MessageQueueService * ProviderRegistrationProvider::_getProviderManagerService()
1037 {
1038 MessageQueue * queue = MessageQueue::lookup(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP);
1039 MessageQueueService * _service = dynamic_cast<MessageQueueService *>(queue);
1040
|
1041 chip 1.24 return(_service);
|
1042 kumpf 1.5 }
1043
1044 ProviderRegistrationProvider & ProviderRegistrationProvider::operator=(const ProviderRegistrationProvider & handle)
1045 {
1046 if(this == &handle)
1047 {
1048 return(*this);
1049 }
1050
1051 return(*this);
1052 }
|
1053 kumpf 1.1
|
1054 kumpf 1.5 Array<Uint16> ProviderRegistrationProvider::_sendDisableMessageToProviderManager(
1055 CIMDisableModuleRequestMessage * disable_req)
1056 {
1057 MessageQueueService * _service = _getProviderManagerService();
1058 Uint32 _queueId = _service->getQueueId();
1059
1060 callback_data *cb_data = new callback_data(this);
1061
1062 // create request envelope
1063 AsyncLegacyOperationStart * asyncRequest =
1064 new AsyncLegacyOperationStart (
1065 _service->get_next_xid(),
1066 NULL,
1067 _queueId,
1068 disable_req,
1069 _queueId);
1070
|
1071 kumpf 1.8 AsyncReply * asyncReply = _controller->ClientSendWait(*_client_handle,
1072 _queueId,
1073 asyncRequest);
|
1074 kumpf 1.10 CIMDisableModuleResponseMessage * response =
1075 reinterpret_cast<CIMDisableModuleResponseMessage *>(
|
1076 kumpf 1.70 (dynamic_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result());
|
1077 kumpf 1.8 if (response->cimException.getCode() != CIM_ERR_SUCCESS)
1078 {
1079 CIMException e = response->cimException;
1080 delete asyncRequest;
1081 delete asyncReply;
1082 delete response;
1083 throw (e);
1084 }
|
1085 kumpf 1.5
|
1086 chip 1.24 Array<Uint16> operationalStatus = response->operationalStatus;
|
1087 kumpf 1.8
1088 delete asyncRequest;
1089 delete asyncReply;
1090 delete response;
|
1091 mday 1.16
|
1092 kumpf 1.5 return(operationalStatus);
1093 }
1094
1095 Array<Uint16> ProviderRegistrationProvider::_sendEnableMessageToProviderManager(
1096 CIMEnableModuleRequestMessage * enable_req)
1097 {
1098 MessageQueueService * _service = _getProviderManagerService();
1099 Uint32 _queueId = _service->getQueueId();
1100
1101 callback_data *cb_data = new callback_data(this);
1102
1103 // create request envelope
1104 AsyncLegacyOperationStart * asyncRequest =
1105 new AsyncLegacyOperationStart (
1106 _service->get_next_xid(),
1107 NULL,
1108 _queueId,
1109 enable_req,
1110 _queueId);
1111
|
1112 kumpf 1.8 AsyncReply * asyncReply = _controller->ClientSendWait(*_client_handle,
1113 _queueId,
1114 asyncRequest);
1115 CIMEnableModuleResponseMessage * response =
1116 reinterpret_cast<CIMEnableModuleResponseMessage *>(
|
1117 kumpf 1.70 (dynamic_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result());
|
1118 kumpf 1.8 if (response->cimException.getCode() != CIM_ERR_SUCCESS)
1119 {
1120 CIMException e = response->cimException;
1121 delete asyncRequest;
1122 delete asyncReply;
1123 delete response;
1124 throw (e);
1125 }
1126
|
1127 chip 1.24 Array<Uint16> operationalStatus = response->operationalStatus;
|
1128 kumpf 1.8
1129 delete asyncRequest;
1130 delete asyncReply;
1131 delete response;
|
1132 mday 1.16
|
1133 kumpf 1.5 return(operationalStatus);
|
1134 kumpf 1.6 }
1135
1136 // send termination message to subscription service
1137 void ProviderRegistrationProvider::_sendTerminationMessageToSubscription(
|
1138 kumpf 1.43 const CIMObjectPath & ref, const String & moduleName,
|
1139 chuck 1.47 const Boolean disableProviderOnly,
1140 const AcceptLanguages & al)
|
1141 kumpf 1.6 {
1142 CIMInstance instance;
1143 String _moduleName;
1144 Array<CIMInstance> instances;
1145
|
1146 kumpf 1.43 if (!disableProviderOnly)
1147 {
1148 CIMObjectPath reference("", PEGASUS_NAMESPACENAME_INTEROP,
1149 PEGASUS_CLASSNAME_PROVIDER, ref.getKeyBindings());
|
1150 chip 1.24
|
1151 kumpf 1.43 Array<CIMObjectPath> instanceNames =
1152 _providerRegistrationManager->enumerateInstanceNames(reference);
|
1153 kumpf 1.6
|
1154 kumpf 1.43 // find all the instances which have same module name as moduleName
1155 for (Uint32 i = 0, n=instanceNames.size(); i < n; i++)
1156 {
|
1157 kumpf 1.42 //
1158 // get provider module name from reference
1159 //
1160
1161 Array<CIMKeyBinding> keys = instanceNames[i].getKeyBindings();
1162
1163 for(Uint32 j=0; j < keys.size(); j++)
1164 {
1165 if(keys[j].getName().equal (_PROPERTY_PROVIDERMODULENAME))
1166 {
1167 _moduleName = keys[j].getValue();
1168 }
1169 }
|
1170 kumpf 1.6
|
1171 kumpf 1.43 if (String::equalNoCase(moduleName, _moduleName))
1172 {
1173 reference.setKeyBindings(keys);
1174 instance = _providerRegistrationManager->getInstance(reference);
|
1175 kumpf 1.55 //
1176 // if the provider is indication provider
1177 //
|
1178 kumpf 1.70 if (_isIndicationProvider(moduleName, instance))
|
1179 kumpf 1.55 {
1180 instances.append(instance);
1181 }
|
1182 kumpf 1.43 }
1183 }
1184 }
1185 else
1186 {
|
1187 kumpf 1.55 instance = _providerRegistrationManager->getInstance(ref);
1188
1189 //
1190 // if the provider is indication provider
1191 //
|
1192 kumpf 1.70 if (_isIndicationProvider(moduleName, instance))
|
1193 kumpf 1.55 {
|
1194 kumpf 1.6 instances.append(instance);
|
1195 kumpf 1.55 }
|
1196 kumpf 1.6 }
1197
1198 //
1199 // get indication server queueId
1200 //
1201 MessageQueueService * _service = _getIndicationService();
1202
|
1203 kumpf 1.15 if (_service != NULL)
1204 {
1205 Uint32 _queueId = _service->getQueueId();
|
1206 kumpf 1.6
|
1207 kumpf 1.15 CIMNotifyProviderTerminationRequestMessage * termination_req =
1208 new CIMNotifyProviderTerminationRequestMessage(
1209 XmlWriter::getNextMessageId (),
1210 instances,
1211 QueueIdStack(_service->getQueueId()));
1212
|
1213 chuck 1.47 // l10n
|
1214 se.gupta 1.69 termination_req->operationContext.set(AcceptLanguageListContainer(al));
|
1215 chuck 1.47
|
1216 kumpf 1.15 // create request envelope
|
1217 kumpf 1.71 AsyncLegacyOperationStart asyncRequest
1218 (_service->get_next_xid(),
1219 NULL,
1220 _queueId,
1221 termination_req,
1222 _queueId);
|
1223 kumpf 1.6
|
1224 kumpf 1.71 AutoPtr <AsyncReply> asyncReply
1225 (_controller->ClientSendWait (* _client_handle, _queueId,
1226 &asyncRequest));
1227
1228 AutoPtr <CIMNotifyProviderTerminationResponseMessage> response
1229 (reinterpret_cast <CIMNotifyProviderTerminationResponseMessage *>
1230 ((dynamic_cast <AsyncLegacyOperationResult *>
1231 (asyncReply.get ()))->get_result ()));
1232
1233 if (response->cimException.getCode () != CIM_ERR_SUCCESS)
|
1234 kumpf 1.15 {
|
1235 kumpf 1.71 CIMException e = response->cimException;
1236 throw (e);
|
1237 kumpf 1.15 }
|
1238 kumpf 1.6 }
1239 }
1240
1241 // get indication service
1242 MessageQueueService * ProviderRegistrationProvider::_getIndicationService()
1243 {
1244 MessageQueue * queue = MessageQueue::lookup(
1245 PEGASUS_QUEUENAME_INDICATIONSERVICE);
1246
1247 MessageQueueService * _service =
1248 dynamic_cast<MessageQueueService *>(queue);
1249 return(_service);
|
1250 kumpf 1.43 }
1251
1252 // disable provider module, return 0 if module is disabled successfully,
|
1253 kumpf 1.51 // return 1 if module is already disabled, return -2 if module can not be
1254 // disabled since there are pending requests, otherwise, return -1
|
1255 kumpf 1.43 Sint16 ProviderRegistrationProvider::_disableModule(
1256 const CIMObjectPath & objectReference,
1257 const String & moduleName,
|
1258 chuck 1.47 Boolean disableProviderOnly,
1259 const AcceptLanguages & al) // l10n
|
1260 kumpf 1.43 {
1261 //
1262 // get module status
1263 //
1264 Array<Uint16> _OperationalStatus =
1265 _providerRegistrationManager->getProviderModuleStatus( moduleName);
1266
1267 for (Uint32 i = 0; i<_OperationalStatus.size(); i++)
1268 {
1269 // retValue equals 1 if module is already disabled
|
1270 kumpf 1.68 if (_OperationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPED ||
1271 _OperationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPING)
|
1272 kumpf 1.43 {
1273 return (1);
1274 }
1275 }
1276
1277 CIMInstance instance;
1278 Array<CIMInstance> instances;
1279 CIMInstance mInstance;
1280 String _moduleName;
1281 Uint16 providers;
1282 CIMObjectPath providerRef;
|
1283 kumpf 1.55 Boolean indProvider = false;
1284 Array<Boolean> indicationProviders;
|
1285 kumpf 1.43
1286 // disable a provider module or delete a provider module
1287 if (!disableProviderOnly)
1288 {
1289 providerRef = CIMObjectPath(objectReference.getHost(),
1290 objectReference.getNameSpace(),
1291 PEGASUS_CLASSNAME_PROVIDER,
1292 objectReference.getKeyBindings());
1293
1294 // get module instance
1295 mInstance =
1296 _providerRegistrationManager->getInstance(objectReference);
1297
1298 }
1299 else // disable a provider
1300 {
1301 // get module instance
1302 Array <CIMKeyBinding> moduleKeyBindings;
1303 moduleKeyBindings.append (CIMKeyBinding
1304 (_PROPERTY_PROVIDERMODULE_NAME, moduleName,
1305 CIMKeyBinding::STRING));
1306 kumpf 1.43
1307 CIMObjectPath moduleRef(objectReference.getHost(),
1308 objectReference.getNameSpace(),
1309 PEGASUS_CLASSNAME_PROVIDERMODULE,
1310 moduleKeyBindings);
1311
1312 mInstance =
1313 _providerRegistrationManager->getInstance(moduleRef);
1314 }
1315
1316 if (!disableProviderOnly)
1317 {
1318 // get all provider instances which have same module name as
1319 // moduleName
1320 Array<CIMObjectPath> instanceNames =
1321 _providerRegistrationManager->enumerateInstanceNames(providerRef);
1322
1323 for(Uint32 i = 0, n=instanceNames.size(); i < n; i++)
1324 {
1325 //
1326 // get provider module name from reference
1327 kumpf 1.43 //
1328
1329 Array<CIMKeyBinding> keys = instanceNames[i].getKeyBindings();
1330
1331 for(Uint32 j=0; j < keys.size(); j++)
1332 {
1333 if(keys[j].getName().equal (_PROPERTY_PROVIDERMODULENAME))
1334 {
1335 _moduleName = keys[j].getValue();
1336 }
1337 }
1338
1339 if (String::equalNoCase(_moduleName, moduleName))
1340 {
1341 providerRef.setKeyBindings(keys);
1342 instance = _providerRegistrationManager->getInstance
1343 (providerRef);
|
1344 kumpf 1.70 if (_isIndicationProvider(moduleName, instance))
|
1345 kumpf 1.55 {
1346 indProvider = true;
1347 indicationProviders.append(true);
1348 }
1349 else
1350 {
1351 indicationProviders.append(false);
1352 }
|
1353 kumpf 1.43 instances.append(instance);
1354 }
1355
1356 }
1357 }
1358 else
1359 {
|
1360 kumpf 1.55 instance = _providerRegistrationManager->getInstance(objectReference);
|
1361 kumpf 1.70 if (_isIndicationProvider(moduleName, instance))
|
1362 kumpf 1.55 {
1363 indProvider = true;
1364 indicationProviders.append(true);
1365 }
1366 else
1367 {
1368 indicationProviders.append(false);
1369 }
1370
1371 instances.append(instance);
|
1372 kumpf 1.43 }
1373
1374 //
1375 // get provider manager service
1376 //
1377 MessageQueueService * _service = _getProviderManagerService();
1378
1379 if (_service != NULL)
1380 {
1381 // create CIMDisableModuleRequestMessage
1382 CIMDisableModuleRequestMessage * disable_req =
1383 new CIMDisableModuleRequestMessage(
1384 XmlWriter::getNextMessageId (),
1385 mInstance,
1386 instances,
1387 disableProviderOnly,
|
1388 kumpf 1.55 indicationProviders,
|
1389 kumpf 1.43 QueueIdStack(_service->getQueueId()));
|
1390 chuck 1.47 // l10n
|
1391 se.gupta 1.66 disable_req->operationContext.set(AcceptLanguageListContainer(al));;
|
1392 kumpf 1.43
1393 Array<Uint16> _opStatus =
1394 _sendDisableMessageToProviderManager(disable_req);
1395
1396 if (!disableProviderOnly) // disable provider module
1397 {
1398 for (Uint32 i = 0; i<_opStatus.size(); i++)
1399 {
1400 // module was disabled successfully
|
1401 kumpf 1.68 if (_opStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPED)
|
1402 kumpf 1.43 {
|
1403 kumpf 1.55 if (indProvider)
1404 {
1405 // send termination message to subscription service
1406 _sendTerminationMessageToSubscription(objectReference,
1407 moduleName, false, al);
1408 }
|
1409 kumpf 1.43 return (0);
1410 }
|
1411 kumpf 1.51
1412 // module is not disabled since there are pending
1413 // requests for the providers in the module
|
1414 kumpf 1.68 if (_opStatus[i] == CIM_MSE_OPSTATUS_VALUE_OK)
|
1415 kumpf 1.51 {
1416 return (-2);
1417 }
|
1418 kumpf 1.43 }
1419 }
1420 else // disable provider
1421 {
|
1422 kumpf 1.55 if (indProvider)
1423 {
1424 _sendTerminationMessageToSubscription(objectReference,
|
1425 chuck 1.47 moduleName, true, al);
|
1426 kumpf 1.55 }
|
1427 kumpf 1.43 return (0);
1428 }
1429 }
1430
1431 // disable failed
1432 return (-1);
|
1433 kumpf 1.55 }
1434
|
1435 kumpf 1.56 // enable provider module
1436 // return 0 if module is enabled successfully,
1437 // return 1 if module is already enabled,
1438 // return 2 if module can not be enabled since module is stopping,
1439 // otherwise, return -1
1440 Sint16 ProviderRegistrationProvider::_enableModule(
1441 const CIMObjectPath & moduleRef,
1442 const String & moduleName,
1443 const AcceptLanguages & al)
1444 {
1445 //
1446 // get module status
1447 //
1448 Array<Uint16> _OperationalStatus =
1449 _providerRegistrationManager->getProviderModuleStatus( moduleName);
1450
1451 for (Uint32 i = 0; i<_OperationalStatus.size(); i++)
1452 {
1453 // retValue equals 1 if module is already enabled
|
1454 kumpf 1.68 if (_OperationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_OK)
|
1455 kumpf 1.56 {
1456 return (1);
1457 }
1458
1459 // retValue equals 2 if module is stopping
1460 // at this stage, module can not be started
|
1461 kumpf 1.68 if (_OperationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPING)
|
1462 kumpf 1.56 {
1463 return (2);
1464 }
1465 }
1466
1467 // get module instance
1468 CIMInstance mInstance =
1469 _providerRegistrationManager->getInstance(moduleRef);
1470
1471 //
1472 // get provider manager service
1473 //
1474 MessageQueueService * _service = _getProviderManagerService();
1475 Boolean enabled = false;
1476
|
1477 kumpf 1.65 if (_service != NULL)
|
1478 kumpf 1.56 {
1479 // create CIMEnableModuleRequestMessage
1480 CIMEnableModuleRequestMessage * enable_req =
1481 new CIMEnableModuleRequestMessage(
1482 XmlWriter::getNextMessageId (),
1483 mInstance,
1484 QueueIdStack(_service->getQueueId()));
1485 // l10n
|
1486 se.gupta 1.66 enable_req->operationContext.set(AcceptLanguageListContainer(al));;
1487
|
1488 kumpf 1.56 Array<Uint16> _opStatus;
1489 _opStatus = _sendEnableMessageToProviderManager(enable_req);
1490
1491 for (Uint32 i = 0; i<_opStatus.size(); i++)
1492 {
1493 // module is enabled successfully
|
1494 kumpf 1.68 if (_opStatus[i] == CIM_MSE_OPSTATUS_VALUE_OK)
|
1495 kumpf 1.56 {
1496 enabled = true;
1497 }
1498 }
1499 }
1500
1501 if (enabled)
1502 {
1503 //
|
1504 kumpf 1.59 // Since module is enabled, need get updated module instance
1505 //
|
1506 kumpf 1.65 CIMInstance updatedModuleInstance =
|
1507 kumpf 1.59 _providerRegistrationManager->getInstance(moduleRef);
1508
|
1509 kumpf 1.65 // module is enabled, initialize providers as necessary
1510 _providerRegistrationManager->initializeProviders(
1511 updatedModuleInstance);
1512
|
1513 kumpf 1.59 //
1514 // The module is enabled, need to send enable message to
|
1515 kumpf 1.56 // subscription service if the provider is an indication provider
1516 //
1517
1518 CIMObjectPath providerRef = CIMObjectPath(String::EMPTY,
1519 moduleRef.getNameSpace(),
1520 PEGASUS_CLASSNAME_PROVIDER,
1521 Array<CIMKeyBinding>());
1522
1523 //
1524 // get all provider instances which have same module name as
1525 // moduleName
1526 //
1527 Array<CIMObjectPath> instanceNames =
1528 _providerRegistrationManager->enumerateInstanceNames(providerRef);
1529 CIMInstance pInstance;
1530 String _moduleName;
1531 String _providerName;
1532 Array<CIMInstance> capInstances;
1533
1534 for(Uint32 i = 0, n=instanceNames.size(); i < n; i++)
1535 {
1536 kumpf 1.56
1537 Array<CIMKeyBinding> keys = instanceNames[i].getKeyBindings();
1538
1539 for(Uint32 j=0; j < keys.size(); j++)
1540 {
1541 //
1542 // get provider module name from reference
1543 //
1544 if(keys[j].getName().equal (_PROPERTY_PROVIDERMODULENAME))
1545 {
1546 _moduleName = keys[j].getValue();
1547 }
1548
1549 //
1550 // get provider name from reference
1551 //
1552 if(keys[j].getName().equal (_PROPERTY_PROVIDER_NAME))
1553 {
1554 _providerName = keys[j].getValue();
1555 }
1556 }
1557 kumpf 1.56
1558 if (String::equalNoCase(_moduleName, moduleName))
1559 {
1560 providerRef.setKeyBindings(keys);
1561 pInstance = _providerRegistrationManager->getInstance
1562 (providerRef);
1563 //
1564 // get all the indication capability instances which belongs
1565 // to this provider
1566 //
1567 capInstances = _getIndicationCapInstances(
1568 moduleName, pInstance, providerRef);
1569
1570 //
1571 // if there are indication capability instances
1572 //
|
1573 kumpf 1.71 if (capInstances.size() != 0)
|
1574 kumpf 1.56 {
|
1575 kumpf 1.65 _sendEnableMessageToSubscription(updatedModuleInstance,
|
1576 kumpf 1.56 pInstance,
1577 capInstances,
1578 al);
1579 }
1580 }
1581 }
1582 return (0);
1583 }
1584
1585
1586 // enable failed
1587 return (-1);
1588 }
1589
1590 // send enable message to indication service
1591 void ProviderRegistrationProvider::_sendEnableMessageToSubscription(
1592 const CIMInstance & mInstance,
1593 const CIMInstance & pInstance,
1594 const Array<CIMInstance> & capInstances,
1595 const AcceptLanguages & al)
1596 {
1597 kumpf 1.56 //
1598 // get indication server queueId
1599 //
1600 MessageQueueService * _service = _getIndicationService();
1601
1602 if (_service != NULL)
1603 {
1604 Uint32 _queueId = _service->getQueueId();
1605
1606 CIMNotifyProviderEnableRequestMessage * enable_req =
1607 new CIMNotifyProviderEnableRequestMessage (
1608 XmlWriter::getNextMessageId (),
1609 capInstances,
1610 QueueIdStack(_service->getQueueId()));
1611
|
1612 se.gupta 1.66 enable_req->operationContext.set(AcceptLanguageListContainer(al));
|
1613 se.gupta 1.67 enable_req->operationContext.insert(ProviderIdContainer(mInstance,pInstance));
|
1614 se.gupta 1.66
|
1615 kumpf 1.56 // create request envelope
1616 AsyncLegacyOperationStart * asyncRequest =
1617 new AsyncLegacyOperationStart (
1618 _service->get_next_xid(),
1619 NULL,
1620 _queueId,
1621 enable_req,
1622 _queueId);
1623
|
1624 kumpf 1.64 AsyncReply * asyncReply =
1625 _controller->ClientSendWait(*_client_handle,
1626 _queueId,
1627 asyncRequest);
|
1628 kumpf 1.56
|
1629 kumpf 1.64 CIMNotifyProviderEnableResponseMessage * response =
1630 reinterpret_cast<CIMNotifyProviderEnableResponseMessage *>(
|
1631 kumpf 1.70 (dynamic_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result());
|
1632 kumpf 1.64
1633 if (response->cimException.getCode() != CIM_ERR_SUCCESS)
1634 {
1635 CIMException e = response->cimException;
1636 delete asyncRequest;
1637 delete asyncReply;
1638 delete response;
1639 throw (e);
1640 }
1641
1642 delete asyncRequest;
1643 delete asyncReply;
1644 delete response;
|
1645 kumpf 1.56 }
1646 }
1647
|
1648 kumpf 1.70 // If provider is an indication provider, return true,
|
1649 kumpf 1.55 // otherwise, return false
1650 Boolean ProviderRegistrationProvider::_isIndicationProvider(
1651 const String & moduleName,
|
1652 kumpf 1.70 const CIMInstance & instance)
|
1653 kumpf 1.55 {
1654 // get provider name
1655 String providerName;
|
1656 kumpf 1.70 Uint32 pos = instance.findProperty(_PROPERTY_PROVIDER_NAME);
|
1657 kumpf 1.55 if (pos != PEG_NOT_FOUND)
1658 {
1659 instance.getProperty(pos).getValue().get(providerName);
1660 }
1661
|
1662 kumpf 1.70 return (_providerRegistrationManager->isIndicationProvider(
1663 moduleName, providerName));
|
1664 kumpf 1.56 }
1665
1666 //
1667 // get all the capability instances whose provider type is indication
1668 //
1669 Array<CIMInstance> ProviderRegistrationProvider::_getIndicationCapInstances(
1670 const String & moduleName,
1671 const CIMInstance & instance,
1672 const CIMObjectPath & providerRef)
1673 {
1674 // get provider name
1675 String providerName;
1676 Uint32 pos = instance.findProperty(CIMName (_PROPERTY_PROVIDER_NAME));
1677 if (pos != PEG_NOT_FOUND)
1678 {
1679 instance.getProperty(pos).getValue().get(providerName);
1680 }
1681
1682 CIMObjectPath capabilityRef;
1683
1684 capabilityRef = CIMObjectPath(providerRef.getHost(),
1685 kumpf 1.56 providerRef.getNameSpace(),
1686 PEGASUS_CLASSNAME_CAPABILITIESREGISTRATION,
1687 providerRef.getKeyBindings());
1688
1689 // get all Capabilities instances
1690 Array<CIMObjectPath> instanceNames =
1691 _providerRegistrationManager->enumerateInstanceNames(capabilityRef);
1692
1693 String _moduleName, _providerName;
1694 CIMInstance capInstance;
1695 Array<Uint16> providerTypes;
1696 Array<CIMInstance> indCapInstances = 0;
1697 for(Uint32 i = 0, n=instanceNames.size(); i < n; i++)
1698 {
1699 Array<CIMKeyBinding> keys = instanceNames[i].getKeyBindings();
1700
1701 for(Uint32 j=0; j < keys.size(); j++)
1702 {
1703 if(keys[j].getName().equal (_PROPERTY_PROVIDERMODULENAME))
1704 {
1705 _moduleName = keys[j].getValue();
1706 kumpf 1.56 }
1707
1708 if(keys[j].getName().equal (_PROPERTY_PROVIDERNAME))
1709 {
1710 _providerName = keys[j].getValue();
1711 }
|
1712 kumpf 1.58 }
|
1713 kumpf 1.56
|
1714 kumpf 1.58 //
1715 // if capability instance has same module name as moduleName
1716 // and same provider name as providerName, get provider type
1717 //
1718 if(String::equal(_moduleName, moduleName) &&
1719 String::equal(_providerName, providerName))
1720 {
1721 capInstance = _providerRegistrationManager->getInstance
|
1722 kumpf 1.56 (instanceNames[i]);
1723
|
1724 kumpf 1.58 Uint32 pos = capInstance.findProperty(CIMName (_PROPERTY_PROVIDERTYPE));
1725 if (pos != PEG_NOT_FOUND)
1726 {
1727 capInstance.getProperty(pos).getValue().get(providerTypes);
|
1728 kumpf 1.56
|
1729 kumpf 1.58 for (Uint32 k=0; k < providerTypes.size(); k++)
1730 {
1731 //
1732 // if provider type of the instance is indication,
1733 // append the instance
1734 //
1735 if (providerTypes[k] == _INDICATION_PROVIDER)
1736 {
1737 indCapInstances.append(capInstance);
1738 }
1739 }
1740 }
1741 }
|
1742 kumpf 1.56 }
1743
1744 return (indCapInstances);
|
1745 kumpf 1.1 }
1746
1747 PEGASUS_NAMESPACE_END
|