1 martin 1.41 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.42 //
|
3 martin 1.41 // 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.42 //
|
10 martin 1.41 // 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.42 //
|
17 martin 1.41 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.42 //
|
20 martin 1.41 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.42 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.41 // 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.42 //
|
28 martin 1.41 //////////////////////////////////////////////////////////////////////////
|
29 kumpf 1.1 //
30 //%////////////////////////////////////////////////////////////////////////////
31
32
33 ///////////////////////////////////////////////////////////////////////////////
34 // ConfigSetting Provider
35 ///////////////////////////////////////////////////////////////////////////////
36
37 #include <Pegasus/Common/Config.h>
|
38 kumpf 1.4 #include <Pegasus/Common/PegasusVersion.h>
|
39 kumpf 1.1
40 #include <cctype>
41 #include <iostream>
42
43 #include "ConfigSettingProvider.h"
44 #include <Pegasus/Common/String.h>
|
45 kumpf 1.40 #include <Pegasus/Common/CIMNameCast.h>
|
46 kumpf 1.1 #include <Pegasus/Common/System.h>
|
47 kumpf 1.13 #include <Pegasus/Common/ArrayInternal.h>
|
48 kumpf 1.1 #include <Pegasus/Common/CIMType.h>
49 #include <Pegasus/Common/CIMInstance.h>
|
50 kumpf 1.6 #include <Pegasus/Common/CIMObjectPath.h>
|
51 kumpf 1.12 #include <Pegasus/Common/InternalException.h>
|
52 kumpf 1.1 #include <Pegasus/Common/CIMStatusCode.h>
53 #include <Pegasus/Common/Tracer.h>
54 #include <Pegasus/Config/ConfigManager.h>
|
55 dl.meetei 1.45.8.1 #include <Pegasus/Config/ConfigExceptions.h>
|
56 kumpf 1.1
57 #include <Pegasus/Repository/CIMRepository.h>
58 #include <Pegasus/Provider/CIMInstanceProvider.h>
|
59 kumpf 1.14 #include <Pegasus/Common/ResponseHandler.h>
|
60 humberto 1.22 #include <Pegasus/Common/MessageLoader.h> //l10n
|
61 kumpf 1.26 #include <Pegasus/Common/ModuleController.h>
62 #include <Pegasus/Common/CIMMessage.h>
63 #include <Pegasus/Common/AutoPtr.h>
|
64 yi.zhou 1.33 #include <Pegasus/Common/AuditLogger.h>
|
65 kumpf 1.26
|
66 kumpf 1.1
67 PEGASUS_USING_STD;
68
69 PEGASUS_NAMESPACE_BEGIN
70
71 /**
72 The constants representing the string literals.
73 */
|
74 mike 1.39 static const CIMName PROPERTY_NAME = CIMNameCast("PropertyName");
|
75 kumpf 1.1
|
76 mike 1.39 static const CIMName DEFAULT_VALUE = CIMNameCast("DefaultValue");
|
77 kumpf 1.1
|
78 mike 1.39 static const CIMName CURRENT_VALUE = CIMNameCast("CurrentValue");
|
79 kumpf 1.1
|
80 mike 1.39 static const CIMName PLANNED_VALUE = CIMNameCast("PlannedValue");
|
81 kumpf 1.1
|
82 mike 1.39 static const CIMName DYNAMIC_PROPERTY = CIMNameCast("DynamicProperty");
|
83 kumpf 1.1
|
84 venkat.puvvada 1.45
85 /**
86 The name of the method that implements the property value update using the
87 timeout period.
88 */
89 static const CIMName METHOD_UPDATE_PROPERTY_VALUE =
90 CIMName("UpdatePropertyValue");
91
92 /**
93 The input parameter names for the UpdatePropertyValue() method.
94 */
95 static const String PARAM_PROPERTYVALUE = String("PropertyValue");
96 static const String PARAM_RESETVALUE = String("ResetValue");
97 static const String PARAM_UPDATEPLANNEDVALUE = String("SetPlannedValue");
98 static const String PARAM_UPDATECURRENTVALUE = String("SetCurrentValue");
99 static const String PARAM_TIMEOUTPERIOD = String("TimeoutPeriod");
100
|
101 kumpf 1.1 /**
|
102 kumpf 1.17 The constant representing the config setting class name
|
103 kumpf 1.1 */
|
104 mike 1.39 static const CIMName PG_CONFIG_SETTING = CIMNameCast("PG_ConfigSetting");
|
105 kumpf 1.1
106 void ConfigSettingProvider::getInstance(
|
107 karl 1.34 const OperationContext & context,
108 const CIMObjectPath& instanceName,
109 const Boolean includeQualifiers,
110 const Boolean includeClassOrigin,
111 const CIMPropertyList& propertyList,
112 InstanceResponseHandler & handler)
|
113 kumpf 1.1 {
114 PEG_METHOD_ENTER(TRC_CONFIG, "ConfigSettingProvider::getInstance()");
115
116 Array<String> propertyInfo;
|
117 kumpf 1.16 CIMKeyBinding kb;
|
118 kumpf 1.1 String keyName;
119 String keyValue;
120
|
121 kumpf 1.5 //
122 // check if the class name requested is PG_ConfigSetting
123 //
|
124 kumpf 1.17 if (!instanceName.getClassName().equal (PG_CONFIG_SETTING))
|
125 kumpf 1.5 {
126 PEG_METHOD_EXIT();
127 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
|
128 kumpf 1.17 instanceName.getClassName().getString());
|
129 kumpf 1.5 }
|
130 kumpf 1.1
|
131 kumpf 1.5 //
132 // validate key bindings
133 //
|
134 kumpf 1.16 Array<CIMKeyBinding> kbArray = instanceName.getKeyBindings();
|
135 kumpf 1.5 if ( (kbArray.size() != 1) ||
|
136 kumpf 1.17 (!kbArray[0].getName().equal (PROPERTY_NAME)))
|
137 kumpf 1.1 {
138 PEG_METHOD_EXIT();
|
139 humberto 1.22 throw PEGASUS_CIM_EXCEPTION_L(
|
140 kumpf 1.5 CIM_ERR_INVALID_PARAMETER,
|
141 karl 1.34 MessageLoaderParms(
142 "ControlProviders.ConfigSettingProvider."
143 "ConfigSettingProvider."
144 "INVALID_INSTANCE_NAME",
145 "Invalid instance name"));
|
146 kumpf 1.1 }
147
|
148 kumpf 1.5 keyValue.assign(kbArray[0].getValue());
149
|
150 kumpf 1.1 // begin processing the request
151 handler.processing();
152
|
153 kumpf 1.5 //
154 // Get values for the property
155 //
156 try
157 {
158 _configManager->getPropertyInfo(keyValue, propertyInfo);
159 }
|
160 david.dillard 1.27 catch (const UnrecognizedConfigProperty&)
|
161 kumpf 1.5 {
162 PEG_METHOD_EXIT();
|
163 humberto 1.22 throw PEGASUS_CIM_EXCEPTION_L(
|
164 kumpf 1.5 CIM_ERR_NOT_FOUND,
|
165 karl 1.34 MessageLoaderParms(
166 "ControlProviders.ConfigSettingProvider."
167 "ConfigSettingProvider."
168 "CONFIG_PROPERTY_NOT_FOUND",
|
169 kumpf 1.43 "Configuration property \"$0\"",
|
170 karl 1.34 keyValue));
|
171 kumpf 1.5 }
|
172 kumpf 1.1
|
173 kumpf 1.5 if (propertyInfo.size() >= 5)
|
174 kumpf 1.1 {
|
175 kumpf 1.5 CIMInstance instance(PG_CONFIG_SETTING);
176
|
177 kumpf 1.1 //
|
178 kumpf 1.5 // construct the instance
|
179 kumpf 1.1 //
|
180 kumpf 1.5 instance.addProperty(CIMProperty(PROPERTY_NAME, propertyInfo[0]));
181 instance.addProperty(CIMProperty(DEFAULT_VALUE, propertyInfo[1]));
182 instance.addProperty(CIMProperty(CURRENT_VALUE, propertyInfo[2]));
183 instance.addProperty(CIMProperty(PLANNED_VALUE, propertyInfo[3]));
184 instance.addProperty(CIMProperty(DYNAMIC_PROPERTY,
185 Boolean(propertyInfo[4]=="true"?true:false)));
|
186 kumpf 1.1
|
187 kumpf 1.5 handler.deliver(instance);
|
188 kumpf 1.1
|
189 kumpf 1.5 // complete processing the request
190 handler.complete();
|
191 kumpf 1.1
|
192 kumpf 1.5 PEG_METHOD_EXIT();
193 return ;
|
194 kumpf 1.1 }
195 }
196
197 void ConfigSettingProvider::modifyInstance(
|
198 karl 1.34 const OperationContext & context,
199 const CIMObjectPath & instanceReference,
200 const CIMInstance& modifiedIns,
201 const Boolean includeQualifiers,
202 const CIMPropertyList& propertyList,
203 ResponseHandler & handler)
|
204 venkat.puvvada 1.45 {
205 PEG_METHOD_ENTER(TRC_CONFIG, "ConfigSettingProvider::modifyInstance()");
206
207 handler.processing();
208
209 _modifyInstance(
210 context,
211 instanceReference,
212 modifiedIns,
213 propertyList,
214 0);
215
216 handler.complete();
217
218 PEG_METHOD_EXIT();
219 }
220
221 void ConfigSettingProvider::_modifyInstance(
222 const OperationContext & context,
223 const CIMObjectPath & instanceReference,
224 const CIMInstance& modifiedIns,
225 venkat.puvvada 1.45 const CIMPropertyList& propertyList,
226 Uint32 timeoutSeconds)
|
227 kumpf 1.1 {
|
228 venkat.puvvada 1.45 PEG_METHOD_ENTER(TRC_CONFIG,
229 "ConfigSettingProvider::_modifyInstance()");
|
230 kumpf 1.1
|
231 kumpf 1.7 //
|
232 chip 1.10 // get userName
|
233 kumpf 1.7 //
234 String userName;
235 try
236 {
|
237 kumpf 1.18 IdentityContainer container = context.get(IdentityContainer::NAME);
|
238 kumpf 1.7 userName = container.getUserName();
239 }
240 catch (...)
241 {
242 userName = String::EMPTY;
243 }
244
245 //
246 // verify user authorizations
|
247 thilo.boehm 1.36 // z/OS: authorization check is done in CIMOpReqAuth already
|
248 kumpf 1.7 //
|
249 thilo.boehm 1.36 #ifndef PEGASUS_OS_ZOS
|
250 kumpf 1.35 if (userName != String::EMPTY)
|
251 kumpf 1.7 {
252 _verifyAuthorization(userName);
253 }
|
254 thilo.boehm 1.36 #endif
|
255 kumpf 1.5 // NOTE: Qualifiers are not processed by this provider, so the
256 // IncludeQualifiers flag is ignored.
257
258 //
259 // check if the class name requested is PG_ConfigSetting
260 //
|
261 kumpf 1.17 if (!instanceReference.getClassName().equal (PG_CONFIG_SETTING))
|
262 kumpf 1.1 {
263 PEG_METHOD_EXIT();
|
264 kumpf 1.5 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
|
265 kumpf 1.17 instanceReference.getClassName().getString());
|
266 kumpf 1.1 }
267
|
268 kumpf 1.5 //
269 // validate key bindings
270 //
|
271 kumpf 1.16 Array<CIMKeyBinding> kbArray = instanceReference.getKeyBindings();
|
272 kumpf 1.5 if ( (kbArray.size() != 1) ||
|
273 kumpf 1.17 (!kbArray[0].getName().equal (PROPERTY_NAME)))
|
274 kumpf 1.5 {
275 PEG_METHOD_EXIT();
|
276 humberto 1.22 throw PEGASUS_CIM_EXCEPTION_L(
|
277 kumpf 1.5 CIM_ERR_INVALID_PARAMETER,
|
278 karl 1.34 MessageLoaderParms(
279 "ControlProviders.ConfigSettingProvider."
280 "ConfigSettingProvider."
281 "INVALID_INSTANCE_NAME",
282 "Invalid instance name"));
|
283 kumpf 1.43
|
284 kumpf 1.5 }
285
286 String configPropertyName = kbArray[0].getValue();
287
288 // Modification of the entire instance is not supported by this provider
289 if (propertyList.isNull())
290 {
291 PEG_METHOD_EXIT();
|
292 humberto 1.22 //l10n
293 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
|
294 karl 1.34 //"Modification of entire instance");
|
295 humberto 1.22 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,
|
296 karl 1.34 MessageLoaderParms(
297 "ControlProviders.ConfigSettingProvider."
298 "ConfigSettingProvider."
299 "MODIFICATION_OF_ENTIRE_INSTANCE",
300 "Modification of entire instance"));
|
301 kumpf 1.5 }
|
302 kumpf 1.1
303 Boolean currentValueModified = false;
304 Boolean plannedValueModified = false;
305
|
306 kumpf 1.11 for (Uint32 i=0; i<propertyList.size(); i++)
|
307 kumpf 1.5 {
|
308 kumpf 1.17 CIMName propertyName = propertyList[i];
309 if (propertyName.equal (CURRENT_VALUE))
|
310 kumpf 1.5 {
311 currentValueModified = true;
312 }
|
313 kumpf 1.17 else if (propertyName.equal (PLANNED_VALUE))
|
314 kumpf 1.5 {
315 plannedValueModified = true;
316 }
317 else
318 {
319 PEG_METHOD_EXIT();
|
320 karl 1.34
|
321 humberto 1.22 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,
|
322 karl 1.34 MessageLoaderParms(
323 "ControlProviders.ConfigSettingProvider."
324 "ConfigSettingProvider."
325 "MODIFICATION_NOT_SUPPORTED",
|
326 kumpf 1.43 "Modification of property \"$0\"",
|
327 humberto 1.22 propertyName.getString()));
|
328 kumpf 1.5 }
329 }
330
|
331 kumpf 1.35 String preValue;
332 String currentValue;
333 String plannedValue;
|
334 kumpf 1.5 Boolean currentValueIsNull = false;
335 Boolean plannedValueIsNull = false;
|
336 kumpf 1.1
|
337 kumpf 1.5 //
338 // Get the current value from the instance
339 //
340 Uint32 pos = modifiedIns.findProperty(CURRENT_VALUE);
341 if (pos == PEG_NOT_FOUND)
342 {
343 currentValueIsNull = true;
344 }
345 else
|
346 kumpf 1.1 {
|
347 kumpf 1.5 CIMConstProperty prop = modifiedIns.getProperty(pos);
348 try
|
349 kumpf 1.1 {
|
350 kumpf 1.5 prop.getValue().get(currentValue);
|
351 kumpf 1.1 }
|
352 kumpf 1.5 catch (Exception& e)
|
353 kumpf 1.1 {
|
354 kumpf 1.5 PEG_METHOD_EXIT();
355 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
356 }
357 }
|
358 kumpf 1.1
|
359 kumpf 1.5 //
360 // Get the planned value from the instance
361 //
362 pos = modifiedIns.findProperty(PLANNED_VALUE);
363 if (pos == PEG_NOT_FOUND)
364 {
365 plannedValueIsNull = true;
|
366 kumpf 1.1 }
|
367 kumpf 1.5 else
|
368 kumpf 1.1 {
|
369 kumpf 1.5 CIMConstProperty prop = modifiedIns.getProperty(pos);
370 try
371 {
372 prop.getValue().get(plannedValue);
373 }
374 catch (Exception& e)
375 {
376 PEG_METHOD_EXIT();
377 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
378 }
|
379 kumpf 1.1 }
380
381 try
382 {
|
383 kumpf 1.5 //
384 // Update the current value, if requested
385 //
|
386 kumpf 1.1 if (currentValueModified)
387 {
|
388 yi.zhou 1.33 preValue = _configManager->getCurrentValue(configPropertyName);
389
|
390 kumpf 1.5 if ( !_configManager->updateCurrentValue(
|
391 venkat.puvvada 1.44 configPropertyName,
392 currentValue,
393 userName,
|
394 venkat.puvvada 1.45 timeoutSeconds,
|
395 venkat.puvvada 1.44 currentValueIsNull))
|
396 kumpf 1.1 {
397 PEG_METHOD_EXIT();
|
398 karl 1.34
|
399 humberto 1.22 throw PEGASUS_CIM_EXCEPTION_L(
|
400 kumpf 1.1 CIM_ERR_FAILED,
|
401 karl 1.34 MessageLoaderParms(
402 "ControlProviders.ConfigSettingProvider."
403 "ConfigSettingProvider."
404 "UPDATE_CURRENT_VALUE_FAILED",
405 "Failed to update the current value."));
|
406 kumpf 1.1 }
|
407 kumpf 1.43
|
408 karl 1.34 // It is unset, get current value which is default
|
409 kumpf 1.26 if (currentValueIsNull)
410 {
411 currentValue = _configManager->getCurrentValue(
412 configPropertyName);
413 }
414
415 // send notify config change message to ProviderManager Service
|
416 kumpf 1.43 _sendNotifyConfigChangeMessage(configPropertyName,
|
417 kumpf 1.26 currentValue,
|
418 venkat.puvvada 1.44 userName,
|
419 kumpf 1.26 true);
|
420 yi.zhou 1.33
421 PEG_AUDIT_LOG(logSetConfigProperty(userName, configPropertyName,
422 preValue, currentValue, false));
|
423 kumpf 1.1 }
424
|
425 kumpf 1.5 //
426 // Update the planned value, if requested
427 //
|
428 kumpf 1.1 if (plannedValueModified)
429 {
|
430 yi.zhou 1.33 preValue = _configManager->getPlannedValue(configPropertyName);
431
|
432 kumpf 1.5 if ( !_configManager->updatePlannedValue(
433 configPropertyName, plannedValue, plannedValueIsNull) )
|
434 kumpf 1.1 {
435 PEG_METHOD_EXIT();
|
436 karl 1.34
|
437 humberto 1.22 throw PEGASUS_CIM_EXCEPTION_L(
|
438 kumpf 1.1 CIM_ERR_FAILED,
|
439 karl 1.34 MessageLoaderParms(
440 "ControlProviders.ConfigSettingProvider."
441 "ConfigSettingProvider."
442 "UPDATE_PLANNED_VALUE_FAILED",
443 "Failed to update the planned value."));
|
444 kumpf 1.1 }
|
445 kumpf 1.26
|
446 karl 1.34 // It is unset, get planned value which is default
|
447 kumpf 1.26 if (plannedValueIsNull)
448 {
449 plannedValue = _configManager->getPlannedValue(
450 configPropertyName);
451 }
452
453 // send notify config change message to ProviderManager Service
|
454 kumpf 1.43 _sendNotifyConfigChangeMessage(configPropertyName,
|
455 kumpf 1.26 plannedValue,
|
456 venkat.puvvada 1.44 userName,
|
457 kumpf 1.26 false);
|
458 yi.zhou 1.33
459 PEG_AUDIT_LOG(logSetConfigProperty(userName, configPropertyName,
460 preValue, plannedValue, true));
|
461 kumpf 1.1 }
462 }
|
463 david.dillard 1.27 catch (const NonDynamicConfigProperty& ndcp)
|
464 kumpf 1.1 {
465 PEG_METHOD_EXIT();
466 throw PEGASUS_CIM_EXCEPTION(
467 CIM_ERR_NOT_SUPPORTED, ndcp.getMessage());
468 }
|
469 david.dillard 1.27 catch (const InvalidPropertyValue& ipv)
|
470 kumpf 1.1 {
471 PEG_METHOD_EXIT();
472 throw PEGASUS_CIM_EXCEPTION(
|
473 kumpf 1.5 CIM_ERR_FAILED, ipv.getMessage());
|
474 kumpf 1.1 }
|
475 david.dillard 1.27 catch (const UnrecognizedConfigProperty&)
|
476 kumpf 1.1 {
477 PEG_METHOD_EXIT();
|
478 humberto 1.22 throw PEGASUS_CIM_EXCEPTION_L(
|
479 kumpf 1.3 CIM_ERR_NOT_FOUND,
|
480 karl 1.34 MessageLoaderParms(
481 "ControlProviders.ConfigSettingProvider."
482 "ConfigSettingProvider."
483 "CONFIG_PROPERTY_NOT_FOUND",
|
484 kumpf 1.43 "Configuration property \"$0\"",
|
485 karl 1.34 configPropertyName));
|
486 kumpf 1.1 }
487
488 PEG_METHOD_EXIT();
|
489 kumpf 1.5 return;
|
490 kumpf 1.1 }
491
492 void ConfigSettingProvider::enumerateInstances(
|
493 karl 1.34 const OperationContext & context,
494 const CIMObjectPath & ref,
495 const Boolean includeQualifiers,
496 const Boolean includeClassOrigin,
497 const CIMPropertyList& propertyList,
498 InstanceResponseHandler & handler)
|
499 kumpf 1.1 {
|
500 karl 1.34 PEG_METHOD_ENTER(TRC_CONFIG,
501 "ConfigSettingProvider::enumerateInstances()");
|
502 kumpf 1.1
503 Array<CIMInstance> instanceArray;
504 Array<String> propertyNames;
505
506 //
507 // check if the class name requested is PG_ConfigSetting
508 //
|
509 kumpf 1.17 if (!ref.getClassName().equal (PG_CONFIG_SETTING))
|
510 kumpf 1.1 {
511 PEG_METHOD_EXIT();
|
512 kumpf 1.5 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
|
513 kumpf 1.17 ref.getClassName().getString());
|
514 kumpf 1.1 }
515
|
516 karl 1.34 // begin processing the request
517 handler.processing();
|
518 kumpf 1.1
519 try
520 {
|
521 kumpf 1.25 _configManager->getAllPropertyNames(propertyNames, false);
|
522 kumpf 1.1
|
523 kumpf 1.19
|
524 kumpf 1.1 for (Uint32 i = 0; i < propertyNames.size(); i++)
525 {
|
526 kumpf 1.23 Array<String> propertyInfo;
|
527 kumpf 1.1
|
528 kumpf 1.23 CIMInstance instance(PG_CONFIG_SETTING);
|
529 kumpf 1.1
|
530 kumpf 1.23 propertyInfo.clear();
|
531 kumpf 1.1
|
532 kumpf 1.23 _configManager->getPropertyInfo(
533 propertyNames[i], propertyInfo);
|
534 kumpf 1.1
|
535 kumpf 1.23 Array<CIMKeyBinding> keyBindings;
|
536 kumpf 1.43 keyBindings.append(CIMKeyBinding(PROPERTY_NAME,
|
537 kumpf 1.23 propertyInfo[0], CIMKeyBinding::STRING));
|
538 kumpf 1.43 CIMObjectPath instanceName(ref.getHost(),
|
539 kumpf 1.23 ref.getNameSpace(),
540 PG_CONFIG_SETTING, keyBindings);
|
541 kumpf 1.19
|
542 kumpf 1.23 // construct the instance
|
543 kumpf 1.43 instance.addProperty(CIMProperty(PROPERTY_NAME,
|
544 kumpf 1.19 propertyInfo[0]));
|
545 kumpf 1.43 instance.addProperty(CIMProperty(DEFAULT_VALUE,
|
546 kumpf 1.19 propertyInfo[1]));
|
547 kumpf 1.43 instance.addProperty(CIMProperty(CURRENT_VALUE,
|
548 kumpf 1.19 propertyInfo[2]));
|
549 kumpf 1.43 instance.addProperty(CIMProperty(PLANNED_VALUE,
|
550 kumpf 1.19 propertyInfo[3]));
|
551 kumpf 1.23 instance.addProperty(CIMProperty(DYNAMIC_PROPERTY,
552 Boolean(propertyInfo[4]=="true"?true:false)));
|
553 kumpf 1.1
|
554 kumpf 1.23 instance.setPath(instanceName);
555 instanceArray.append(instance);
|
556 kumpf 1.1 }
557 }
558 catch(Exception& e)
559 {
560 PEG_METHOD_EXIT();
561 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
562 }
563
|
564 karl 1.34 handler.deliver(instanceArray);
|
565 kumpf 1.1
|
566 karl 1.34 // complete processing the request
567 handler.complete();
|
568 kumpf 1.1
569 PEG_METHOD_EXIT();
570 }
571
572 void ConfigSettingProvider::enumerateInstanceNames(
|
573 karl 1.34 const OperationContext & context,
574 const CIMObjectPath & classReference,
575 ObjectPathResponseHandler & handler)
|
576 kumpf 1.1 {
577 PEG_METHOD_ENTER(TRC_CONFIG,
578 "ConfigSettingProvider::enumerateInstanceNames()");
579
|
580 kumpf 1.6 Array<CIMObjectPath> instanceRefs;
|
581 kumpf 1.1 Array<String> propertyNames;
|
582 kumpf 1.16 Array<CIMKeyBinding> keyBindings;
583 CIMKeyBinding kb;
|
584 kumpf 1.1 String hostName;
585
586 hostName.assign(System::getHostName());
587
|
588 karl 1.34 const CIMName& className = classReference.getClassName();
589 const CIMNamespaceName& nameSpace = classReference.getNameSpace();
|
590 kumpf 1.1
|
591 kumpf 1.17 if (!className.equal (PG_CONFIG_SETTING))
|
592 kumpf 1.1 {
593 PEG_METHOD_EXIT();
|
594 kumpf 1.43 throw PEGASUS_CIM_EXCEPTION( CIM_ERR_NOT_SUPPORTED,
|
595 kumpf 1.17 className.getString());
|
596 kumpf 1.1 }
597
|
598 karl 1.34 // begin processing the request
599 handler.processing();
|
600 kumpf 1.1
601 try
602 {
|
603 kumpf 1.25 _configManager->getAllPropertyNames(propertyNames, false);
|
604 kumpf 1.1
605 Uint32 size = propertyNames.size();
606
607 for (Uint32 i = 0; i < size; i++)
608 {
|
609 kumpf 1.23 keyBindings.append(
610 CIMKeyBinding(PROPERTY_NAME, propertyNames[i],
611 CIMKeyBinding::STRING));
612
613 //
614 // Convert instance names to References
615 //
|
616 kumpf 1.43 CIMObjectPath ref(hostName, nameSpace, className,
|
617 kumpf 1.23 keyBindings);
|
618 kumpf 1.1
|
619 kumpf 1.23 instanceRefs.append(ref);
620 keyBindings.clear();
|
621 kumpf 1.1
622 }
623 }
624 catch(Exception& e)
625 {
626 PEG_METHOD_EXIT();
627 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
628 }
629
|
630 karl 1.34 handler.deliver(instanceRefs);
|
631 kumpf 1.1
|
632 karl 1.34 // complete processing the request
633 handler.complete();
|
634 kumpf 1.7
635 PEG_METHOD_EXIT();
636 }
637
|
638 venkat.puvvada 1.45 void ConfigSettingProvider::invokeMethod(
639 const OperationContext & context,
640 const CIMObjectPath & cimObjectPath,
641 const CIMName & methodName,
642 const Array<CIMParamValue> & inParams,
643 MethodResultResponseHandler & handler)
644 {
645 PEG_METHOD_ENTER(TRC_CONFIG,
646 "ConfigSettingProvider::invokeMethod");
647
648 if (!methodName.equal(METHOD_UPDATE_PROPERTY_VALUE))
649 {
650 throw CIMException(
651 CIM_ERR_METHOD_NOT_FOUND, methodName.getString());
652 }
653
654 // Prepare the instance for modification.
655
656 String propValue;
657 Boolean resetValue = false;
658 Boolean currentValueSet = false;
659 venkat.puvvada 1.45 Boolean plannedValueSet = false;
660 Uint32 timeoutSeconds = 0;
661 Array<CIMName> propertyList;
662
663 for (Uint32 i = 0, n = inParams.size(); i < n ; ++i)
664 {
665 CIMName name = inParams[i].getParameterName();
666 if (name.equal(PARAM_PROPERTYVALUE))
667 {
668 inParams[i].getValue().get(propValue);
669 }
670 else if (name.equal(PARAM_RESETVALUE))
671 {
672 inParams[i].getValue().get(resetValue);
673 }
674 else if (name.equal(PARAM_UPDATECURRENTVALUE))
675 {
676 inParams[i].getValue().get(currentValueSet);
677 }
678 else if (name.equal(PARAM_UPDATEPLANNEDVALUE))
679 {
680 venkat.puvvada 1.45 inParams[i].getValue().get(plannedValueSet);
681 }
682 else if (name.equal(PARAM_TIMEOUTPERIOD))
683 {
684 inParams[i].getValue().get(timeoutSeconds);
685 }
686 else
687 {
688 throw CIMException(
689 CIM_ERR_INVALID_PARAMETER, name.getString());
690 }
691 }
692
693 CIMInstance modifiedInst(PG_CONFIG_SETTING);
694
695 if (currentValueSet)
696 {
697 if (!resetValue)
698 {
699 CIMProperty prop =
700 CIMProperty(CURRENT_VALUE, CIMValue(propValue));
701 venkat.puvvada 1.45 modifiedInst.addProperty(prop);
702 }
703 propertyList.append(CURRENT_VALUE);
704 }
705
706 if (plannedValueSet)
707 {
708 if (!resetValue)
709 {
710 CIMProperty prop =
711 CIMProperty(PLANNED_VALUE, CIMValue(propValue));
712 modifiedInst.addProperty(prop);
713 }
714 propertyList.append(PLANNED_VALUE);
715 }
716
717 handler.processing();
718
719 _modifyInstance(
720 context,
721 cimObjectPath,
722 venkat.puvvada 1.45 modifiedInst,
723 propertyList,
724 timeoutSeconds);
725
726 handler.deliver(CIMValue(true));
727 handler.complete();
728
729 PEG_METHOD_EXIT();
730 }
731
732
|
733 kumpf 1.7 //
734 // Verify user authorization
735 //
736 void ConfigSettingProvider::_verifyAuthorization(const String& userName)
737 {
738 PEG_METHOD_ENTER(TRC_CONFIG,
739 "ConfigSettingProvider::_verifyAuthorization()");
740
741 if ( System::isPrivilegedUser(userName) == false )
742 {
743 PEG_METHOD_EXIT();
|
744 humberto 1.22 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED,
|
745 karl 1.34 MessageLoaderParms(
746 "ControlProviders.ConfigSettingProvider."
747 "ConfigSettingProvider."
748 "USER_NOT_PRIVILEGED",
749 "Must be a privileged user to do this CIM operation."));
|
750 kumpf 1.7 }
|
751 kumpf 1.1
752 PEG_METHOD_EXIT();
753 }
754
|
755 kumpf 1.26 //
756 // send notify config change message to provider manager service
757 //
758 void ConfigSettingProvider::_sendNotifyConfigChangeMessage(
759 const String& propertyName,
760 const String& newPropertyValue,
|
761 venkat.puvvada 1.44 const String& userName,
|
762 kumpf 1.26 Boolean currentValueModified)
763 {
764 PEG_METHOD_ENTER(TRC_CONFIG,
765 "ConfigSettingProvider::_sendNotifyConfigChangeMessage");
766
|
767 kumpf 1.32 ModuleController* controller = ModuleController::getModuleController();
|
768 kumpf 1.26
769 MessageQueue * queue = MessageQueue::lookup(
770 PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP);
771
772 MessageQueueService * service = dynamic_cast<MessageQueueService *>(queue);
773
774 if (service != NULL)
775 {
776 // create CIMNotifyConfigChangeRequestMessage
777 CIMNotifyConfigChangeRequestMessage * notify_req =
778 new CIMNotifyConfigChangeRequestMessage (
779 XmlWriter::getNextMessageId (),
780 propertyName,
781 newPropertyValue,
782 currentValueModified,
783 QueueIdStack(service->getQueueId()));
784
|
785 venkat.puvvada 1.44 notify_req->operationContext.insert(
786 IdentityContainer(userName));
787
|
788 kumpf 1.26 // create request envelope
789 AsyncLegacyOperationStart asyncRequest(
790 NULL,
791 service->getQueueId(),
|
792 venkat.puvvada 1.38 notify_req);
|
793 kumpf 1.26
|
794 kumpf 1.43 AutoPtr<AsyncReply> asyncReply(
|
795 kumpf 1.32 controller->ClientSendWait(service->getQueueId(), &asyncRequest));
|
796 kumpf 1.26
797 AutoPtr<CIMNotifyConfigChangeResponseMessage> response(
798 reinterpret_cast<CIMNotifyConfigChangeResponseMessage *>(
799 (static_cast<AsyncLegacyOperationResult *>
800 (asyncReply.get()))->get_result()));
801
802 if (response->cimException.getCode() != CIM_ERR_SUCCESS)
803 {
804 CIMException e = response->cimException;
805 throw (e);
|
806 karl 1.34 }
|
807 kumpf 1.26 }
808 }
809
|
810 kumpf 1.1 PEGASUS_NAMESPACE_END
811
|