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