1 kumpf 1.1 //%/////////////////////////////////////////////////////////////////////////////
2 //
|
3 kumpf 1.22 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
4 // The Open Group, Tivoli Systems
|
5 kumpf 1.1 //
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:
|
12 chip 1.24 //
|
13 kumpf 1.1 // 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.
21 //
22 //==============================================================================
23 //
24 // Author: Yi Zhou (yi_zhou@hp.com)
25 //
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 kumpf 1.20 // Carol Ann Krug Graves, Hewlett-Packard Company
30 // (carolann_graves@hp.com)
|
31 kumpf 1.1 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
|
34 kumpf 1.5 #include "ProviderRegistrationProvider.h"
35
|
36 kumpf 1.4 #include <Pegasus/Common/PegasusVersion.h>
|
37 kumpf 1.5 #include <Pegasus/Common/XmlWriter.h>
|
38 kumpf 1.6 #include <Pegasus/Common/Constants.h>
39 #include <Pegasus/Common/CIMMessage.h>
|
40 kumpf 1.15 #include <Pegasus/Common/OperationContext.h>
41 #include <Pegasus/Common/System.h>
|
42 humberto 1.48 #include <Pegasus/Common/MessageLoader.h> //l10n
|
43 kumpf 1.1
44 PEGASUS_NAMESPACE_BEGIN
45
46 /**
47 The name of the CapabilityID property for provider capabilities class
48 */
|
49 kumpf 1.36 static const CIMName _PROPERTY_CAPABILITYID = CIMName ("CapabilityID");
|
50 kumpf 1.1
51 /**
|
52 kumpf 1.40 Module status
|
53 kumpf 1.1 */
|
54 kumpf 1.40 static const Uint16 _MODULE_OK = 2;
|
55 kumpf 1.1
56 /**
57 stopping provider method
58 */
|
59 kumpf 1.36 static const CIMName _STOP_PROVIDER = CIMName ("Stop");
|
60 kumpf 1.1
61 /**
62 starting provider method
63 */
|
64 kumpf 1.36 static const CIMName _START_PROVIDER = CIMName ("Start");
|
65 kumpf 1.1
66 /**
67 Provider status
68 */
|
69 kumpf 1.14 static const Uint16 _MODULE_STOPPING = 9;
|
70 kumpf 1.1
|
71 kumpf 1.10 static const Uint16 _MODULE_STOPPED = 10;
|
72 kumpf 1.1
73 ProviderRegistrationProvider::ProviderRegistrationProvider(
74 ProviderRegistrationManager * providerRegistrationManager)
|
75 kumpf 1.6 :_id(peg_credential_types::PROVIDER)
|
76 kumpf 1.1 {
77 _providerRegistrationManager = providerRegistrationManager;
|
78 kumpf 1.6
79 _controller = &(ModuleController::get_client_handle(_id, &_client_handle));
80 if(_client_handle == NULL)
|
81 kumpf 1.32 throw UninitializedObjectException();
|
82 kumpf 1.1 }
83
84 ProviderRegistrationProvider::~ProviderRegistrationProvider(void)
85 {
|
86 kumpf 1.6 if (_providerRegistrationManager)
87 {
88 delete _providerRegistrationManager;
89 }
90
91 if (_client_handle)
92 {
93 delete _client_handle;
94 }
95
|
96 kumpf 1.1 }
97
98 void ProviderRegistrationProvider::initialize(CIMOMHandle & cimom)
99 {
100 // This method should not be called because this is a control provider
101 // and is not dynamically loaded through the provider manager
102 }
103
104 void ProviderRegistrationProvider::terminate(void)
105 {
106 }
107
108 // get registered provider
109 void ProviderRegistrationProvider::getInstance(
110 const OperationContext & context,
|
111 kumpf 1.13 const CIMObjectPath & instanceReference,
|
112 kumpf 1.34 const Boolean includeQualifiers,
113 const Boolean includeClassOrigin,
|
114 kumpf 1.2 const CIMPropertyList & propertyList,
|
115 kumpf 1.33 InstanceResponseHandler & handler)
|
116 kumpf 1.1 {
117
|
118 kumpf 1.36 if(!instanceReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
|
119 kumpf 1.10 {
|
120 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
|
121 kumpf 1.36 instanceReference.getNameSpace().getString());
|
122 kumpf 1.10 }
123
|
124 kumpf 1.1 // ensure the class existing in the specified namespace
|
125 kumpf 1.36 CIMName className = instanceReference.getClassName();
|
126 kumpf 1.1
|
127 kumpf 1.36 if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
128 !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
|
129 kumpf 1.46 !className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES) &&
|
130 kumpf 1.36 !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
|
131 kumpf 1.1 {
|
132 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
133 className.getString());
|
134 kumpf 1.1 }
135
136 // begin processing the request
137 handler.processing();
138
139 CIMInstance instance;
140
141 try
142 {
143 instance = _providerRegistrationManager->getInstance(instanceReference);
144 }
145 catch(CIMException& e)
146 {
|
147 kumpf 1.26 throw (e);
|
148 kumpf 1.1 }
149
150 handler.deliver(instance);
151
152 // complete processing the request
153 handler.complete();
154 }
155
156 // get all registered providers
157 void ProviderRegistrationProvider::enumerateInstances(
158 const OperationContext & context,
|
159 kumpf 1.13 const CIMObjectPath & classReference,
|
160 kumpf 1.34 const Boolean includeQualifiers,
161 const Boolean includeClassOrigin,
|
162 kumpf 1.2 const CIMPropertyList & propertyList,
|
163 kumpf 1.33 InstanceResponseHandler & handler)
|
164 kumpf 1.1 {
|
165 kumpf 1.36 if(!classReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
|
166 kumpf 1.10 {
|
167 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
168 classReference.getNameSpace().getString());
|
169 kumpf 1.10 }
170
|
171 kumpf 1.1 // ensure the class existing in the specified namespace
|
172 kumpf 1.36 CIMName className = classReference.getClassName();
|
173 kumpf 1.1
|
174 kumpf 1.36 if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
175 !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
|
176 kumpf 1.46 !className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES) &&
|
177 kumpf 1.36 !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
|
178 kumpf 1.1 {
|
179 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
180 className.getString());
|
181 kumpf 1.1 }
182
183 // begin processing the request
184 handler.processing();
185
|
186 kumpf 1.20 Array<CIMInstance> enumInstances;
|
187 kumpf 1.1
188 try
189 {
190 enumInstances = _providerRegistrationManager->enumerateInstances(classReference);
191 }
192 catch(CIMException& e)
193 {
|
194 kumpf 1.26 throw (e);
|
195 kumpf 1.1 }
196
|
197 kumpf 1.21 handler.deliver(enumInstances);
|
198 kumpf 1.1
199 // complete processing the request
200 handler.complete();
201 }
202
203 // get all registered provider names
204 void ProviderRegistrationProvider::enumerateInstanceNames(
205 const OperationContext & context,
|
206 kumpf 1.13 const CIMObjectPath & classReference,
|
207 kumpf 1.33 ObjectPathResponseHandler & handler)
|
208 kumpf 1.1 {
|
209 kumpf 1.36 if(!classReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
|
210 kumpf 1.10 {
|
211 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
212 classReference.getNameSpace().getString());
|
213 kumpf 1.10 }
214
|
215 kumpf 1.1 // ensure the class existing in the specified namespace
|
216 kumpf 1.36 CIMName className = classReference.getClassName();
|
217 kumpf 1.1
|
218 kumpf 1.36 if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
219 !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
|
220 kumpf 1.46 !className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES) &&
|
221 kumpf 1.36 !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
|
222 kumpf 1.1 {
|
223 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
224 className.getString());
|
225 kumpf 1.1 }
226
227 // begin processing the request
228 handler.processing();
229
|
230 kumpf 1.13 Array<CIMObjectPath> enumInstanceNames;
|
231 kumpf 1.1
232 // get all instance names from repository
233 try
234 {
235 enumInstanceNames =
236 _providerRegistrationManager->enumerateInstanceNames(classReference);
237 }
238 catch(CIMException& e)
239 {
|
240 kumpf 1.26 throw (e);
|
241 kumpf 1.1 }
242
243 handler.deliver(enumInstanceNames);
244
245 // complete processing the request
246 handler.complete();
247 }
248
249 // change properties for the registered provider
|
250 chip 1.24 // only support to change property of Namespaces, property of
|
251 kumpf 1.1 // SupportedProperties, and property of SupportedMethods
252 void ProviderRegistrationProvider::modifyInstance(
|
253 kumpf 1.15 const OperationContext & context,
|
254 kumpf 1.13 const CIMObjectPath & instanceReference,
|
255 kumpf 1.1 const CIMInstance & instanceObject,
|
256 kumpf 1.34 const Boolean includeQualifiers,
|
257 kumpf 1.2 const CIMPropertyList & propertyList,
|
258 kumpf 1.33 ResponseHandler & handler)
|
259 kumpf 1.1 {
|
260 kumpf 1.15 // get userName and only privileged user can execute this operation
|
261 kumpf 1.19 String userName;
262 try
263 {
|
264 kumpf 1.37 IdentityContainer container = context.get(IdentityContainer::NAME);
|
265 kumpf 1.19 userName = container.getUserName();
266 }
267 catch (...)
268 {
269 userName = String::EMPTY;
270 }
|
271 kumpf 1.15
|
272 chip 1.24 if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
|
273 kumpf 1.15 {
|
274 humberto 1.48 //l10n
275 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,
276 //"You must have superuser privilege to modify the registration.");
277 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED,MessageLoaderParms(
278 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.SUPERUSER_PRIVILEGE_REQUIRED_MODIFY_REGISTRATION",
279 "You must have superuser privilege to modify the registration."));
|
280 kumpf 1.15 }
281
|
282 kumpf 1.36 if(!instanceReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
|
283 kumpf 1.10 {
|
284 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
285 instanceReference.getNameSpace().getString());
|
286 kumpf 1.10 }
287
|
288 kumpf 1.1 //
289 // only support to modify the instance of PG_ProviderCapabilities
290 //
|
291 kumpf 1.36 if (!instanceReference.getClassName().equal
292 (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES))
|
293 kumpf 1.1 {
|
294 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
295 instanceReference.getClassName().getString());
|
296 kumpf 1.1 }
297
298 //
|
299 kumpf 1.2 // only can modify the property of Namespaces, property of
|
300 kumpf 1.1 // SupportedProperties, and property of SupportedMethods
301 //
|
302 kumpf 1.2 if (propertyList.isNull())
|
303 kumpf 1.1 {
|
304 humberto 1.48 //l10n
305 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
306 //"Only can modify Namespaces, SupportedProperties, and SupportedMethods.");
307 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED, MessageLoaderParms(
308 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.CAN_ONLY_MODIFY_ERR",
|
309 humberto 1.50 "Only can modify Namespaces, SupportedProperties, and SupportedMethods."));
|
310 kumpf 1.2 }
311
|
312 kumpf 1.28 Array<CIMName> propertyArray = propertyList.getPropertyNameArray();
|
313 kumpf 1.2 for (Uint32 i=0; i<propertyArray.size(); i++)
314 {
|
315 kumpf 1.36 if (!propertyArray[i].equal (_PROPERTY_NAMESPACES) &&
316 !propertyArray[i].equal (_PROPERTY_SUPPORTEDPROPERTIES) &&
317 !propertyArray[i].equal (_PROPERTY_SUPPORTEDMETHODS))
|
318 kumpf 1.1 {
|
319 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
320 propertyArray[i].getString());
|
321 kumpf 1.2 }
|
322 kumpf 1.1 }
323
324 // begin processing the request
325 handler.processing();
326
327 try
328 {
|
329 chip 1.24 _providerRegistrationManager->modifyInstance(instanceReference,
|
330 kumpf 1.34 instanceObject, includeQualifiers, propertyArray);
|
331 kumpf 1.1 }
332 catch(CIMException& e)
333 {
|
334 kumpf 1.26 throw (e);
|
335 kumpf 1.1 }
336
337 // complete processing the request
338 handler.complete();
339 }
340
341 // register a provider
342 void ProviderRegistrationProvider::createInstance(
343 const OperationContext & context,
|
344 kumpf 1.13 const CIMObjectPath & instanceReference,
|
345 kumpf 1.1 const CIMInstance & instanceObject,
|
346 kumpf 1.33 ObjectPathResponseHandler & handler)
|
347 kumpf 1.1 {
|
348 kumpf 1.15 // get userName and only privileged user can execute this operation
|
349 kumpf 1.19 String userName;
350 try
351 {
|
352 kumpf 1.37 IdentityContainer container = context.get(IdentityContainer::NAME);
|
353 kumpf 1.19 userName = container.getUserName();
354 }
355 catch (...)
356 {
357 userName = String::EMPTY;
358 }
|
359 kumpf 1.15
|
360 chip 1.24 if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
|
361 kumpf 1.15 {
|
362 humberto 1.48 //l10n
363 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,
364 //"You must have superuser privilege to register providers.");
365 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED, MessageLoaderParms(
366 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.SUPERUSER_PRIVILEGE_REQUIRED_REGISTER_PROVIDERS",
367 "You must have superuser privilege to register providers."));
|
368 kumpf 1.15 }
369
|
370 kumpf 1.36 CIMName className = instanceReference.getClassName();
371 CIMNamespaceName nameSpace = instanceReference.getNameSpace();
|
372 kumpf 1.1
|
373 kumpf 1.13 CIMObjectPath returnReference;
|
374 kumpf 1.1
375 CIMInstance instance = instanceObject;
376
|
377 kumpf 1.36 if(!nameSpace.equal (PEGASUS_NAMESPACENAME_INTEROP))
|
378 kumpf 1.10 {
|
379 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
380 nameSpace.getString());
|
381 kumpf 1.10 }
382
|
383 kumpf 1.1 // ensure the class existing in the specified namespace
|
384 kumpf 1.36 if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
385 !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
|
386 kumpf 1.46 !className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES) &&
|
387 kumpf 1.36 !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
|
388 kumpf 1.1 {
|
389 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
390 className.getString());
|
391 kumpf 1.1 }
392
393 //
394 // Check all required properties are set
395 //
|
396 kumpf 1.36 if (className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
|
397 kumpf 1.1 {
398 //
399 // Name, Version, InterfaceType, InterfaceVersion, and Location
400 // properties must be set
401 // OperationalStatus property needs to be set. If not, set to default
402 //
|
403 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULE_NAME) ==
404 PEG_NOT_FOUND)
|
405 kumpf 1.1 {
|
406 humberto 1.53 //l10n 485
|
407 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
408 //"Missing Name which is required property in PG_ProviderModule class.");
409 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
410 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_NAME_IN_PG_PROVIDERMODULE",
411 "Missing Name which is required property in PG_ProviderModule class."));
|
412 kumpf 1.12 }
413
|
414 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_VENDOR) == PEG_NOT_FOUND)
|
415 kumpf 1.12 {
|
416 humberto 1.53 //l10n 485
|
417 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
418 //"Missing Vendor which is required property in PG_ProviderModule class.");
419 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
420 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_VENDOR_IN_PG_PROVIDERMODULE",
421 "Missing Vendor which is required property in PG_ProviderModule class."));
|
422 kumpf 1.1 }
423
|
424 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_VERSION) == PEG_NOT_FOUND)
|
425 kumpf 1.1 {
|
426 humberto 1.53 //l10n 485
|
427 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
428 //"Missing Version which is required property in PG_ProviderModule class.");
429 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
430 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_VERSION_IN_PG_PROVIDERMODULE",
431 "Missing Version which is required property in PG_ProviderModule class."));
|
432 kumpf 1.1 }
433
|
434 kumpf 1.41 Uint32 ifcTypeIndex =
435 instanceObject.findProperty(_PROPERTY_INTERFACETYPE);
436 if (ifcTypeIndex == PEG_NOT_FOUND)
|
437 kumpf 1.1 {
|
438 humberto 1.53 //l10n 485
|
439 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
440 //"Missing InterfaceType which is required property in PG_ProviderModule class.");
441 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
442 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_INTERFACETYPE_IN_PG_PROVIDERMODULE",
443 "Missing InterfaceType which is required property in PG_ProviderModul class."));
|
444 kumpf 1.1 }
|
445 kumpf 1.41 String ifcTypeString;
446 instanceObject.getProperty(ifcTypeIndex).getValue().
447 get(ifcTypeString);
|
448 mday 1.45
449 if(ifcTypeString != "C++Default" && ifcTypeString != "CMPI" )
|
450 kumpf 1.41 {
|
451 humberto 1.53 //l10n 485
|
452 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
453 //"Unsupported InterfaceType value: \"" + ifcTypeString + "\"");
454 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,MessageLoaderParms(
|
455 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.UNSUPPORTED_INTERFACETYPE_VALUE",
456 "Unsupported InterfaceType value: \"$0\"",ifcTypeString));
|
457 kumpf 1.41 }
|
458 kumpf 1.1
|
459 kumpf 1.41 Uint32 ifcVersionIndex =
460 instanceObject.findProperty(_PROPERTY_INTERFACEVERSION);
461 if (ifcVersionIndex == PEG_NOT_FOUND)
|
462 kumpf 1.1 {
|
463 humberto 1.53 //l10n 485
|
464 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
465 //"Missing InterfaceVersion which is required property in PG_ProviderModule class.");
466 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
467 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_INTERFACEVERSION_IN_PG_PROVIDERMODULE",
468 "Missing InterfaceVersion which is required property in PG_ProviderModule class."));
|
469 kumpf 1.41 }
470 String ifcVersionString;
471 instanceObject.getProperty(ifcVersionIndex).getValue().
472 get(ifcVersionString);
473 if ((ifcVersionString != "2.1.0") &&
|
474 kumpf 1.46 (ifcVersionString != "2.2.0") &&
475 (ifcVersionString != "2.3.0"))
|
476 kumpf 1.41 {
|
477 humberto 1.53 //l10n 485
|
478 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
479 //"Unsupported InterfaceVersion value: \"" + ifcVersionString +
480 // "\"");
481 String unsupported = "InterfaceVersion";
482 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,MessageLoaderParms(
|
483 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.UNSUPPORTED_INTERFACEVERSION_VALUE",
484 "Unsupported InterfaceVersion value: \"$0\"",ifcVersionString));
|
485 kumpf 1.1 }
486
|
487 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_LOCATION) == PEG_NOT_FOUND)
|
488 kumpf 1.1 {
|
489 humberto 1.53 //l10n 485
|
490 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
491 //"Missing Location which is required property in PG_ProviderModule class.");
492 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
493 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_LOCATION_IN_PG_PROVIDERMODULE",
494 "Missing Location which is required property in PG_ProviderModule class."));
|
495 kumpf 1.1 }
496
|
497 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_OPERATIONALSTATUS) ==
498 PEG_NOT_FOUND)
|
499 kumpf 1.1 {
500 Array<Uint16> _operationalStatus;
|
501 kumpf 1.14 _operationalStatus.append(_MODULE_OK);
|
502 kumpf 1.1 instance.addProperty (CIMProperty
503 (_PROPERTY_OPERATIONALSTATUS, _operationalStatus));
504 }
505 }
|
506 kumpf 1.36 else if (className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES))
|
507 kumpf 1.1 {
508 //
509 // ProviderModuleName, ProviderName, InstanceID, ClassName,
510 // Namespaces, and ProviderType properties must be set
511 //
512
|
513 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULENAME) ==
514 PEG_NOT_FOUND)
|
515 kumpf 1.1 {
|
516 humberto 1.53 //l10n 485
|
517 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
518 //"Missing ProviderModuleName which is required property in PG_ProviderCapabilities class.");
519 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
520 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDERMODULENAME_IN_PG_PROVIDERCAPABILITIES",
521 "Missing ProviderModuleName which is required property in PG_ProviderCapabilities class."));
|
522 kumpf 1.1 }
523
|
524 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_PROVIDERNAME) ==
525 PEG_NOT_FOUND)
|
526 kumpf 1.1 {
|
527 humberto 1.53 //l10n 485
|
528 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
529 //"Missing ProviderName which is required property in PG_ProviderCapabilities class.");
530 String missing = "ProviderName";
531 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
532 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_REQUIRED_PROPERTY",
|
533 humberto 1.53 "Missing ProviderName which is required property in PG_ProviderCapabilities class."));
|
534 kumpf 1.1 }
535
|
536 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_CAPABILITYID) ==
537 PEG_NOT_FOUND)
|
538 kumpf 1.1 {
|
539 humberto 1.53 //l10n 485
|
540 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
541 //"Missing CapabilityID which is required property in PG_ProviderCapabilities class.");
542 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
543 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSINGCAPABILITYID_IN_PG_PROVIDERCAPABILITIES",
544 "Missing CapabilityID which is required property in PG_ProviderCapabilities class."));
|
545 kumpf 1.1 }
546
|
547 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_CLASSNAME) == PEG_NOT_FOUND)
|
548 kumpf 1.1 {
|
549 humberto 1.53 //l10n 485
|
550 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
551 //"Missing ClassName which is required property in PG_ProviderCapabilities class.");
552 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
553 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_CLASSNAME_IN_PG_PROVIDERCAPABILITIES",
554 "Missing ClassName which is required property in PG_ProviderCapabilities class."));
|
555 kumpf 1.1 }
556
|
557 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_NAMESPACES) == PEG_NOT_FOUND)
|
558 kumpf 1.1 {
|
559 humberto 1.53 //l10n 485
|
560 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
561 //"Missing Namespaces which is required property in PG_ProviderCapabilities class.");
562 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
563 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_NAMESPACES_IN_PG_PROVIDERCAPABILITIES",
564 "Missing Namespaces which is required property in PG_ProviderCapabilities class."));
|
565 kumpf 1.1 }
566
|
567 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_PROVIDERTYPE) == PEG_NOT_FOUND)
|
568 kumpf 1.1 {
|
569 humberto 1.53 //l10n 485
|
570 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
571 //"Missing ProviderType which is required property in PG_ProviderCapabilities class.");
572 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
573 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDERTYPE_IN_PG_PROVIDERCAPABILITIES",
574 "Missing ProviderType which is required property in PG_ProviderCapabilities class."));
|
575 kumpf 1.1 }
576 }
|
577 kumpf 1.46 else if (className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES))
578 {
579 //
580 // ProviderModuleName, ProviderName, CapabilityID, ProviderType,
581 // and Destinations properties must be set
582 //
583
584 if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULENAME) ==
585 PEG_NOT_FOUND)
586 {
|
587 humberto 1.49 //L10N_ TODO DONE
588 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
589 //"Missing ProviderModuleName which is required property in PG_ConsumerCapabilities class.");
590 MessageLoaderParms parms(
591 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDER_MODULE_NAME_WHICH_IS_REQUIRED",
|
592 kumpf 1.46 "Missing ProviderModuleName which is required property in PG_ConsumerCapabilities class.");
|
593 humberto 1.49
594 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
|
595 kumpf 1.46 }
596
597 if (instanceObject.findProperty(_PROPERTY_PROVIDERNAME) ==
598 PEG_NOT_FOUND)
599 {
|
600 humberto 1.49 //L10N_ TODO DONE
601 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
602 //"Missing ProviderName which is required property in PG_ConsumerCapabilities class.");
603
604 MessageLoaderParms parms(
605 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDER_NAME_WHICH_IS_REQUIRED",
|
606 kumpf 1.46 "Missing ProviderName which is required property in PG_ConsumerCapabilities class.");
|
607 humberto 1.49
608 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
|
609 kumpf 1.46 }
610
611 if (instanceObject.findProperty(_PROPERTY_CAPABILITYID) ==
612 PEG_NOT_FOUND)
613 {
|
614 humberto 1.49 //L10N_ TODO DONE
615 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
616 //"Missing CapabilityID which is required property in PG_ConsumerCapabilities class.");
617
618 MessageLoaderParms parms(
619 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_CAPABILITY_ID_WHICH_IS_REQUIRED",
|
620 kumpf 1.46 "Missing CapabilityID which is required property in PG_ConsumerCapabilities class.");
|
621 humberto 1.49
622 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
|
623 kumpf 1.46 }
624
625 if (instanceObject.findProperty(_PROPERTY_PROVIDERTYPE) == PEG_NOT_FOUND)
626 {
|
627 humberto 1.49 //L10N_ TODO DONE
628 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
629 //"Missing ProviderType which is required property in PG_ConsumerCapabilities class.");
630
631 MessageLoaderParms parms(
632 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDER_TYPE_WHICH_IS_REQUIRED",
|
633 kumpf 1.46 "Missing ProviderType 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_INDICATIONDESTINATIONS) ==
639 PEG_NOT_FOUND)
640 {
|
641 humberto 1.49 //L10N_ TODO DONE
642 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
643 //"Missing Destinations which is required property in PG_ConsumerCapabilities class.");
644
645 MessageLoaderParms parms(
646 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_DESTINATIONS_TYPE_WHICH_IS_REQUIRED",
|
647 kumpf 1.46 "Missing Destinations which is required property in PG_ConsumerCapabilities class.");
|
648 humberto 1.49
649 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
|
650 kumpf 1.46 }
651 }
|
652 kumpf 1.10 else // PEGASUS_CLASSNAME_PROVIDER
|
653 kumpf 1.1 {
654 //
655 // Name and ProviderModuleName properties must be set
656 //
|
657 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_PROVIDER_NAME) == PEG_NOT_FOUND)
|
658 kumpf 1.1 {
|
659 humberto 1.53 //l10n 485
|
660 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
661 //"Missing Name which is required property in PG_Provider class.");
662 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
663 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_REQUIRED_PROPERTY",
|
664 humberto 1.53 "Missing Name which is required property in PG_Provider class."));
|
665 kumpf 1.1 }
666
|
667 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULENAME) ==
668 PEG_NOT_FOUND)
|
669 kumpf 1.1 {
|
670 humberto 1.53 //l10n 485
|
671 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
672 //"Missing ProviderModuleName which is required property in PG_Provider class.");
673 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
|
674 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDERMODULENAME_IN_PG_PROVIDER",
675 "Missing ProviderModuleName which is required property in PG_Provider class."));
|
676 kumpf 1.1 }
677 }
678
679 // begin processing the request
680 handler.processing();
681
682 try
683 {
684 returnReference =
685 _providerRegistrationManager->createInstance(instanceReference, instance);
686 }
687 catch(CIMException& e)
688 {
|
689 kumpf 1.26 throw (e);
|
690 kumpf 1.1 }
691
692 handler.deliver(returnReference);
693
694 // complete processing request
695 handler.complete();
696 }
697
698 // Unregister a provider
699 void ProviderRegistrationProvider::deleteInstance(
700 const OperationContext & context,
|
701 kumpf 1.13 const CIMObjectPath & instanceReference,
|
702 kumpf 1.33 ResponseHandler & handler)
|
703 kumpf 1.1 {
|
704 kumpf 1.15 // get userName and only privileged user can execute this operation
|
705 kumpf 1.19 String userName;
706 try
707 {
|
708 kumpf 1.37 IdentityContainer container = context.get(IdentityContainer::NAME);
|
709 kumpf 1.19 userName = container.getUserName();
710 }
711 catch (...)
712 {
713 userName = String::EMPTY;
714 }
|
715 kumpf 1.15
|
716 chip 1.24 if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
|
717 kumpf 1.15 {
|
718 humberto 1.48 //l10n
719 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,
720 //"You must have superuser privilege to unregister providers.");
721 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED,MessageLoaderParms(
722 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.SUPERUSER_PRIVILEGE_REQUIRED_UNREGISTER_PROVIDERS",
723 "You must have superuser privilege to unregister providers."));
|
724 kumpf 1.15 }
725
|
726 kumpf 1.36 if(!instanceReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
|
727 kumpf 1.10 {
|
728 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
729 instanceReference.getNameSpace().getString());
|
730 kumpf 1.10 }
731
|
732 chuck 1.47
733 // l10n
734 // Get the client's list of preferred languages for the response
735 AcceptLanguages al = AcceptLanguages::EMPTY;
736 try
737 {
738 AcceptLanguageListContainer al_container =
739 (AcceptLanguageListContainer)context.get(AcceptLanguageListContainer::NAME);
740 al = al_container.getLanguages();
741 }
742 catch (...)
743 {
744 ; // Leave AcceptLanguages empty
745 }
746
|
747 kumpf 1.36 CIMName className = instanceReference.getClassName();
|
748 kumpf 1.1
749 // ensure the class existing in the specified namespace
|
750 kumpf 1.36 if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
751 !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
|
752 kumpf 1.46 !className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES) &&
|
753 kumpf 1.36 !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
|
754 kumpf 1.1 {
|
755 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
756 className.getString());
|
757 kumpf 1.1 }
758
759 // begin processing the request
760 handler.processing();
761
|
762 kumpf 1.43 String moduleName;
763 Boolean moduleFound = false;
764 Array<CIMKeyBinding> keys = instanceReference.getKeyBindings();
765
766 //
767 // disable provider before delete provider
768 // registration if the class is PG_Provider
769 //
770 if (className.equal (PEGASUS_CLASSNAME_PROVIDER))
771 {
772 // get module name from reference
773
774 for(Uint32 i=0; i<keys.size() ; i++)
775 {
776 if(keys[i].getName().equal (_PROPERTY_PROVIDERMODULENAME))
777 {
778 moduleName = keys[i].getValue();
779 moduleFound = true;
780 }
781 }
782
783 kumpf 1.43 // if _PROPERTY_PROVIDERMODULENAME key not found
784 if( !moduleFound)
785 {
|
786 humberto 1.53 //l10n 485
|
787 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
788 //"key ProviderModuleName was not found");
789 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,MessageLoaderParms(
|
790 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.PROVIDERMODULENAME_KEY_NOT_FOUND",
791 "key ProviderModuleName was not found"));
|
792 kumpf 1.43 }
793
794 //
795 // disable the provider
796 //
797 try
798 {
|
799 kumpf 1.51 Sint16 ret_value = _disableModule(instanceReference, moduleName, true, al);
800
|
801 kumpf 1.43 //
802 // if the provider disable failed
803 //
|
804 chuck 1.47 // l10n
|
805 kumpf 1.51 if (ret_value == -1)
|
806 kumpf 1.43 {
|
807 humberto 1.48 //l10n
808 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
809 //"disable the provider failed.");
810 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
811 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.DISABLE_PROVIDER_FAILED",
812 "disable the provider failed."));
|
813 kumpf 1.43 }
|
814 kumpf 1.51 //
815 // The provider disable failed since there are pending requests
816 //
817 if (ret_value == -2)
818 {
819 //L10N TODO
|
820 humberto 1.52 // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
821 //"disable the provider failed: Provider is busy.");
822 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
823 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.DISABLE_PROVIDER_FAILED_PROVIDER_BUSY",
824 "disable the provider failed: Provider is busy."));
|
825 kumpf 1.51 }
|
826 kumpf 1.43 }
827 catch(CIMException&)
828 {
829 throw;
830 }
831 }
832
833 //
834 // disable provider module before remove provider registration
835 // if the class is PG_ProviderModule
836 //
837
838 if (className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
839 {
840 // get module name from reference
841
842 for(Uint32 i=0; i<keys.size() ; i++)
843 {
844 if(keys[i].getName().equal (_PROPERTY_PROVIDERMODULE_NAME))
845 {
846 moduleName = keys[i].getValue();
847 kumpf 1.43 moduleFound = true;
848 }
849 }
850
851 // if _PROPERTY_PROVIDERMODULE_NAME key not found
852 if( !moduleFound)
853 {
|
854 humberto 1.53 //l10n 485
|
855 humberto 1.48 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
856 //"key Name was not found");
857 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,MessageLoaderParms(
|
858 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.NAME_KEY_NOT_FOUND",
859 "key Name was not found"));
|
860 kumpf 1.43 }
861
862 //
863 // disable the provider module
864 //
865 try
866 {
|
867 kumpf 1.51 Sint16 ret_value = _disableModule(instanceReference, moduleName, false, al);
868
|
869 kumpf 1.43 //
870 // if the provider module disable failed
871 //
|
872 chuck 1.47 // l10n
|
873 kumpf 1.51 if (ret_value == -1)
|
874 kumpf 1.43 {
|
875 humberto 1.48 //l10n
876 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
877 //"disable the provider module failed.");
878 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
879 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.DISABLE_PROVIDER_MODULE_FAILED",
880 "disable the provider module failed."));
|
881 kumpf 1.43 }
|
882 kumpf 1.51
883 //
884 // The provider module disable failed since there are pending requests
885 //
886 if (ret_value == -2)
887 {
888 //L10N TODO
|
889 humberto 1.52 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
890 // "disable the provider module failed: Provider is busy.");
891 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
892 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.DISABLE_PROVIDER_MODULE_FAILED_PROVIDER_BUSY",
893 "disable the provider module failed: Provider is busy."));
|
894 kumpf 1.51 }
|
895 kumpf 1.43 }
896 catch(CIMException& e)
897 {
898 throw (e);
899 }
900 }
901
|
902 kumpf 1.1 try
903 {
904 _providerRegistrationManager->deleteInstance(instanceReference);
905 }
906 catch(CIMException& e)
907 {
|
908 kumpf 1.26 throw (e);
|
909 kumpf 1.1 }
910
911 // complete processing the request
912 handler.complete();
913 }
914
915 // Block a provider, unblock a provider, and stop a provider
916 void ProviderRegistrationProvider::invokeMethod(
917 const OperationContext & context,
|
918 kumpf 1.13 const CIMObjectPath & objectReference,
|
919 kumpf 1.28 const CIMName & methodName,
|
920 kumpf 1.1 const Array<CIMParamValue> & inParameters,
|
921 kumpf 1.33 MethodResultResponseHandler & handler)
|
922 kumpf 1.1 {
|
923 kumpf 1.15 // get userName and only privileged user can execute this operation
|
924 kumpf 1.19 String userName;
925 try
926 {
|
927 kumpf 1.37 IdentityContainer container = context.get(IdentityContainer::NAME);
|
928 kumpf 1.19 userName = container.getUserName();
929 }
930 catch (...)
931 {
932 userName = String::EMPTY;
933 }
|
934 kumpf 1.15
|
935 chip 1.24 if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
|
936 mday 1.17 {
|
937 humberto 1.48 //l10n
938 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,
939 //"You must have superuser privilege to disable or enable providers.");
940 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED,MessageLoaderParms(
941 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.SUPERUSER_PRIVILEGE_REQUIRED_DISABLE_ENABLE_PROVIDERS",
942 "You must have superuser privilege to disable or enable providers."));
|
943 mday 1.17 }
|
944 kumpf 1.15
|
945 kumpf 1.36 if(!objectReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
|
946 kumpf 1.10 {
|
947 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
948 objectReference.getNameSpace().getString());
|
949 kumpf 1.10 }
950
|
951 chuck 1.47
952 // l10n
953 // Get the client's list of preferred languages for the response
954 AcceptLanguages al = AcceptLanguages::EMPTY;
955 try
956 {
957 AcceptLanguageListContainer al_container =
958 (AcceptLanguageListContainer)context.get(AcceptLanguageListContainer::NAME);
959 al = al_container.getLanguages();
960 }
961 catch (...)
962 {
963 ; // Leave AcceptLanguages empty
964 }
965
|
966 kumpf 1.5 String moduleName;
967 Boolean moduleFound = false;
|
968 kumpf 1.3
|
969 kumpf 1.5 // get module name from reference
|
970 kumpf 1.35 Array<CIMKeyBinding> keys = objectReference.getKeyBindings();
|
971 kumpf 1.1
|
972 kumpf 1.5 for(Uint32 i=0; i<keys.size() ; i++)
|
973 kumpf 1.1 {
|
974 kumpf 1.36 if(keys[i].getName().equal (_PROPERTY_PROVIDERMODULE_NAME))
|
975 kumpf 1.1 {
|
976 kumpf 1.5 moduleName = keys[i].getValue();
977 moduleFound = true;
|
978 kumpf 1.1 }
979 }
980
|
981 kumpf 1.5 // if _PROPERTY_PROVIDERMODULE_NAME key not found
982 if( !moduleFound)
|
983 kumpf 1.1 {
|
984 humberto 1.53 //l10n 485
|
985 humberto 1.48 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,MessageLoaderParms(
|
986 humberto 1.53 "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.NAME_KEY_NOT_FOUND",
987 "key Name was not found"));
|
988 kumpf 1.1 }
989
|
990 kumpf 1.5 handler.processing();
991
992 Sint16 ret_value;
|
993 kumpf 1.1
|
994 kumpf 1.28 if(methodName.equal(_STOP_PROVIDER))
|
995 kumpf 1.1 {
|
996 kumpf 1.43 // disable module
997 try
|
998 kumpf 1.8 {
|
999 chuck 1.47 // l10n
1000 ret_value = _disableModule(objectReference, moduleName, false, al);
|
1001 kumpf 1.8 }
|
1002 kumpf 1.43 catch(CIMException& e)
1003 {
1004 throw (e);
1005 }
|
1006 kumpf 1.8
|
1007 kumpf 1.5 CIMValue retValue(ret_value);
1008 handler.deliver(retValue);
1009 handler.complete();
1010 return;
|
1011 kumpf 1.1 }
|
1012 kumpf 1.28 else if(methodName.equal(_START_PROVIDER))
|
1013 kumpf 1.1 {
|
1014 kumpf 1.43 //
1015 // get module status
1016 //
1017 Array<Uint16> _OperationalStatus =
1018 _providerRegistrationManager->getProviderModuleStatus( moduleName);
1019
|
1020 kumpf 1.5 for (Uint32 i = 0; i<_OperationalStatus.size(); i++)
|
1021 kumpf 1.1 {
|
1022 kumpf 1.5 // retValue equals 1 if module is already enabled
|
1023 chip 1.24 if (_OperationalStatus[i] == _MODULE_OK)
|
1024 kumpf 1.5 {
1025 ret_value = 1;
1026 CIMValue retValue(ret_value);
1027 handler.deliver(retValue);
1028 handler.complete();
1029 return;
|
1030 kumpf 1.14 }
1031
1032 // retValue equals 2 if module is stopping
1033 // at this stage, module can not be started
1034 if (_OperationalStatus[i] == _MODULE_STOPPING)
1035 {
1036 ret_value = 2;
1037 CIMValue retValue(ret_value);
1038 handler.deliver(retValue);
1039 handler.complete();
1040 return;
|
1041 kumpf 1.5 }
|
1042 kumpf 1.1 }
|
1043 kumpf 1.5
|
1044 kumpf 1.43 // get module instance
1045 CIMInstance mInstance =
1046 _providerRegistrationManager->getInstance(objectReference);
1047
|
1048 chip 1.24 //
|
1049 kumpf 1.5 // get provider manager service
1050 //
1051 MessageQueueService * _service = _getProviderManagerService();
1052
|
1053 kumpf 1.15 if (_service != NULL)
1054 {
1055 // create CIMEnableModuleRequestMessage
|
1056 chip 1.24 CIMEnableModuleRequestMessage * enable_req =
|
1057 kumpf 1.15 new CIMEnableModuleRequestMessage(
1058 XmlWriter::getNextMessageId (),
|
1059 kumpf 1.25 mInstance,
|
1060 kumpf 1.15 QueueIdStack(_service->getQueueId()));
|
1061 chuck 1.47 // l10n
1062 enable_req->acceptLanguages = al;
|
1063 kumpf 1.5
|
1064 kumpf 1.15 Array<Uint16> _opStatus;
1065 _opStatus = _sendEnableMessageToProviderManager(enable_req);
|
1066 kumpf 1.5
|
1067 kumpf 1.15 for (Uint32 i = 0; i<_opStatus.size(); i++)
|
1068 kumpf 1.5 {
|
1069 kumpf 1.15 if (_opStatus[i] == _MODULE_OK)
1070 {
1071 // module was enabled successfully
1072 ret_value = 0;
1073 CIMValue retValue(ret_value);
1074 handler.deliver(retValue);
1075 handler.complete();
1076 return;
1077 }
|
1078 kumpf 1.5 }
1079 }
1080
1081 // enable failed
1082 ret_value = -1;
1083 CIMValue retValue(ret_value);
1084 handler.deliver(retValue);
1085 handler.complete();
1086 return;
|
1087 kumpf 1.1 }
1088 else
1089 {
|
1090 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_METHOD_NOT_AVAILABLE, String::EMPTY);
|
1091 kumpf 1.1 }
|
1092 kumpf 1.5 }
1093
1094 // get provider manager service
1095 MessageQueueService * ProviderRegistrationProvider::_getProviderManagerService()
1096 {
1097 MessageQueue * queue = MessageQueue::lookup(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP);
1098 MessageQueueService * _service = dynamic_cast<MessageQueueService *>(queue);
1099
|
1100 chip 1.24 return(_service);
|
1101 kumpf 1.5 }
1102
1103 ProviderRegistrationProvider & ProviderRegistrationProvider::operator=(const ProviderRegistrationProvider & handle)
1104 {
1105 if(this == &handle)
1106 {
1107 return(*this);
1108 }
1109
1110 return(*this);
1111 }
|
1112 kumpf 1.1
|
1113 kumpf 1.5 Array<Uint16> ProviderRegistrationProvider::_sendDisableMessageToProviderManager(
1114 CIMDisableModuleRequestMessage * disable_req)
1115 {
1116 MessageQueueService * _service = _getProviderManagerService();
1117 Uint32 _queueId = _service->getQueueId();
1118
1119 callback_data *cb_data = new callback_data(this);
1120
1121 // create request envelope
1122 AsyncLegacyOperationStart * asyncRequest =
1123 new AsyncLegacyOperationStart (
1124 _service->get_next_xid(),
1125 NULL,
1126 _queueId,
1127 disable_req,
1128 _queueId);
1129
|
1130 kumpf 1.8 AsyncReply * asyncReply = _controller->ClientSendWait(*_client_handle,
1131 _queueId,
1132 asyncRequest);
|
1133 kumpf 1.10 CIMDisableModuleResponseMessage * response =
1134 reinterpret_cast<CIMDisableModuleResponseMessage *>(
|
1135 kumpf 1.8 (static_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result());
1136 if (response->cimException.getCode() != CIM_ERR_SUCCESS)
1137 {
1138 CIMException e = response->cimException;
1139 delete asyncRequest;
1140 delete asyncReply;
1141 delete response;
1142 throw (e);
1143 }
|
1144 kumpf 1.5
|
1145 chip 1.24 Array<Uint16> operationalStatus = response->operationalStatus;
|
1146 kumpf 1.8
1147 delete asyncRequest;
1148 delete asyncReply;
1149 delete response;
|
1150 mday 1.16
|
1151 kumpf 1.5 return(operationalStatus);
1152 }
1153
1154 Array<Uint16> ProviderRegistrationProvider::_sendEnableMessageToProviderManager(
1155 CIMEnableModuleRequestMessage * enable_req)
1156 {
1157 MessageQueueService * _service = _getProviderManagerService();
1158 Uint32 _queueId = _service->getQueueId();
1159
1160 callback_data *cb_data = new callback_data(this);
1161
1162 // create request envelope
1163 AsyncLegacyOperationStart * asyncRequest =
1164 new AsyncLegacyOperationStart (
1165 _service->get_next_xid(),
1166 NULL,
1167 _queueId,
1168 enable_req,
1169 _queueId);
1170
|
1171 kumpf 1.8 AsyncReply * asyncReply = _controller->ClientSendWait(*_client_handle,
1172 _queueId,
1173 asyncRequest);
1174 CIMEnableModuleResponseMessage * response =
1175 reinterpret_cast<CIMEnableModuleResponseMessage *>(
1176 (static_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result());
1177 if (response->cimException.getCode() != CIM_ERR_SUCCESS)
1178 {
1179 CIMException e = response->cimException;
1180 delete asyncRequest;
1181 delete asyncReply;
1182 delete response;
1183 throw (e);
1184 }
1185
|
1186 chip 1.24 Array<Uint16> operationalStatus = response->operationalStatus;
|
1187 kumpf 1.8
1188 delete asyncRequest;
1189 delete asyncReply;
1190 delete response;
|
1191 mday 1.16
|
1192 kumpf 1.5 return(operationalStatus);
|
1193 kumpf 1.6 }
1194
1195 // send termination message to subscription service
1196 void ProviderRegistrationProvider::_sendTerminationMessageToSubscription(
|
1197 kumpf 1.43 const CIMObjectPath & ref, const String & moduleName,
|
1198 chuck 1.47 const Boolean disableProviderOnly,
1199 const AcceptLanguages & al)
|
1200 kumpf 1.6 {
1201 CIMInstance instance;
1202 String _moduleName;
1203 Array<CIMInstance> instances;
1204
|
1205 kumpf 1.43 if (!disableProviderOnly)
1206 {
1207 CIMObjectPath reference("", PEGASUS_NAMESPACENAME_INTEROP,
1208 PEGASUS_CLASSNAME_PROVIDER, ref.getKeyBindings());
|
1209 chip 1.24
|
1210 kumpf 1.43 Array<CIMObjectPath> instanceNames =
1211 _providerRegistrationManager->enumerateInstanceNames(reference);
|
1212 kumpf 1.6
|
1213 kumpf 1.43 // find all the instances which have same module name as moduleName
1214 for (Uint32 i = 0, n=instanceNames.size(); i < n; i++)
1215 {
|
1216 kumpf 1.42 //
1217 // get provider module name from reference
1218 //
1219
1220 Array<CIMKeyBinding> keys = instanceNames[i].getKeyBindings();
1221
1222 for(Uint32 j=0; j < keys.size(); j++)
1223 {
1224 if(keys[j].getName().equal (_PROPERTY_PROVIDERMODULENAME))
1225 {
1226 _moduleName = keys[j].getValue();
1227 }
1228 }
|
1229 kumpf 1.6
|
1230 kumpf 1.43 if (String::equalNoCase(moduleName, _moduleName))
1231 {
1232 reference.setKeyBindings(keys);
1233 instance = _providerRegistrationManager->getInstance(reference);
1234 instances.append(instance);
1235 }
1236 }
1237 }
1238 else
1239 {
1240 instance = _providerRegistrationManager->getInstance(ref);
|
1241 kumpf 1.6 instances.append(instance);
1242 }
1243
1244 //
1245 // get indication server queueId
1246 //
1247 MessageQueueService * _service = _getIndicationService();
1248
|
1249 kumpf 1.15 if (_service != NULL)
1250 {
1251 Uint32 _queueId = _service->getQueueId();
|
1252 kumpf 1.6
|
1253 kumpf 1.15 CIMNotifyProviderTerminationRequestMessage * termination_req =
1254 new CIMNotifyProviderTerminationRequestMessage(
1255 XmlWriter::getNextMessageId (),
1256 instances,
1257 QueueIdStack(_service->getQueueId()));
1258
|
1259 chuck 1.47 // l10n
1260 termination_req->acceptLanguages = al;
1261
|
1262 kumpf 1.15 // create request envelope
1263 AsyncLegacyOperationStart * asyncRequest =
1264 new AsyncLegacyOperationStart (
|
1265 kumpf 1.6 _service->get_next_xid(),
1266 NULL,
1267 _queueId,
1268 termination_req,
1269 _queueId);
1270
|
1271 kumpf 1.15 if( false == _controller->ClientSendForget(
|
1272 kumpf 1.6 *_client_handle,
1273 _queueId,
1274 asyncRequest))
|
1275 kumpf 1.15 {
1276 delete asyncRequest;
|
1277 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_FOUND, String::EMPTY);
|
1278 kumpf 1.15 }
|
1279 kumpf 1.6 }
1280 }
1281
1282 // get indication service
1283 MessageQueueService * ProviderRegistrationProvider::_getIndicationService()
1284 {
1285 MessageQueue * queue = MessageQueue::lookup(
1286 PEGASUS_QUEUENAME_INDICATIONSERVICE);
1287
1288 MessageQueueService * _service =
1289 dynamic_cast<MessageQueueService *>(queue);
1290 return(_service);
|
1291 kumpf 1.43 }
1292
1293 // disable provider module, return 0 if module is disabled successfully,
|
1294 kumpf 1.51 // return 1 if module is already disabled, return -2 if module can not be
1295 // disabled since there are pending requests, otherwise, return -1
|
1296 kumpf 1.43 Sint16 ProviderRegistrationProvider::_disableModule(
1297 const CIMObjectPath & objectReference,
1298 const String & moduleName,
|
1299 chuck 1.47 Boolean disableProviderOnly,
1300 const AcceptLanguages & al) // l10n
|
1301 kumpf 1.43 {
1302 //
1303 // get module status
1304 //
1305 Array<Uint16> _OperationalStatus =
1306 _providerRegistrationManager->getProviderModuleStatus( moduleName);
1307
1308 for (Uint32 i = 0; i<_OperationalStatus.size(); i++)
1309 {
1310 // retValue equals 1 if module is already disabled
1311 if (_OperationalStatus[i] == _MODULE_STOPPED ||
1312 _OperationalStatus[i] == _MODULE_STOPPING)
1313 {
1314 return (1);
1315 }
1316 }
1317
1318 CIMInstance instance;
1319 Array<CIMInstance> instances;
1320 CIMInstance mInstance;
1321 String _moduleName;
1322 kumpf 1.43 Uint16 providers;
1323 CIMObjectPath providerRef;
1324
1325 // disable a provider module or delete a provider module
1326 if (!disableProviderOnly)
1327 {
1328 providerRef = CIMObjectPath(objectReference.getHost(),
1329 objectReference.getNameSpace(),
1330 PEGASUS_CLASSNAME_PROVIDER,
1331 objectReference.getKeyBindings());
1332
1333 // get module instance
1334 mInstance =
1335 _providerRegistrationManager->getInstance(objectReference);
1336
1337 }
1338 else // disable a provider
1339 {
1340 // get module instance
1341 Array <CIMKeyBinding> moduleKeyBindings;
1342 moduleKeyBindings.append (CIMKeyBinding
1343 kumpf 1.43 (_PROPERTY_PROVIDERMODULE_NAME, moduleName,
1344 CIMKeyBinding::STRING));
1345
1346 CIMObjectPath moduleRef(objectReference.getHost(),
1347 objectReference.getNameSpace(),
1348 PEGASUS_CLASSNAME_PROVIDERMODULE,
1349 moduleKeyBindings);
1350
1351 mInstance =
1352 _providerRegistrationManager->getInstance(moduleRef);
1353 }
1354
1355 if (!disableProviderOnly)
1356 {
1357 // get all provider instances which have same module name as
1358 // moduleName
1359 Array<CIMObjectPath> instanceNames =
1360 _providerRegistrationManager->enumerateInstanceNames(providerRef);
1361
1362 for(Uint32 i = 0, n=instanceNames.size(); i < n; i++)
1363 {
1364 kumpf 1.43 //
1365 // get provider module name from reference
1366 //
1367
1368 Array<CIMKeyBinding> keys = instanceNames[i].getKeyBindings();
1369
1370 for(Uint32 j=0; j < keys.size(); j++)
1371 {
1372 if(keys[j].getName().equal (_PROPERTY_PROVIDERMODULENAME))
1373 {
1374 _moduleName = keys[j].getValue();
1375 }
1376 }
1377
1378 if (String::equalNoCase(_moduleName, moduleName))
1379 {
1380 providerRef.setKeyBindings(keys);
1381 instance = _providerRegistrationManager->getInstance
1382 (providerRef);
1383 instances.append(instance);
1384 }
1385 kumpf 1.43
1386 }
1387 }
1388 else
1389 {
1390 instances.append(_providerRegistrationManager->getInstance
1391 (objectReference));
1392 }
1393
1394 //
1395 // get provider manager service
1396 //
1397 MessageQueueService * _service = _getProviderManagerService();
1398
1399 if (_service != NULL)
1400 {
1401 // create CIMDisableModuleRequestMessage
1402 CIMDisableModuleRequestMessage * disable_req =
1403 new CIMDisableModuleRequestMessage(
1404 XmlWriter::getNextMessageId (),
1405 mInstance,
1406 kumpf 1.43 instances,
1407 disableProviderOnly,
1408 QueueIdStack(_service->getQueueId()));
|
1409 chuck 1.47 // l10n
1410 disable_req->acceptLanguages = al;
|
1411 kumpf 1.43
1412 Array<Uint16> _opStatus =
1413 _sendDisableMessageToProviderManager(disable_req);
1414
1415 if (!disableProviderOnly) // disable provider module
1416 {
1417 for (Uint32 i = 0; i<_opStatus.size(); i++)
1418 {
1419 // module was disabled successfully
1420 if (_opStatus[i] == _MODULE_STOPPED)
1421 {
1422 // send termination message to subscription service
1423 _sendTerminationMessageToSubscription(objectReference,
|
1424 chuck 1.47 moduleName, false, al);
|
1425 kumpf 1.43 return (0);
1426 }
|
1427 kumpf 1.51
1428 // module is not disabled since there are pending
1429 // requests for the providers in the module
1430 if (_opStatus[i] == _MODULE_OK)
1431 {
1432 return (-2);
1433 }
|
1434 kumpf 1.43 }
1435 }
1436 else // disable provider
1437 {
1438 _sendTerminationMessageToSubscription(objectReference,
|
1439 chuck 1.47 moduleName, true, al);
|
1440 kumpf 1.43 return (0);
1441 }
1442 }
1443
1444 // disable failed
1445 return (-1);
|
1446 kumpf 1.1 }
1447
1448 PEGASUS_NAMESPACE_END
|