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

  1 karl  1.21 //%2006////////////////////////////////////////////////////////////////////////
  2 mike  1.2  //
  3 karl  1.14 // 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.12 // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.14 // 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.16 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.21 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 mike  1.2  //
 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 kumpf 1.8  // 
 21 mike  1.2  // 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.8  //==============================================================================
 31 mike  1.2  //
 32            //%/////////////////////////////////////////////////////////////////////////////
 33            
 34            
 35            ///////////////////////////////////////////////////////////////////////////////
 36 kumpf 1.22 //
 37 mike  1.2  // This file has implementation for the timeout property owner class.
 38            //
 39            ///////////////////////////////////////////////////////////////////////////////
 40            
 41            #include <Pegasus/Common/FileSystem.h>
 42            #include "ShutdownPropertyOwner.h"
 43            
 44            
 45            PEGASUS_USING_STD;
 46            
 47            PEGASUS_NAMESPACE_BEGIN
 48            
 49            ///////////////////////////////////////////////////////////////////////////////
 50            //  ShutdownPropertyOwner
 51            //
 52 kumpf 1.3  //  The shutdownTimeout property is the timeout value in seconds that the
 53 kumpf 1.6  //  cimom uses to wait for all the outstanding CIM operations to complete
 54 carolann.graves 1.20 //  before shutting down the cimserver.  The default value is 30 seconds.
 55 kumpf           1.3  //
 56 mike            1.2  //  When a new timeout property is added, make sure to add the property name
 57                      //  and the default attributes of that property in the table below.
 58 kumpf           1.3  //
 59 mike            1.2  ///////////////////////////////////////////////////////////////////////////////
 60                      
 61                      static struct ConfigPropertyRow properties[] =
 62                      {
 63 carolann.graves 1.20     {"shutdownTimeout", "30", IS_DYNAMIC, 0, 0, IS_VISIBLE},
 64 mike            1.2  };
 65                      
 66                      const Uint32 NUM_PROPERTIES = sizeof(properties) / sizeof(properties[0]);
 67                      
 68 kumpf           1.7  static long MIN_SHUTDOWN_TIMEOUT = 2;
 69 mike            1.2  
 70                      /** Constructor  */
 71                      ShutdownPropertyOwner::ShutdownPropertyOwner()
 72                      {
 73 a.arora         1.13     _shutdownTimeout.reset(new ConfigProperty);
 74 mike            1.2  }
 75                      
 76                      
 77                      /**
 78 kumpf           1.22     Initialize the config properties.
 79 mike            1.2  */
 80                      void ShutdownPropertyOwner::initialize()
 81                      {
 82                          for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
 83                          {
 84                              //
 85                              // Initialize the properties with default values
 86                              //
 87 kumpf           1.6          if (String::equalNoCase(properties[i].propertyName, "shutdownTimeout"))
 88 mike            1.2          {
 89                                  _shutdownTimeout->propertyName = properties[i].propertyName;
 90                                  _shutdownTimeout->defaultValue = properties[i].defaultValue;
 91                                  _shutdownTimeout->currentValue = properties[i].defaultValue;
 92                                  _shutdownTimeout->plannedValue = properties[i].defaultValue;
 93                                  _shutdownTimeout->dynamic = properties[i].dynamic;
 94                                  _shutdownTimeout->domain = properties[i].domain;
 95                                  _shutdownTimeout->domainSize = properties[i].domainSize;
 96 kumpf           1.22             _shutdownTimeout->externallyVisible =
 97                                      properties[i].externallyVisible;
 98 mike            1.2          }
 99                          }
100                      }
101                      
102 kumpf           1.5  struct ConfigProperty* ShutdownPropertyOwner::_lookupConfigProperty(
103 aruran.ms       1.19     const String& name) const
104 kumpf           1.5  {
105 kumpf           1.6      if (String::equalNoCase(_shutdownTimeout->propertyName, name))
106 kumpf           1.5      {
107 a.arora         1.13         return _shutdownTimeout.get();
108 kumpf           1.5      }
109                          else
110                          {
111                              throw UnrecognizedConfigProperty(name);
112                          }
113                      }
114                      
115 kumpf           1.22 /**
116                          Get information about the specified property.
117 mike            1.2  */
118                      void ShutdownPropertyOwner::getPropertyInfo(
119 kumpf           1.22     const String& name,
120 vijay.eli       1.18     Array<String>& propertyInfo) const
121 mike            1.2  {
122                          propertyInfo.clear();
123 aruran.ms       1.19     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
124 kumpf           1.5  
125                          propertyInfo.append(configProperty->propertyName);
126                          propertyInfo.append(configProperty->defaultValue);
127                          propertyInfo.append(configProperty->currentValue);
128                          propertyInfo.append(configProperty->plannedValue);
129                          if (configProperty->dynamic)
130 kumpf           1.11     {
131                              propertyInfo.append(STRING_TRUE);
132                          }
133                          else
134                          {
135                              propertyInfo.append(STRING_FALSE);
136                          }
137                          if (configProperty->externallyVisible)
138 mike            1.2      {
139 kumpf           1.5          propertyInfo.append(STRING_TRUE);
140 mike            1.2      }
141                          else
142                          {
143 kumpf           1.5          propertyInfo.append(STRING_FALSE);
144 mike            1.2      }
145                      }
146                      
147 kumpf           1.22 /**
148                          Get default value of the specified property.
149 mike            1.2  */
150 vijay.eli       1.18 String ShutdownPropertyOwner::getDefaultValue(const String& name) const
151 mike            1.2  {
152 aruran.ms       1.19     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
153 kumpf           1.5      return configProperty->defaultValue;
154 mike            1.2  }
155                      
156 kumpf           1.22 /**
157                          Get current value of the specified property.
158 mike            1.2  */
159 vijay.eli       1.18 String ShutdownPropertyOwner::getCurrentValue(const String& name) const
160 mike            1.2  {
161 aruran.ms       1.19     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
162 kumpf           1.5      return configProperty->currentValue;
163 mike            1.2  }
164                      
165 kumpf           1.22 /**
166                          Get planned value of the specified property.
167 mike            1.2  */
168 vijay.eli       1.18 String ShutdownPropertyOwner::getPlannedValue(const String& name) const
169 mike            1.2  {
170 aruran.ms       1.19     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
171 kumpf           1.5      return configProperty->plannedValue;
172 mike            1.2  }
173                      
174 kumpf           1.22 /**
175                          Init current value of the specified property to the specified value.
176 mike            1.2  */
177                      void ShutdownPropertyOwner::initCurrentValue(
178 kumpf           1.22     const String& name,
179 mike            1.2      const String& value)
180                      {
181 kumpf           1.5      struct ConfigProperty* configProperty = _lookupConfigProperty(name);
182                          configProperty->currentValue = value;
183 mike            1.2  }
184                      
185                      
186 kumpf           1.22 /**
187                          Init planned value of the specified property to the specified value.
188 mike            1.2  */
189                      void ShutdownPropertyOwner::initPlannedValue(
190 kumpf           1.22     const String& name,
191 mike            1.2      const String& value)
192                      {
193 kumpf           1.5      struct ConfigProperty* configProperty = _lookupConfigProperty(name);
194                          configProperty->plannedValue = value;
195 mike            1.2  }
196                      
197 kumpf           1.22 /**
198                          Update current value of the specified property to the specified value.
199 mike            1.2  */
200                      void ShutdownPropertyOwner::updateCurrentValue(
201 kumpf           1.22     const String& name,
202                          const String& value)
203 mike            1.2  {
204                          //
205                          // make sure the property is dynamic before updating the value.
206                          //
207                          if (!isDynamic(name))
208                          {
209 kumpf           1.22         throw NonDynamicConfigProperty(name);
210 mike            1.2      }
211                      
212                          //
213                          // Since the validations done in initCurrrentValue are sufficient and
214                          // no additional validations required for update, we will call
215                          // initCurrrentValue.
216                          //
217                          initCurrentValue(name, value);
218                      }
219                      
220                      
221 kumpf           1.22 /**
222                          Update planned value of the specified property to the specified value.
223 mike            1.2  */
224                      void ShutdownPropertyOwner::updatePlannedValue(
225 kumpf           1.22     const String& name,
226 mike            1.2      const String& value)
227                      {
228                          //
229                          // Since the validations done in initPlannedValue are sufficient and
230                          // no additional validations required for update, we will call
231                          // initPlannedValue.
232                          //
233                          initPlannedValue(name, value);
234                      }
235                      
236 kumpf           1.22 /**
237                          Checks to see if the given value is valid or not.
238 mike            1.2  */
239 kumpf           1.22 Boolean ShutdownPropertyOwner::isValid(
240                          const String& name,
241                          const String& value) const
242 mike            1.2  {
243                          //
244                          // convert timeout string to integer
245                          //
246 kumpf           1.10     long timeoutValue = strtol(value.getCString(), (char **)0, 10);
247 mike            1.2  
248 kumpf           1.6      if (String::equalNoCase(_shutdownTimeout->propertyName, name))
249 mike            1.2      {
250                              // Check if the timeout value is greater than the minimum allowed
251                              //
252                              if ( timeoutValue > MIN_SHUTDOWN_TIMEOUT )
253                              {
254                                  return true;
255                              }
256                              else
257                              {
258                                  return false;
259                              }
260                          }
261                          else
262                          {
263                              throw UnrecognizedConfigProperty(name);
264                          }
265                      }
266                      
267 kumpf           1.22 /**
268                          Checks to see if the specified property is dynamic or not.
269 mike            1.2  */
270 vijay.eli       1.18 Boolean ShutdownPropertyOwner::isDynamic(const String& name) const
271 mike            1.2  {
272 kumpf           1.22     struct ConfigProperty* configProperty = _lookupConfigProperty(name);
273                          return (configProperty->dynamic == IS_DYNAMIC);
274 mike            1.2  }
275                      
276                      PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2