(file) Return to ConfigSettingProvider.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ControlProviders / ConfigSettingProvider

  1 karl  1.30 //%2006////////////////////////////////////////////////////////////////////////
  2 kumpf 1.1  //
  3 karl  1.28 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4            // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5            // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6 karl  1.24 // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.28 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8            // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9 karl  1.29 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.30 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 kumpf 1.1  //
 14            // Permission is hereby granted, free of charge, to any person obtaining a copy
 15            // of this software and associated documentation files (the "Software"), to
 16            // deal in the Software without restriction, including without limitation the
 17            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18            // sell copies of the Software, and to permit persons to whom the Software is
 19            // furnished to do so, subject to the following conditions:
 20 karl  1.24 // 
 21 kumpf 1.1  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27            // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29            //
 30 kumpf 1.9  //==============================================================================
 31 kumpf 1.1  //
 32            //%////////////////////////////////////////////////////////////////////////////
 33            
 34            
 35            ///////////////////////////////////////////////////////////////////////////////
 36            //  ConfigSetting Provider
 37            ///////////////////////////////////////////////////////////////////////////////
 38            
 39            #include <Pegasus/Common/Config.h>
 40 kumpf 1.4  #include <Pegasus/Common/PegasusVersion.h>
 41 kumpf 1.1  
 42            #include <cctype>
 43            #include <iostream>
 44            
 45            #include "ConfigSettingProvider.h"
 46            #include <Pegasus/Common/String.h>
 47            #include <Pegasus/Common/System.h>
 48 kumpf 1.13 #include <Pegasus/Common/ArrayInternal.h>
 49 kumpf 1.1  #include <Pegasus/Common/CIMType.h>
 50            #include <Pegasus/Common/CIMInstance.h>
 51 kumpf 1.6  #include <Pegasus/Common/CIMObjectPath.h>
 52 kumpf 1.12 #include <Pegasus/Common/InternalException.h>
 53 kumpf 1.1  #include <Pegasus/Common/CIMStatusCode.h>
 54            #include <Pegasus/Common/Tracer.h>
 55            #include <Pegasus/Config/ConfigManager.h>
 56            
 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 kumpf    1.17 static const CIMName PROPERTY_NAME       = CIMName ("PropertyName");
 75 kumpf    1.1  
 76 kumpf    1.17 static const CIMName DEFAULT_VALUE       = CIMName ("DefaultValue");
 77 kumpf    1.1  
 78 kumpf    1.17 static const CIMName CURRENT_VALUE       = CIMName ("CurrentValue");
 79 kumpf    1.1  
 80 kumpf    1.17 static const CIMName PLANNED_VALUE       = CIMName ("PlannedValue");
 81 kumpf    1.1  
 82 kumpf    1.17 static const CIMName DYNAMIC_PROPERTY    = CIMName ("DynamicProperty");
 83 kumpf    1.1  
 84               /**
 85 kumpf    1.17     The constant representing the config setting class name
 86 kumpf    1.1  */
 87 kumpf    1.17 static const CIMName PG_CONFIG_SETTING  = CIMName ("PG_ConfigSetting");
 88 kumpf    1.1  
 89               void ConfigSettingProvider::getInstance(
 90 karl     1.34     const OperationContext & context,
 91                   const CIMObjectPath& instanceName,
 92                   const Boolean includeQualifiers,
 93                   const Boolean includeClassOrigin,
 94                   const CIMPropertyList& propertyList,
 95                   InstanceResponseHandler & handler)
 96 kumpf    1.1      {
 97                       PEG_METHOD_ENTER(TRC_CONFIG, "ConfigSettingProvider::getInstance()");
 98               
 99                       Array<String>     propertyInfo;
100 kumpf    1.16         CIMKeyBinding        kb;
101 kumpf    1.1          String            keyName;
102                       String            keyValue;
103               
104 kumpf    1.5          //
105                       // check if the class name requested is PG_ConfigSetting
106                       //
107 kumpf    1.17         if (!instanceName.getClassName().equal (PG_CONFIG_SETTING))
108 kumpf    1.5          {
109                           PEG_METHOD_EXIT();
110                           throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
111 kumpf    1.17                 instanceName.getClassName().getString());
112 kumpf    1.5          }
113 kumpf    1.1  
114 kumpf    1.5          //
115                       // validate key bindings
116                       //
117 kumpf    1.16         Array<CIMKeyBinding> kbArray = instanceName.getKeyBindings();
118 kumpf    1.5          if ( (kbArray.size() != 1) ||
119 kumpf    1.17              (!kbArray[0].getName().equal (PROPERTY_NAME)))
120 kumpf    1.1          {
121                           PEG_METHOD_EXIT();
122 humberto 1.22             throw PEGASUS_CIM_EXCEPTION_L(
123 kumpf    1.5                  CIM_ERR_INVALID_PARAMETER,
124 karl     1.34                 MessageLoaderParms(
125                                   "ControlProviders.ConfigSettingProvider."
126                                       "ConfigSettingProvider."
127                                       "INVALID_INSTANCE_NAME",
128                                   "Invalid instance name"));
129 kumpf    1.1          }
130               
131 kumpf    1.5          keyValue.assign(kbArray[0].getValue());
132               
133 kumpf    1.1          // begin processing the request
134                       handler.processing();
135               
136 kumpf    1.5          //
137                       // Get values for the property
138                       //
139                       try
140                       {
141                           _configManager->getPropertyInfo(keyValue, propertyInfo);
142                       }
143 david.dillard 1.27         catch (const UnrecognizedConfigProperty&)
144 kumpf         1.5          {
145                                PEG_METHOD_EXIT();
146 humberto      1.22             throw PEGASUS_CIM_EXCEPTION_L(
147 kumpf         1.5                  CIM_ERR_NOT_FOUND,
148 karl          1.34                 MessageLoaderParms(
149                                        "ControlProviders.ConfigSettingProvider."
150                                            "ConfigSettingProvider."
151                                            "CONFIG_PROPERTY_NOT_FOUND",
152                                        "Configuration property \"$0\"", 
153                                        keyValue));
154 kumpf         1.5          }
155 kumpf         1.1  
156 kumpf         1.5          if (propertyInfo.size() >= 5)
157 kumpf         1.1          {
158 kumpf         1.5              CIMInstance instance(PG_CONFIG_SETTING);
159                    
160 kumpf         1.1              //
161 kumpf         1.5              // construct the instance
162 kumpf         1.1              //
163 kumpf         1.5              instance.addProperty(CIMProperty(PROPERTY_NAME, propertyInfo[0]));
164                                instance.addProperty(CIMProperty(DEFAULT_VALUE, propertyInfo[1]));
165                                instance.addProperty(CIMProperty(CURRENT_VALUE, propertyInfo[2]));
166                                instance.addProperty(CIMProperty(PLANNED_VALUE, propertyInfo[3]));
167                                instance.addProperty(CIMProperty(DYNAMIC_PROPERTY,
168                                    Boolean(propertyInfo[4]=="true"?true:false)));
169 kumpf         1.1  
170 kumpf         1.5              handler.deliver(instance);
171 kumpf         1.1  
172 kumpf         1.5              // complete processing the request
173                                handler.complete();
174 kumpf         1.1  
175 kumpf         1.5              PEG_METHOD_EXIT();
176                                return ;
177 kumpf         1.1          }
178                        }
179                    
180                    void ConfigSettingProvider::modifyInstance(
181 karl          1.34     const OperationContext & context,
182                        const CIMObjectPath & instanceReference,
183                        const CIMInstance& modifiedIns,
184                        const Boolean includeQualifiers,
185                        const CIMPropertyList& propertyList,
186                        ResponseHandler & handler)
187 kumpf         1.1      {
188                            PEG_METHOD_ENTER(TRC_CONFIG, "ConfigSettingProvider::modifyInstance()");
189                    
190 kumpf         1.7          //
191 chip          1.10         // get userName
192 kumpf         1.7          //
193                            String userName;
194                            try
195                            {
196 kumpf         1.18             IdentityContainer container = context.get(IdentityContainer::NAME);
197 kumpf         1.7              userName = container.getUserName();
198                            }
199                            catch (...)
200                            {
201                                userName = String::EMPTY;
202                            }
203                    
204                            //
205                            // verify user authorizations
206 thilo.boehm   1.36         // z/OS: authorization check is done in CIMOpReqAuth already
207 kumpf         1.7          //
208 thilo.boehm   1.36 #ifndef PEGASUS_OS_ZOS
209 kumpf         1.35         if (userName != String::EMPTY)
210 kumpf         1.7          {
211                                _verifyAuthorization(userName);
212                            }
213 thilo.boehm   1.36 #endif
214 kumpf         1.5          // NOTE: Qualifiers are not processed by this provider, so the
215                            // IncludeQualifiers flag is ignored.
216                    
217                            //
218                            // check if the class name requested is PG_ConfigSetting
219                            //
220 kumpf         1.17         if (!instanceReference.getClassName().equal (PG_CONFIG_SETTING))
221 kumpf         1.1          {
222                                PEG_METHOD_EXIT();
223 kumpf         1.5              throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
224 kumpf         1.17                 instanceReference.getClassName().getString());
225 kumpf         1.1          }
226                    
227 kumpf         1.5          //
228                            // validate key bindings
229                            //
230 kumpf         1.16         Array<CIMKeyBinding> kbArray = instanceReference.getKeyBindings();
231 kumpf         1.5          if ( (kbArray.size() != 1) ||
232 kumpf         1.17              (!kbArray[0].getName().equal (PROPERTY_NAME)))
233 kumpf         1.5          {
234                                PEG_METHOD_EXIT();
235 humberto      1.22             throw PEGASUS_CIM_EXCEPTION_L(
236 kumpf         1.5                  CIM_ERR_INVALID_PARAMETER,
237 karl          1.34                 MessageLoaderParms(
238                                        "ControlProviders.ConfigSettingProvider."
239                                            "ConfigSettingProvider."
240                                            "INVALID_INSTANCE_NAME",
241                                        "Invalid instance name"));
242 humberto      1.22                 
243 kumpf         1.5          }
244                    
245                            String configPropertyName = kbArray[0].getValue();
246                    
247                            // Modification of the entire instance is not supported by this provider
248                            if (propertyList.isNull())
249                            {
250                                PEG_METHOD_EXIT();
251 humberto      1.22             //l10n
252                                //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
253 karl          1.34             //"Modification of entire instance");
254 humberto      1.22             throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,
255 karl          1.34                   MessageLoaderParms(
256                                          "ControlProviders.ConfigSettingProvider."
257                                              "ConfigSettingProvider."
258                                              "MODIFICATION_OF_ENTIRE_INSTANCE",
259                                         "Modification of entire instance"));
260 kumpf         1.5          }
261 kumpf         1.1  
262                            Boolean currentValueModified = false;
263                            Boolean plannedValueModified = false;
264                    
265 kumpf         1.11         for (Uint32 i=0; i<propertyList.size(); i++)
266 kumpf         1.5          {
267 kumpf         1.17             CIMName propertyName = propertyList[i];
268                                if (propertyName.equal (CURRENT_VALUE))
269 kumpf         1.5              {
270                                    currentValueModified = true;
271                                }
272 kumpf         1.17             else if (propertyName.equal (PLANNED_VALUE))
273 kumpf         1.5              {
274                                    plannedValueModified = true;
275                                }
276                                else
277                                {
278                                    PEG_METHOD_EXIT();
279 karl          1.34 
280 humberto      1.22                 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,
281 karl          1.34                     MessageLoaderParms(
282                                            "ControlProviders.ConfigSettingProvider."
283                                                "ConfigSettingProvider."
284                                                "MODIFICATION_NOT_SUPPORTED",
285                                            "Modification of property \"$0\"", 
286 humberto      1.22                         propertyName.getString()));
287 kumpf         1.5              }
288                            }
289                    
290 kumpf         1.35         String preValue;
291                            String currentValue;
292                            String plannedValue;
293 kumpf         1.5          Boolean currentValueIsNull = false;
294                            Boolean plannedValueIsNull = false;
295 kumpf         1.1  
296 karl          1.34         // begin processing the request
297                            handler.processing();
298 kumpf         1.1  
299 kumpf         1.5          //
300                            // Get the current value from the instance
301                            //
302                            Uint32 pos = modifiedIns.findProperty(CURRENT_VALUE);
303                            if (pos == PEG_NOT_FOUND)
304                            {
305                                currentValueIsNull = true;
306                            }
307                            else
308 kumpf         1.1          {
309 kumpf         1.5              CIMConstProperty prop = modifiedIns.getProperty(pos);
310                                try
311 kumpf         1.1              {
312 kumpf         1.5                  prop.getValue().get(currentValue);
313 kumpf         1.1              }
314 kumpf         1.5              catch (Exception& e)
315 kumpf         1.1              {
316 kumpf         1.5                  PEG_METHOD_EXIT();
317                                    throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
318                                }
319                            }
320 kumpf         1.1  
321 kumpf         1.5          //
322                            // Get the planned value from the instance
323                            //
324                            pos = modifiedIns.findProperty(PLANNED_VALUE);
325                            if (pos == PEG_NOT_FOUND)
326                            {
327                                plannedValueIsNull = true;
328 kumpf         1.1          }
329 kumpf         1.5          else
330 kumpf         1.1          {
331 kumpf         1.5              CIMConstProperty prop = modifiedIns.getProperty(pos);
332                                try
333                                {
334                                    prop.getValue().get(plannedValue);
335                                }
336                                catch (Exception& e)
337                                {
338                                    PEG_METHOD_EXIT();
339                                    throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
340                                }
341 kumpf         1.1          }
342                    
343                            try
344                            {
345 kumpf         1.5              //
346                                // Update the current value, if requested
347                                //
348 kumpf         1.1              if (currentValueModified)
349                                {
350 yi.zhou       1.33                 preValue = _configManager->getCurrentValue(configPropertyName);
351                    
352 kumpf         1.5                  if ( !_configManager->updateCurrentValue(
353                                        configPropertyName, currentValue, currentValueIsNull) )
354 kumpf         1.1                  {
355 kumpf         1.5                      handler.complete();
356 kumpf         1.1                      PEG_METHOD_EXIT();
357 karl          1.34 
358 humberto      1.22                     throw PEGASUS_CIM_EXCEPTION_L(
359 kumpf         1.1                          CIM_ERR_FAILED,
360 karl          1.34                         MessageLoaderParms(
361                                                "ControlProviders.ConfigSettingProvider."
362                                                    "ConfigSettingProvider."
363                                                    "UPDATE_CURRENT_VALUE_FAILED",
364                                                "Failed to update the current value."));
365 kumpf         1.1                  }
366 karl          1.34                 
367                                    // It is unset, get current value which is default
368 kumpf         1.26                 if (currentValueIsNull)
369                                    {
370                                        currentValue = _configManager->getCurrentValue(
371                                            configPropertyName);
372                                    }
373                    
374                                    // send notify config change message to ProviderManager Service
375                                    _sendNotifyConfigChangeMessage(configPropertyName, 
376                                                                   currentValue,
377                                                                   true);
378 yi.zhou       1.33 
379                                   PEG_AUDIT_LOG(logSetConfigProperty(userName, configPropertyName,
380                                       preValue, currentValue, false));
381 kumpf         1.1              }
382                    
383 kumpf         1.5              //
384                                // Update the planned value, if requested
385                                //
386 kumpf         1.1              if (plannedValueModified)
387                                {
388 yi.zhou       1.33                 preValue = _configManager->getPlannedValue(configPropertyName);
389                    
390 kumpf         1.5                  if ( !_configManager->updatePlannedValue(
391                                        configPropertyName, plannedValue, plannedValueIsNull) )
392 kumpf         1.1                  {
393 karl          1.34                     handler.complete();
394 kumpf         1.1                      PEG_METHOD_EXIT();
395 karl          1.34 
396 humberto      1.22                     throw PEGASUS_CIM_EXCEPTION_L(
397 kumpf         1.1                          CIM_ERR_FAILED,
398 karl          1.34                         MessageLoaderParms(
399                                                "ControlProviders.ConfigSettingProvider."
400                                                    "ConfigSettingProvider."
401                                                    "UPDATE_PLANNED_VALUE_FAILED",
402                                                "Failed to update the planned value."));
403 kumpf         1.1                  }
404 kumpf         1.26 
405 karl          1.34                 // It is unset, get planned value which is default
406 kumpf         1.26                 if (plannedValueIsNull)
407                                    {
408                                        plannedValue = _configManager->getPlannedValue(
409                                            configPropertyName);
410                                    }
411                    
412                                    // send notify config change message to ProviderManager Service
413                                    _sendNotifyConfigChangeMessage(configPropertyName, 
414                                                                   plannedValue,
415                                                                   false);
416 yi.zhou       1.33 
417                                   PEG_AUDIT_LOG(logSetConfigProperty(userName, configPropertyName,
418                                       preValue, plannedValue, true));
419 kumpf         1.1              }
420                            }
421 david.dillard 1.27         catch (const NonDynamicConfigProperty& ndcp)
422 kumpf         1.1          {
423                                PEG_METHOD_EXIT();
424                                throw PEGASUS_CIM_EXCEPTION(
425                                    CIM_ERR_NOT_SUPPORTED, ndcp.getMessage());
426                            }
427 david.dillard 1.27         catch (const InvalidPropertyValue& ipv)
428 kumpf         1.1          {
429                                PEG_METHOD_EXIT();
430                                throw PEGASUS_CIM_EXCEPTION(
431 kumpf         1.5                  CIM_ERR_FAILED, ipv.getMessage());
432 kumpf         1.1          }
433 david.dillard 1.27         catch (const UnrecognizedConfigProperty&)
434 kumpf         1.1          {
435                                PEG_METHOD_EXIT();
436 humberto      1.22             throw PEGASUS_CIM_EXCEPTION_L(
437 kumpf         1.3                  CIM_ERR_NOT_FOUND,
438 karl          1.34                 MessageLoaderParms(
439                                        "ControlProviders.ConfigSettingProvider."
440                                            "ConfigSettingProvider."
441                                            "CONFIG_PROPERTY_NOT_FOUND",
442                                        "Configuration property \"$0\"", 
443                                        configPropertyName));
444 kumpf         1.1          }
445                    
446 kumpf         1.5          handler.complete();
447 kumpf         1.1          PEG_METHOD_EXIT();
448 kumpf         1.5          return;
449 kumpf         1.1      }
450                    
451                    void ConfigSettingProvider::enumerateInstances(
452 karl          1.34     const OperationContext & context,
453                        const CIMObjectPath & ref,
454                        const Boolean includeQualifiers,
455                        const Boolean includeClassOrigin,
456                        const CIMPropertyList& propertyList,
457                        InstanceResponseHandler & handler)
458 kumpf         1.1      {
459 karl          1.34         PEG_METHOD_ENTER(TRC_CONFIG,
460                                             "ConfigSettingProvider::enumerateInstances()");
461 kumpf         1.1  
462                            Array<CIMInstance> instanceArray;
463                            Array<String> propertyNames;
464                    
465                            //
466                            // check if the class name requested is PG_ConfigSetting
467                            //
468 kumpf         1.17         if (!ref.getClassName().equal (PG_CONFIG_SETTING))
469 kumpf         1.1          {
470                                PEG_METHOD_EXIT();
471 kumpf         1.5              throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
472 kumpf         1.17                                         ref.getClassName().getString());
473 kumpf         1.1          }
474                    
475 karl          1.34         // begin processing the request
476                            handler.processing();
477 kumpf         1.1  
478                            try
479                            {
480 kumpf         1.25             _configManager->getAllPropertyNames(propertyNames, false);
481 kumpf         1.1  
482 kumpf         1.19 
483 kumpf         1.1              for (Uint32 i = 0; i < propertyNames.size(); i++)
484                                {
485 kumpf         1.23                  Array<String> propertyInfo;
486 kumpf         1.1  
487 kumpf         1.23                  CIMInstance        instance(PG_CONFIG_SETTING);
488 kumpf         1.1  
489 kumpf         1.23                  propertyInfo.clear();
490 kumpf         1.1  
491 kumpf         1.23                  _configManager->getPropertyInfo(
492                                     propertyNames[i], propertyInfo);
493 kumpf         1.1  
494 kumpf         1.23                  Array<CIMKeyBinding> keyBindings;
495                                     keyBindings.append(CIMKeyBinding(PROPERTY_NAME, 
496                                     propertyInfo[0], CIMKeyBinding::STRING));
497                                     CIMObjectPath instanceName(ref.getHost(), 
498                                     ref.getNameSpace(),
499                                     PG_CONFIG_SETTING, keyBindings);
500 kumpf         1.19 
501 kumpf         1.23                  // construct the instance
502                                     instance.addProperty(CIMProperty(PROPERTY_NAME, 
503 kumpf         1.19                                          propertyInfo[0]));
504 kumpf         1.23                  instance.addProperty(CIMProperty(DEFAULT_VALUE, 
505 kumpf         1.19                                          propertyInfo[1]));
506 kumpf         1.23                  instance.addProperty(CIMProperty(CURRENT_VALUE, 
507 kumpf         1.19                                          propertyInfo[2]));
508 kumpf         1.23                  instance.addProperty(CIMProperty(PLANNED_VALUE, 
509 kumpf         1.19                                          propertyInfo[3]));
510 kumpf         1.23                  instance.addProperty(CIMProperty(DYNAMIC_PROPERTY,
511                                     Boolean(propertyInfo[4]=="true"?true:false)));
512 kumpf         1.1  
513 kumpf         1.23                  instance.setPath(instanceName);
514                                     instanceArray.append(instance);
515 kumpf         1.1              }
516                            }
517                            catch(Exception& e)
518                            {
519                                PEG_METHOD_EXIT();
520                                throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
521                            }
522                    
523 karl          1.34         handler.deliver(instanceArray);
524 kumpf         1.1  
525 karl          1.34         // complete processing the request
526                            handler.complete();
527 kumpf         1.1  
528                            PEG_METHOD_EXIT();
529                        }
530                    
531                    void ConfigSettingProvider::enumerateInstanceNames(
532 karl          1.34     const OperationContext & context,
533                        const CIMObjectPath & classReference,
534                        ObjectPathResponseHandler & handler)
535 kumpf         1.1      {
536                            PEG_METHOD_ENTER(TRC_CONFIG,
537                                "ConfigSettingProvider::enumerateInstanceNames()");
538                    
539 kumpf         1.6          Array<CIMObjectPath> instanceRefs;
540 kumpf         1.1          Array<String>       propertyNames;
541 kumpf         1.16         Array<CIMKeyBinding>   keyBindings;
542                            CIMKeyBinding          kb;
543 kumpf         1.1          String              hostName;
544                    
545                            hostName.assign(System::getHostName());
546                    
547 karl          1.34         const CIMName& className = classReference.getClassName();
548                            const CIMNamespaceName& nameSpace = classReference.getNameSpace();
549 kumpf         1.1  
550 kumpf         1.17         if (!className.equal (PG_CONFIG_SETTING))
551 kumpf         1.1          {
552                                PEG_METHOD_EXIT();
553 kumpf         1.17             throw PEGASUS_CIM_EXCEPTION( CIM_ERR_NOT_SUPPORTED, 
554                                    className.getString());
555 kumpf         1.1          }
556                    
557 karl          1.34         // begin processing the request
558                            handler.processing();
559 kumpf         1.1  
560                            try
561                            {
562 kumpf         1.25             _configManager->getAllPropertyNames(propertyNames, false);
563 kumpf         1.1  
564                                Uint32 size = propertyNames.size();
565                    
566                                for (Uint32 i = 0; i < size; i++)
567                                {
568 kumpf         1.23                  keyBindings.append(
569                                                  CIMKeyBinding(PROPERTY_NAME, propertyNames[i],
570                                                  CIMKeyBinding::STRING));
571                    
572                                     //
573                                     // Convert instance names to References
574                                     //
575                                     CIMObjectPath ref(hostName, nameSpace, className, 
576                                                        keyBindings);
577 kumpf         1.1  
578 kumpf         1.23                  instanceRefs.append(ref);
579                                     keyBindings.clear();
580 kumpf         1.1  
581                                }
582                            }
583                            catch(Exception& e)
584                            {
585                                PEG_METHOD_EXIT();
586                                throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
587                            }
588                    
589 karl          1.34         handler.deliver(instanceRefs);
590 kumpf         1.1  
591 karl          1.34         // complete processing the request
592                            handler.complete();
593 kumpf         1.7  
594                            PEG_METHOD_EXIT();
595                        }
596                    
597                    //
598                    // Verify user authorization
599                    //
600                    void ConfigSettingProvider::_verifyAuthorization(const String& userName)
601                        {
602                            PEG_METHOD_ENTER(TRC_CONFIG,
603                                "ConfigSettingProvider::_verifyAuthorization()");
604                    
605                            if ( System::isPrivilegedUser(userName) == false )
606                            {
607                                PEG_METHOD_EXIT();
608 humberto      1.22             throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED,
609 karl          1.34                 MessageLoaderParms(
610                                        "ControlProviders.ConfigSettingProvider."
611                                            "ConfigSettingProvider."
612                                            "USER_NOT_PRIVILEGED",
613                                        "Must be a privileged user to do this CIM operation."));
614 kumpf         1.7          }
615 kumpf         1.1  
616                            PEG_METHOD_EXIT();
617                        }
618                    
619 kumpf         1.26 //
620                    // send notify config change message to provider manager service
621                    //
622                    void ConfigSettingProvider::_sendNotifyConfigChangeMessage(
623                        const String& propertyName,
624                        const String& newPropertyValue,
625                        Boolean currentValueModified)
626                    {
627                        PEG_METHOD_ENTER(TRC_CONFIG,
628                            "ConfigSettingProvider::_sendNotifyConfigChangeMessage");
629                    
630 kumpf         1.32     ModuleController* controller = ModuleController::getModuleController();
631 kumpf         1.26 
632                        MessageQueue * queue = MessageQueue::lookup(
633                            PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP);
634                    
635                        MessageQueueService * service = dynamic_cast<MessageQueueService *>(queue);
636                    
637                        if (service != NULL)
638                        {
639                            // create CIMNotifyConfigChangeRequestMessage
640                            CIMNotifyConfigChangeRequestMessage * notify_req =
641                                new CIMNotifyConfigChangeRequestMessage (
642                                XmlWriter::getNextMessageId (),
643                                propertyName,
644                                newPropertyValue,
645                                currentValueModified,
646                                QueueIdStack(service->getQueueId()));
647                    
648                            // create request envelope
649                            AsyncLegacyOperationStart asyncRequest(
650                                NULL,
651                                service->getQueueId(),
652 kumpf         1.26             notify_req,
653                                service->getQueueId());
654                    
655                            AutoPtr<AsyncReply> asyncReply( 
656 kumpf         1.32             controller->ClientSendWait(service->getQueueId(), &asyncRequest));
657 kumpf         1.26 
658                            AutoPtr<CIMNotifyConfigChangeResponseMessage> response(
659                                reinterpret_cast<CIMNotifyConfigChangeResponseMessage *>(
660                                (static_cast<AsyncLegacyOperationResult *>
661                                (asyncReply.get()))->get_result()));
662                    
663                            if (response->cimException.getCode() != CIM_ERR_SUCCESS)
664                            {
665                                CIMException e = response->cimException;
666                                throw (e);
667 karl          1.34         }
668 kumpf         1.26     }
669                    }
670                    
671 kumpf         1.1  PEGASUS_NAMESPACE_END
672                    

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2