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