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