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 kumpf 1.1
43 PEGASUS_NAMESPACE_BEGIN
44
45 /**
46 The name of the operational status property
47 */
|
48 kumpf 1.36 static const CIMName _PROPERTY_OPERATIONALSTATUS =
49 CIMName ("OperationalStatus");
|
50 kumpf 1.1
51 /**
52 The name of the name property for PG_Provider class
53 */
|
54 kumpf 1.36 static const CIMName _PROPERTY_PROVIDER_NAME = CIMName ("Name");
|
55 kumpf 1.1
56 /**
57 The name of the Name property for PG_ProviderModule class
58 */
|
59 kumpf 1.36 static const CIMName _PROPERTY_PROVIDERMODULE_NAME = CIMName ("Name");
|
60 kumpf 1.1
61 /**
|
62 kumpf 1.12 The name of the Vendor property for PG_ProviderModule class
63 */
|
64 kumpf 1.36 static const CIMName _PROPERTY_VENDOR = CIMName ("Vendor");
|
65 kumpf 1.12
66 /**
|
67 kumpf 1.1 The name of the Version property for PG_ProviderModule class
68 */
|
69 kumpf 1.36 static const CIMName _PROPERTY_VERSION = CIMName ("Version");
|
70 kumpf 1.1
71 /**
72 The name of the interface type property for PG_ProviderModule class
73 */
|
74 kumpf 1.36 static const CIMName _PROPERTY_INTERFACETYPE = CIMName ("InterfaceType");
|
75 kumpf 1.1
76 /**
77 The name of the interface version property for PG_ProviderModule class
78 */
|
79 kumpf 1.36 static const CIMName _PROPERTY_INTERFACEVERSION = CIMName ("InterfaceVersion");
|
80 kumpf 1.1
81 /**
82 The name of the location property for PG_ProviderModule class
83 */
|
84 kumpf 1.36 static const CIMName _PROPERTY_LOCATION = CIMName ("Location");
|
85 kumpf 1.1
86 /**
87 The name of the CapabilityID property for provider capabilities class
88 */
|
89 kumpf 1.36 static const CIMName _PROPERTY_CAPABILITYID = CIMName ("CapabilityID");
|
90 kumpf 1.1
91 /**
92 The name of the provider module name property for provider capabilities class
93 */
|
94 kumpf 1.36 static const CIMName _PROPERTY_PROVIDERMODULENAME =
95 CIMName ("ProviderModuleName");
|
96 kumpf 1.1
97 /**
98 The name of the provider name property for provider capabilities class
99 */
|
100 kumpf 1.36 static const CIMName _PROPERTY_PROVIDERNAME = CIMName ("ProviderName");
|
101 kumpf 1.1
102 /**
103 The name of the classname property for provider capabilities class
104 */
|
105 kumpf 1.36 static const CIMName _PROPERTY_CLASSNAME = CIMName ("ClassName");
|
106 kumpf 1.1
107 /**
108 The name of the Namespace property for provider capabilities class
109 */
|
110 kumpf 1.36 static const CIMName _PROPERTY_NAMESPACES = CIMName ("Namespaces");
|
111 kumpf 1.1
112 /**
113 The name of the provider type property for provider capabilities class
114 */
|
115 kumpf 1.36 static const CIMName _PROPERTY_PROVIDERTYPE = CIMName ("ProviderType");
|
116 kumpf 1.1
117 /**
118 The name of the supported properties property for provider capabilities class
119 */
|
120 kumpf 1.36 static const CIMName _PROPERTY_SUPPORTEDPROPERTIES =
121 CIMName ("SupportedProperties");
|
122 kumpf 1.1
123 /**
124 The name of the supported methods property for provider capabilities class
125 */
|
126 kumpf 1.36 static const CIMName _PROPERTY_SUPPORTEDMETHODS = CIMName ("SupportedMethods");
|
127 kumpf 1.1
128 /**
129 Registered instance provider type
130 */
131 static const Uint16 _INSTANCE_PROVIDER = 2;
132
133 /**
134 Registered association provider type
135 */
136 static const Uint16 _ASSOCIATION_PROVIDER = 3;
137
138 /**
139 Registered indication provider type
140 */
141 static const Uint16 _INDICATION_PROVIDER = 4;
142
143 /**
144 Registered method provider type
145 */
146 static const Uint16 _METHOD_PROVIDER = 5;
147
148 kumpf 1.1 /**
149 stopping provider method
150 */
|
151 kumpf 1.36 static const CIMName _STOP_PROVIDER = CIMName ("Stop");
|
152 kumpf 1.1
153 /**
154 starting provider method
155 */
|
156 kumpf 1.36 static const CIMName _START_PROVIDER = CIMName ("Start");
|
157 kumpf 1.1
158 /**
159 Provider status
160 */
|
161 kumpf 1.14 static const Uint16 _MODULE_OK = 2;
|
162 kumpf 1.10
|
163 kumpf 1.14 static const Uint16 _MODULE_STOPPING = 9;
|
164 kumpf 1.1
|
165 kumpf 1.10 static const Uint16 _MODULE_STOPPED = 10;
|
166 kumpf 1.1
167 ProviderRegistrationProvider::ProviderRegistrationProvider(
168 ProviderRegistrationManager * providerRegistrationManager)
|
169 kumpf 1.6 :_id(peg_credential_types::PROVIDER)
|
170 kumpf 1.1 {
171 _providerRegistrationManager = providerRegistrationManager;
|
172 kumpf 1.6
173 _controller = &(ModuleController::get_client_handle(_id, &_client_handle));
174 if(_client_handle == NULL)
|
175 kumpf 1.32 throw UninitializedObjectException();
|
176 kumpf 1.1 }
177
178 ProviderRegistrationProvider::~ProviderRegistrationProvider(void)
179 {
|
180 kumpf 1.6 if (_providerRegistrationManager)
181 {
182 delete _providerRegistrationManager;
183 }
184
185 if (_client_handle)
186 {
187 delete _client_handle;
188 }
189
|
190 kumpf 1.1 }
191
192 void ProviderRegistrationProvider::initialize(CIMOMHandle & cimom)
193 {
194 // This method should not be called because this is a control provider
195 // and is not dynamically loaded through the provider manager
196 }
197
198 void ProviderRegistrationProvider::terminate(void)
199 {
200 }
201
202 // get registered provider
203 void ProviderRegistrationProvider::getInstance(
204 const OperationContext & context,
|
205 kumpf 1.13 const CIMObjectPath & instanceReference,
|
206 kumpf 1.34 const Boolean includeQualifiers,
207 const Boolean includeClassOrigin,
|
208 kumpf 1.2 const CIMPropertyList & propertyList,
|
209 kumpf 1.33 InstanceResponseHandler & handler)
|
210 kumpf 1.1 {
211
|
212 kumpf 1.36 if(!instanceReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
|
213 kumpf 1.10 {
|
214 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
|
215 kumpf 1.36 instanceReference.getNameSpace().getString());
|
216 kumpf 1.10 }
217
|
218 kumpf 1.1 // ensure the class existing in the specified namespace
|
219 kumpf 1.36 CIMName className = instanceReference.getClassName();
|
220 kumpf 1.1
|
221 kumpf 1.36 if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
222 !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
223 !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
|
224 kumpf 1.1 {
|
225 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
226 className.getString());
|
227 kumpf 1.1 }
228
229 // begin processing the request
230 handler.processing();
231
232 CIMInstance instance;
233
234 try
235 {
236 instance = _providerRegistrationManager->getInstance(instanceReference);
237 }
238 catch(CIMException& e)
239 {
|
240 kumpf 1.26 throw (e);
|
241 kumpf 1.1 }
242
243 handler.deliver(instance);
244
245 // complete processing the request
246 handler.complete();
247 }
248
249 // get all registered providers
250 void ProviderRegistrationProvider::enumerateInstances(
251 const OperationContext & context,
|
252 kumpf 1.13 const CIMObjectPath & classReference,
|
253 kumpf 1.34 const Boolean includeQualifiers,
254 const Boolean includeClassOrigin,
|
255 kumpf 1.2 const CIMPropertyList & propertyList,
|
256 kumpf 1.33 InstanceResponseHandler & handler)
|
257 kumpf 1.1 {
|
258 kumpf 1.36 if(!classReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
|
259 kumpf 1.10 {
|
260 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
261 classReference.getNameSpace().getString());
|
262 kumpf 1.10 }
263
|
264 kumpf 1.1 // ensure the class existing in the specified namespace
|
265 kumpf 1.36 CIMName className = classReference.getClassName();
|
266 kumpf 1.1
|
267 kumpf 1.36 if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
268 !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
269 !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
|
270 kumpf 1.1 {
|
271 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
272 className.getString());
|
273 kumpf 1.1 }
274
275 // begin processing the request
276 handler.processing();
277
|
278 kumpf 1.20 Array<CIMInstance> enumInstances;
|
279 kumpf 1.1
280 try
281 {
282 enumInstances = _providerRegistrationManager->enumerateInstances(classReference);
283 }
284 catch(CIMException& e)
285 {
|
286 kumpf 1.26 throw (e);
|
287 kumpf 1.1 }
288
|
289 kumpf 1.21 handler.deliver(enumInstances);
|
290 kumpf 1.1
291 // complete processing the request
292 handler.complete();
293 }
294
295 // get all registered provider names
296 void ProviderRegistrationProvider::enumerateInstanceNames(
297 const OperationContext & context,
|
298 kumpf 1.13 const CIMObjectPath & classReference,
|
299 kumpf 1.33 ObjectPathResponseHandler & handler)
|
300 kumpf 1.1 {
|
301 kumpf 1.36 if(!classReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
|
302 kumpf 1.10 {
|
303 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
304 classReference.getNameSpace().getString());
|
305 kumpf 1.10 }
306
|
307 kumpf 1.1 // ensure the class existing in the specified namespace
|
308 kumpf 1.36 CIMName className = classReference.getClassName();
|
309 kumpf 1.1
|
310 kumpf 1.36 if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
311 !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
312 !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
|
313 kumpf 1.1 {
|
314 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
315 className.getString());
|
316 kumpf 1.1 }
317
318 // begin processing the request
319 handler.processing();
320
|
321 kumpf 1.13 Array<CIMObjectPath> enumInstanceNames;
|
322 kumpf 1.1
323 // get all instance names from repository
324 try
325 {
326 enumInstanceNames =
327 _providerRegistrationManager->enumerateInstanceNames(classReference);
328 }
329 catch(CIMException& e)
330 {
|
331 kumpf 1.26 throw (e);
|
332 kumpf 1.1 }
333
334 handler.deliver(enumInstanceNames);
335
336 // complete processing the request
337 handler.complete();
338 }
339
340 // change properties for the registered provider
|
341 chip 1.24 // only support to change property of Namespaces, property of
|
342 kumpf 1.1 // SupportedProperties, and property of SupportedMethods
343 void ProviderRegistrationProvider::modifyInstance(
|
344 kumpf 1.15 const OperationContext & context,
|
345 kumpf 1.13 const CIMObjectPath & instanceReference,
|
346 kumpf 1.1 const CIMInstance & instanceObject,
|
347 kumpf 1.34 const Boolean includeQualifiers,
|
348 kumpf 1.2 const CIMPropertyList & propertyList,
|
349 kumpf 1.33 ResponseHandler & 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 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,
|
366 kumpf 1.15 "You must have superuser privilege to modify the registration.");
367 }
368
|
369 kumpf 1.36 if(!instanceReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
|
370 kumpf 1.10 {
|
371 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
372 instanceReference.getNameSpace().getString());
|
373 kumpf 1.10 }
374
|
375 kumpf 1.1 //
376 // only support to modify the instance of PG_ProviderCapabilities
377 //
|
378 kumpf 1.36 if (!instanceReference.getClassName().equal
379 (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES))
|
380 kumpf 1.1 {
|
381 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
382 instanceReference.getClassName().getString());
|
383 kumpf 1.1 }
384
385 //
|
386 kumpf 1.2 // only can modify the property of Namespaces, property of
|
387 kumpf 1.1 // SupportedProperties, and property of SupportedMethods
388 //
|
389 kumpf 1.2 if (propertyList.isNull())
|
390 kumpf 1.1 {
|
391 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
|
392 kumpf 1.12 "Only can modify Namespaces, SupportedProperties, and SupportedMethods.");
|
393 kumpf 1.2 }
394
|
395 kumpf 1.28 Array<CIMName> propertyArray = propertyList.getPropertyNameArray();
|
396 kumpf 1.2 for (Uint32 i=0; i<propertyArray.size(); i++)
397 {
|
398 kumpf 1.36 if (!propertyArray[i].equal (_PROPERTY_NAMESPACES) &&
399 !propertyArray[i].equal (_PROPERTY_SUPPORTEDPROPERTIES) &&
400 !propertyArray[i].equal (_PROPERTY_SUPPORTEDMETHODS))
|
401 kumpf 1.1 {
|
402 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
403 propertyArray[i].getString());
|
404 kumpf 1.2 }
|
405 kumpf 1.1 }
406
407 // begin processing the request
408 handler.processing();
409
410 try
411 {
|
412 chip 1.24 _providerRegistrationManager->modifyInstance(instanceReference,
|
413 kumpf 1.34 instanceObject, includeQualifiers, propertyArray);
|
414 kumpf 1.1 }
415 catch(CIMException& e)
416 {
|
417 kumpf 1.26 throw (e);
|
418 kumpf 1.1 }
419
420 // complete processing the request
421 handler.complete();
422 }
423
424 // register a provider
425 void ProviderRegistrationProvider::createInstance(
426 const OperationContext & context,
|
427 kumpf 1.13 const CIMObjectPath & instanceReference,
|
428 kumpf 1.1 const CIMInstance & instanceObject,
|
429 kumpf 1.33 ObjectPathResponseHandler & handler)
|
430 kumpf 1.1 {
|
431 kumpf 1.15 // get userName and only privileged user can execute this operation
|
432 kumpf 1.19 String userName;
433 try
434 {
|
435 kumpf 1.37 IdentityContainer container = context.get(IdentityContainer::NAME);
|
436 kumpf 1.19 userName = container.getUserName();
437 }
438 catch (...)
439 {
440 userName = String::EMPTY;
441 }
|
442 kumpf 1.15
|
443 chip 1.24 if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
|
444 kumpf 1.15 {
|
445 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,
|
446 kumpf 1.15 "You must have superuser privilege to register providers.");
447 }
448
|
449 kumpf 1.36 CIMName className = instanceReference.getClassName();
450 CIMNamespaceName nameSpace = instanceReference.getNameSpace();
|
451 kumpf 1.1
|
452 kumpf 1.13 CIMObjectPath returnReference;
|
453 kumpf 1.1
454 CIMInstance instance = instanceObject;
455
|
456 kumpf 1.36 if(!nameSpace.equal (PEGASUS_NAMESPACENAME_INTEROP))
|
457 kumpf 1.10 {
|
458 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
459 nameSpace.getString());
|
460 kumpf 1.10 }
461
|
462 kumpf 1.1 // ensure the class existing in the specified namespace
|
463 kumpf 1.36 if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
464 !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
465 !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
|
466 kumpf 1.1 {
|
467 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
468 className.getString());
|
469 kumpf 1.1 }
470
471 //
472 // Check all required properties are set
473 //
|
474 kumpf 1.36 if (className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
|
475 kumpf 1.1 {
476 //
477 // Name, Version, InterfaceType, InterfaceVersion, and Location
478 // properties must be set
479 // OperationalStatus property needs to be set. If not, set to default
480 //
|
481 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULE_NAME) ==
482 PEG_NOT_FOUND)
|
483 kumpf 1.1 {
|
484 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
|
485 kumpf 1.12 "Missing Name which is required property in PG_ProviderModule class.");
486 }
487
|
488 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_VENDOR) == PEG_NOT_FOUND)
|
489 kumpf 1.12 {
|
490 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
|
491 kumpf 1.12 "Missing Vendor which is required property in PG_ProviderModule class.");
|
492 kumpf 1.1 }
493
|
494 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_VERSION) == PEG_NOT_FOUND)
|
495 kumpf 1.1 {
|
496 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
|
497 kumpf 1.12 "Missing Version which is required property in PG_ProviderModule class.");
|
498 kumpf 1.1 }
499
|
500 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_INTERFACETYPE) ==
501 PEG_NOT_FOUND)
|
502 kumpf 1.1 {
|
503 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
|
504 kumpf 1.12 "Missing InterfaceType which is required property in PG_ProviderModule class.");
|
505 kumpf 1.1 }
506
|
507 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_INTERFACEVERSION) ==
508 PEG_NOT_FOUND)
|
509 kumpf 1.1 {
|
510 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
|
511 kumpf 1.12 "Missing InterfaceVersion which is required property in PG_ProviderModule class.");
|
512 kumpf 1.1 }
513
|
514 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_LOCATION) == PEG_NOT_FOUND)
|
515 kumpf 1.1 {
|
516 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
|
517 kumpf 1.12 "Missing Location which is required property in PG_ProviderModule class.");
|
518 kumpf 1.1 }
519
|
520 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_OPERATIONALSTATUS) ==
521 PEG_NOT_FOUND)
|
522 kumpf 1.1 {
523 Array<Uint16> _operationalStatus;
|
524 kumpf 1.14 _operationalStatus.append(_MODULE_OK);
|
525 kumpf 1.1 instance.addProperty (CIMProperty
526 (_PROPERTY_OPERATIONALSTATUS, _operationalStatus));
527 }
528 }
|
529 kumpf 1.36 else if (className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES))
|
530 kumpf 1.1 {
531 //
532 // ProviderModuleName, ProviderName, InstanceID, ClassName,
533 // Namespaces, and ProviderType properties must be set
534 //
535
|
536 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULENAME) ==
537 PEG_NOT_FOUND)
|
538 kumpf 1.1 {
|
539 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
|
540 kumpf 1.12 "Missing ProviderModuleName which is required property in PG_ProviderCapabilities class.");
|
541 kumpf 1.1 }
542
|
543 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_PROVIDERNAME) ==
544 PEG_NOT_FOUND)
|
545 kumpf 1.1 {
|
546 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
|
547 kumpf 1.12 "Missing ProviderName which is required property in PG_ProviderCapabilities class.");
|
548 kumpf 1.1 }
549
|
550 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_CAPABILITYID) ==
551 PEG_NOT_FOUND)
|
552 kumpf 1.1 {
|
553 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
|
554 kumpf 1.12 "Missing CapabilityID which is required property in PG_ProviderCapabilities class.");
|
555 kumpf 1.1 }
556
|
557 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_CLASSNAME) == PEG_NOT_FOUND)
|
558 kumpf 1.1 {
|
559 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
|
560 kumpf 1.12 "Missing ClassName which is required property in PG_ProviderCapabilities class.");
|
561 kumpf 1.1 }
562
|
563 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_NAMESPACES) == PEG_NOT_FOUND)
|
564 kumpf 1.1 {
|
565 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
|
566 kumpf 1.12 "Missing Namespaces which is required property in PG_ProviderCapabilities class.");
|
567 kumpf 1.1 }
568
|
569 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_PROVIDERTYPE) == PEG_NOT_FOUND)
|
570 kumpf 1.1 {
|
571 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
|
572 kumpf 1.12 "Missing ProviderType which is required property in PG_ProviderCapabilities class.");
|
573 kumpf 1.1 }
574 }
|
575 kumpf 1.10 else // PEGASUS_CLASSNAME_PROVIDER
|
576 kumpf 1.1 {
577 //
578 // Name and ProviderModuleName properties must be set
579 //
|
580 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_PROVIDER_NAME) == PEG_NOT_FOUND)
|
581 kumpf 1.1 {
|
582 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
|
583 kumpf 1.12 "Missing Name which is required property in PG_Provider class.");
|
584 kumpf 1.1 }
585
|
586 kumpf 1.27 if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULENAME) ==
587 PEG_NOT_FOUND)
|
588 kumpf 1.1 {
|
589 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
|
590 kumpf 1.12 "Missing ProviderModuleName which is required property in PG_Provider class.");
|
591 kumpf 1.1 }
592 }
593
594 // begin processing the request
595 handler.processing();
596
597 try
598 {
599 returnReference =
600 _providerRegistrationManager->createInstance(instanceReference, instance);
601 }
602 catch(CIMException& e)
603 {
|
604 kumpf 1.26 throw (e);
|
605 kumpf 1.1 }
606
607 handler.deliver(returnReference);
608
609 // complete processing request
610 handler.complete();
611 }
612
613 // Unregister a provider
614 void ProviderRegistrationProvider::deleteInstance(
615 const OperationContext & context,
|
616 kumpf 1.13 const CIMObjectPath & instanceReference,
|
617 kumpf 1.33 ResponseHandler & handler)
|
618 kumpf 1.1 {
|
619 kumpf 1.15 // get userName and only privileged user can execute this operation
|
620 kumpf 1.19 String userName;
621 try
622 {
|
623 kumpf 1.37 IdentityContainer container = context.get(IdentityContainer::NAME);
|
624 kumpf 1.19 userName = container.getUserName();
625 }
626 catch (...)
627 {
628 userName = String::EMPTY;
629 }
|
630 kumpf 1.15
|
631 chip 1.24 if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
|
632 kumpf 1.15 {
|
633 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,
|
634 kumpf 1.15 "You must have superuser privilege to unregister providers.");
635 }
636
|
637 kumpf 1.36 if(!instanceReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
|
638 kumpf 1.10 {
|
639 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
640 instanceReference.getNameSpace().getString());
|
641 kumpf 1.10 }
642
|
643 kumpf 1.36 CIMName className = instanceReference.getClassName();
|
644 kumpf 1.1
645 // ensure the class existing in the specified namespace
|
646 kumpf 1.36 if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
647 !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
648 !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
|
649 kumpf 1.1 {
|
650 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
651 className.getString());
|
652 kumpf 1.1 }
653
654 // begin processing the request
655 handler.processing();
656
657 try
658 {
659 _providerRegistrationManager->deleteInstance(instanceReference);
660 }
661 catch(CIMException& e)
662 {
|
663 kumpf 1.26 throw (e);
|
664 kumpf 1.1 }
665
666 // complete processing the request
667 handler.complete();
668 }
669
670 // Block a provider, unblock a provider, and stop a provider
671 void ProviderRegistrationProvider::invokeMethod(
672 const OperationContext & context,
|
673 kumpf 1.13 const CIMObjectPath & objectReference,
|
674 kumpf 1.28 const CIMName & methodName,
|
675 kumpf 1.1 const Array<CIMParamValue> & inParameters,
|
676 kumpf 1.33 MethodResultResponseHandler & handler)
|
677 kumpf 1.1 {
|
678 kumpf 1.15 // get userName and only privileged user can execute this operation
|
679 kumpf 1.19 String userName;
680 try
681 {
|
682 kumpf 1.37 IdentityContainer container = context.get(IdentityContainer::NAME);
|
683 kumpf 1.19 userName = container.getUserName();
684 }
685 catch (...)
686 {
687 userName = String::EMPTY;
688 }
|
689 kumpf 1.15
|
690 chip 1.24 if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
|
691 mday 1.17 {
|
692 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,
|
693 mday 1.17 "You must have superuser privilege to disable or enable providers.");
694 }
|
695 kumpf 1.15
|
696 kumpf 1.36 if(!objectReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
|
697 kumpf 1.10 {
|
698 kumpf 1.36 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
699 objectReference.getNameSpace().getString());
|
700 kumpf 1.10 }
701
|
702 kumpf 1.5 String moduleName;
703 Boolean moduleFound = false;
|
704 kumpf 1.3
|
705 kumpf 1.5 // get module name from reference
|
706 kumpf 1.35 Array<CIMKeyBinding> keys = objectReference.getKeyBindings();
|
707 kumpf 1.1
|
708 kumpf 1.5 for(Uint32 i=0; i<keys.size() ; i++)
|
709 kumpf 1.1 {
|
710 kumpf 1.36 if(keys[i].getName().equal (_PROPERTY_PROVIDERMODULE_NAME))
|
711 kumpf 1.1 {
|
712 kumpf 1.5 moduleName = keys[i].getValue();
713 moduleFound = true;
|
714 kumpf 1.1 }
715 }
716
|
717 kumpf 1.5 // if _PROPERTY_PROVIDERMODULE_NAME key not found
718 if( !moduleFound)
|
719 kumpf 1.1 {
720 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
721 "key Name was not found");
722 }
723
|
724 kumpf 1.5 //
725 // get module status
726 //
|
727 chip 1.24 Array<Uint16> _OperationalStatus =
|
728 kumpf 1.5 _providerRegistrationManager->getProviderModuleStatus( moduleName);
729
|
730 kumpf 1.25 // get module instance
731 CIMInstance mInstance = _providerRegistrationManager->getInstance(objectReference);
732
|
733 kumpf 1.5 handler.processing();
734
735 Sint16 ret_value;
|
736 kumpf 1.1
|
737 kumpf 1.28 if(methodName.equal(_STOP_PROVIDER))
|
738 kumpf 1.1 {
|
739 kumpf 1.5 for (Uint32 i = 0; i<_OperationalStatus.size(); i++)
740 {
741 // retValue equals 1 if module is already disabled
|
742 chip 1.24 if (_OperationalStatus[i] == _MODULE_STOPPED ||
|
743 kumpf 1.14 _OperationalStatus[i] == _MODULE_STOPPING)
|
744 kumpf 1.5 {
745 ret_value = 1;
746 CIMValue retValue(ret_value);
747 handler.deliver(retValue);
748 handler.complete();
749 return;
750 }
751 }
|
752 kumpf 1.1
|
753 kumpf 1.8 CIMInstance instance;
754 Array<CIMInstance> instances;
755 String _moduleName;
756
757 // get all provider instances which have same module name as moduleName
|
758 kumpf 1.13 CIMObjectPath providerRef(objectReference.getHost(),
|
759 kumpf 1.8 objectReference.getNameSpace(),
760 PEGASUS_CLASSNAME_PROVIDER,
761 objectReference.getKeyBindings());
|
762 kumpf 1.20 Array<CIMInstance> namedInstances;
|
763 kumpf 1.8 namedInstances = _providerRegistrationManager->enumerateInstances(providerRef);
764 for(Uint32 i = 0, n=namedInstances.size(); i < n; i++)
765 {
|
766 kumpf 1.20 instance = namedInstances[i];
|
767 kumpf 1.8 instance.getProperty(instance.findProperty
768 (_PROPERTY_PROVIDERMODULENAME)).getValue().get(_moduleName);
769 if (String::equalNoCase(_moduleName, moduleName))
770 {
771 instances.append(instance);
772 }
|
773 chip 1.24
|
774 kumpf 1.8 }
775
|
776 chip 1.24 //
|
777 kumpf 1.5 // get provider manager service
|
778 kumpf 1.1 //
|
779 kumpf 1.5 MessageQueueService * _service = _getProviderManagerService();
|
780 kumpf 1.1
|
781 kumpf 1.15 if (_service != NULL)
782 {
783 // create CIMDisableModuleRequestMessage
|
784 chip 1.24 CIMDisableModuleRequestMessage * disable_req =
|
785 kumpf 1.15 new CIMDisableModuleRequestMessage(
786 XmlWriter::getNextMessageId (),
787 mInstance,
788 instances,
789 QueueIdStack(_service->getQueueId()));
|
790 kumpf 1.5
|
791 chip 1.24 Array<Uint16> _opStatus =
|
792 kumpf 1.15 _sendDisableMessageToProviderManager(disable_req);
|
793 kumpf 1.5
|
794 kumpf 1.15 for (Uint32 i = 0; i<_opStatus.size(); i++)
|
795 kumpf 1.5 {
|
796 kumpf 1.15 if (_opStatus[i] == _MODULE_STOPPED)
797 {
798 // module was disabled successfully
799 ret_value = 0;
800 CIMValue retValue(ret_value);
801 handler.deliver(retValue);
802 handler.complete();
803
804 // send termination message to subscription service
805 _sendTerminationMessageToSubscription(objectReference, moduleName);
806 return;
807 }
|
808 kumpf 1.5 }
|
809 kumpf 1.15 }
|
810 kumpf 1.5
811 // disable failed
812 ret_value = -1;
813 CIMValue retValue(ret_value);
814 handler.deliver(retValue);
815 handler.complete();
816 return;
|
817 kumpf 1.1 }
|
818 kumpf 1.28 else if(methodName.equal(_START_PROVIDER))
|
819 kumpf 1.1 {
|
820 kumpf 1.5 for (Uint32 i = 0; i<_OperationalStatus.size(); i++)
|
821 kumpf 1.1 {
|
822 kumpf 1.5 // retValue equals 1 if module is already enabled
|
823 chip 1.24 if (_OperationalStatus[i] == _MODULE_OK)
|
824 kumpf 1.5 {
825 ret_value = 1;
826 CIMValue retValue(ret_value);
827 handler.deliver(retValue);
828 handler.complete();
829 return;
|
830 kumpf 1.14 }
831
832 // retValue equals 2 if module is stopping
833 // at this stage, module can not be started
834 if (_OperationalStatus[i] == _MODULE_STOPPING)
835 {
836 ret_value = 2;
837 CIMValue retValue(ret_value);
838 handler.deliver(retValue);
839 handler.complete();
840 return;
|
841 kumpf 1.5 }
|
842 kumpf 1.1 }
|
843 kumpf 1.5
|
844 chip 1.24 //
|
845 kumpf 1.5 // get provider manager service
846 //
847 MessageQueueService * _service = _getProviderManagerService();
848
|
849 kumpf 1.15 if (_service != NULL)
850 {
851 // create CIMEnableModuleRequestMessage
|
852 chip 1.24 CIMEnableModuleRequestMessage * enable_req =
|
853 kumpf 1.15 new CIMEnableModuleRequestMessage(
854 XmlWriter::getNextMessageId (),
|
855 kumpf 1.25 mInstance,
|
856 kumpf 1.15 QueueIdStack(_service->getQueueId()));
|
857 kumpf 1.5
|
858 kumpf 1.15 Array<Uint16> _opStatus;
859 _opStatus = _sendEnableMessageToProviderManager(enable_req);
|
860 kumpf 1.5
|
861 kumpf 1.15 for (Uint32 i = 0; i<_opStatus.size(); i++)
|
862 kumpf 1.5 {
|
863 kumpf 1.15 if (_opStatus[i] == _MODULE_OK)
864 {
865 // module was enabled successfully
866 ret_value = 0;
867 CIMValue retValue(ret_value);
868 handler.deliver(retValue);
869 handler.complete();
870 return;
871 }
|
872 kumpf 1.5 }
873 }
874
875 // enable failed
876 ret_value = -1;
877 CIMValue retValue(ret_value);
878 handler.deliver(retValue);
879 handler.complete();
880 return;
|
881 kumpf 1.1 }
882 else
883 {
|
884 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_METHOD_NOT_AVAILABLE, String::EMPTY);
|
885 kumpf 1.1 }
|
886 kumpf 1.5 }
887
888 // get provider manager service
889 MessageQueueService * ProviderRegistrationProvider::_getProviderManagerService()
890 {
891 MessageQueue * queue = MessageQueue::lookup(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP);
892 MessageQueueService * _service = dynamic_cast<MessageQueueService *>(queue);
893
|
894 chip 1.24 return(_service);
|
895 kumpf 1.5 }
896
897 ProviderRegistrationProvider & ProviderRegistrationProvider::operator=(const ProviderRegistrationProvider & handle)
898 {
899 if(this == &handle)
900 {
901 return(*this);
902 }
903
904 return(*this);
905 }
|
906 kumpf 1.1
|
907 kumpf 1.5 Array<Uint16> ProviderRegistrationProvider::_sendDisableMessageToProviderManager(
908 CIMDisableModuleRequestMessage * disable_req)
909 {
910 MessageQueueService * _service = _getProviderManagerService();
911 Uint32 _queueId = _service->getQueueId();
912
913 callback_data *cb_data = new callback_data(this);
914
915 // create request envelope
916 AsyncLegacyOperationStart * asyncRequest =
917 new AsyncLegacyOperationStart (
918 _service->get_next_xid(),
919 NULL,
920 _queueId,
921 disable_req,
922 _queueId);
923
|
924 kumpf 1.8 AsyncReply * asyncReply = _controller->ClientSendWait(*_client_handle,
925 _queueId,
926 asyncRequest);
|
927 kumpf 1.10 CIMDisableModuleResponseMessage * response =
928 reinterpret_cast<CIMDisableModuleResponseMessage *>(
|
929 kumpf 1.8 (static_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result());
930 if (response->cimException.getCode() != CIM_ERR_SUCCESS)
931 {
932 CIMException e = response->cimException;
933 delete asyncRequest;
934 delete asyncReply;
935 delete response;
936 throw (e);
937 }
|
938 kumpf 1.5
|
939 chip 1.24 Array<Uint16> operationalStatus = response->operationalStatus;
|
940 kumpf 1.8
941 delete asyncRequest;
942 delete asyncReply;
943 delete response;
|
944 mday 1.16
|
945 kumpf 1.5 return(operationalStatus);
946 }
947
948 Array<Uint16> ProviderRegistrationProvider::_sendEnableMessageToProviderManager(
949 CIMEnableModuleRequestMessage * enable_req)
950 {
951 MessageQueueService * _service = _getProviderManagerService();
952 Uint32 _queueId = _service->getQueueId();
953
954 callback_data *cb_data = new callback_data(this);
955
956 // create request envelope
957 AsyncLegacyOperationStart * asyncRequest =
958 new AsyncLegacyOperationStart (
959 _service->get_next_xid(),
960 NULL,
961 _queueId,
962 enable_req,
963 _queueId);
964
|
965 kumpf 1.8 AsyncReply * asyncReply = _controller->ClientSendWait(*_client_handle,
966 _queueId,
967 asyncRequest);
968 CIMEnableModuleResponseMessage * response =
969 reinterpret_cast<CIMEnableModuleResponseMessage *>(
970 (static_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result());
971 if (response->cimException.getCode() != CIM_ERR_SUCCESS)
972 {
973 CIMException e = response->cimException;
974 delete asyncRequest;
975 delete asyncReply;
976 delete response;
977 throw (e);
978 }
979
|
980 chip 1.24 Array<Uint16> operationalStatus = response->operationalStatus;
|
981 kumpf 1.8
982 delete asyncRequest;
983 delete asyncReply;
984 delete response;
|
985 mday 1.16
|
986 kumpf 1.5 return(operationalStatus);
|
987 kumpf 1.6 }
988
989 // send termination message to subscription service
990 void ProviderRegistrationProvider::_sendTerminationMessageToSubscription(
|
991 kumpf 1.13 const CIMObjectPath & ref, const String & moduleName)
|
992 kumpf 1.6 {
993 CIMInstance instance;
994 String _moduleName;
995 Array<CIMInstance> instances;
996
|
997 chip 1.24 CIMObjectPath reference("", PEGASUS_NAMESPACENAME_INTEROP,
|
998 kumpf 1.6 PEGASUS_CLASSNAME_PROVIDER, ref.getKeyBindings());
|
999 chip 1.24
|
1000 kumpf 1.6 // get all registered providers
|
1001 kumpf 1.20 Array<CIMInstance> enumInstances =
|
1002 chip 1.24 _providerRegistrationManager->enumerateInstances(reference);
|
1003 kumpf 1.6
1004 // find all the instances which have same module name as moduleName
1005 for (Uint32 i = 0, n=enumInstances.size(); i < n; i++)
1006 {
|
1007 kumpf 1.20 instance = enumInstances[i];
|
1008 kumpf 1.6
1009 //
1010 // get provider module name
1011 //
1012 instance.getProperty(instance.findProperty
1013 (_PROPERTY_PROVIDERMODULENAME)).getValue().get(_moduleName);
1014
1015 if (String::equalNoCase(moduleName, _moduleName))
1016 {
1017 instances.append(instance);
1018 }
1019 }
1020
1021 //
1022 // get indication server queueId
1023 //
1024 MessageQueueService * _service = _getIndicationService();
1025
|
1026 kumpf 1.15 if (_service != NULL)
1027 {
1028 Uint32 _queueId = _service->getQueueId();
|
1029 kumpf 1.6
|
1030 kumpf 1.15 CIMNotifyProviderTerminationRequestMessage * termination_req =
1031 new CIMNotifyProviderTerminationRequestMessage(
1032 XmlWriter::getNextMessageId (),
1033 instances,
1034 QueueIdStack(_service->getQueueId()));
1035
1036 // create request envelope
1037 AsyncLegacyOperationStart * asyncRequest =
1038 new AsyncLegacyOperationStart (
|
1039 kumpf 1.6 _service->get_next_xid(),
1040 NULL,
1041 _queueId,
1042 termination_req,
1043 _queueId);
1044
|
1045 kumpf 1.15 if( false == _controller->ClientSendForget(
|
1046 kumpf 1.6 *_client_handle,
1047 _queueId,
1048 asyncRequest))
|
1049 kumpf 1.15 {
1050 delete asyncRequest;
|
1051 kumpf 1.30 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_FOUND, String::EMPTY);
|
1052 kumpf 1.15 }
|
1053 kumpf 1.6 }
1054 }
1055
1056 // get indication service
1057 MessageQueueService * ProviderRegistrationProvider::_getIndicationService()
1058 {
1059 MessageQueue * queue = MessageQueue::lookup(
1060 PEGASUS_QUEUENAME_INDICATIONSERVICE);
1061
1062 MessageQueueService * _service =
1063 dynamic_cast<MessageQueueService *>(queue);
1064 return(_service);
|
1065 kumpf 1.1 }
1066
1067 PEGASUS_NAMESPACE_END
|