1 martin 1.25 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.26 //
|
3 martin 1.25 // 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.26 //
|
10 martin 1.25 // 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.26 //
|
17 martin 1.25 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.26 //
|
20 martin 1.25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.26 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.25 // 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.26 //
|
28 martin 1.25 //////////////////////////////////////////////////////////////////////////
|
29 mike 1.2 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32
33 ///////////////////////////////////////////////////////////////////////////////
|
34 kumpf 1.22 //
|
35 mike 1.2 // This file has implementation for the timeout property owner class.
36 //
37 ///////////////////////////////////////////////////////////////////////////////
38
39 #include <Pegasus/Common/FileSystem.h>
|
40 kumpf 1.23 #include <Pegasus/Common/Constants.h>
|
41 mike 1.2 #include "ShutdownPropertyOwner.h"
42
43
44 PEGASUS_USING_STD;
45
46 PEGASUS_NAMESPACE_BEGIN
47
48 ///////////////////////////////////////////////////////////////////////////////
49 // ShutdownPropertyOwner
50 //
|
51 kumpf 1.3 // The shutdownTimeout property is the timeout value in seconds that the
|
52 kumpf 1.6 // cimom uses to wait for all the outstanding CIM operations to complete
|
53 carolann.graves 1.20 // before shutting down the cimserver. The default value is 30 seconds.
|
54 kumpf 1.3 //
|
55 mike 1.2 // When a new timeout property is added, make sure to add the property name
56 // and the default attributes of that property in the table below.
|
57 kumpf 1.3 //
|
58 mike 1.2 ///////////////////////////////////////////////////////////////////////////////
59
60 static struct ConfigPropertyRow properties[] =
61 {
|
62 kumpf 1.23 {"shutdownTimeout", PEGASUS_DEFAULT_SHUTDOWN_TIMEOUT_SECONDS_STRING,
|
63 kumpf 1.27 IS_DYNAMIC, 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 kavita.gupta 1.28 if (String::equal(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 kumpf 1.22 _shutdownTimeout->externallyVisible =
95 properties[i].externallyVisible;
|
96 mike 1.2 }
97 }
98 }
99
|
100 kumpf 1.5 struct ConfigProperty* ShutdownPropertyOwner::_lookupConfigProperty(
|
101 aruran.ms 1.19 const String& name) const
|
102 kumpf 1.5 {
|
103 kavita.gupta 1.28 if (String::equal(_shutdownTimeout->propertyName, name))
|
104 kumpf 1.5 {
|
105 a.arora 1.13 return _shutdownTimeout.get();
|
106 kumpf 1.5 }
107 else
108 {
109 throw UnrecognizedConfigProperty(name);
110 }
111 }
112
|
113 kumpf 1.22 /**
114 Get information about the specified property.
|
115 mike 1.2 */
116 void ShutdownPropertyOwner::getPropertyInfo(
|
117 kumpf 1.22 const String& name,
|
118 vijay.eli 1.18 Array<String>& propertyInfo) const
|
119 mike 1.2 {
|
120 aruran.ms 1.19 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
121 kumpf 1.5
|
122 karl 1.32 buildPropertyInfo(name, configProperty, propertyInfo);
|
123 mike 1.2 }
124
|
125 kumpf 1.22 /**
126 Get default value of the specified property.
|
127 mike 1.2 */
|
128 vijay.eli 1.18 String ShutdownPropertyOwner::getDefaultValue(const String& name) const
|
129 mike 1.2 {
|
130 aruran.ms 1.19 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
131 kumpf 1.5 return configProperty->defaultValue;
|
132 mike 1.2 }
133
|
134 kumpf 1.22 /**
135 Get current value of the specified property.
|
136 mike 1.2 */
|
137 vijay.eli 1.18 String ShutdownPropertyOwner::getCurrentValue(const String& name) const
|
138 mike 1.2 {
|
139 aruran.ms 1.19 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
140 kumpf 1.5 return configProperty->currentValue;
|
141 mike 1.2 }
142
|
143 kumpf 1.22 /**
144 Get planned value of the specified property.
|
145 mike 1.2 */
|
146 vijay.eli 1.18 String ShutdownPropertyOwner::getPlannedValue(const String& name) const
|
147 mike 1.2 {
|
148 aruran.ms 1.19 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
149 kumpf 1.5 return configProperty->plannedValue;
|
150 mike 1.2 }
151
|
152 kumpf 1.22 /**
153 Init current value of the specified property to the specified value.
|
154 mike 1.2 */
155 void ShutdownPropertyOwner::initCurrentValue(
|
156 kumpf 1.22 const String& name,
|
157 mike 1.2 const String& value)
158 {
|
159 kumpf 1.5 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
160 configProperty->currentValue = value;
|
161 mike 1.2 }
162
163
|
164 kumpf 1.22 /**
165 Init planned value of the specified property to the specified value.
|
166 mike 1.2 */
167 void ShutdownPropertyOwner::initPlannedValue(
|
168 kumpf 1.22 const String& name,
|
169 mike 1.2 const String& value)
170 {
|
171 kumpf 1.5 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
172 configProperty->plannedValue = value;
|
173 mike 1.2 }
174
|
175 kumpf 1.22 /**
176 Update current value of the specified property to the specified value.
|
177 mike 1.2 */
178 void ShutdownPropertyOwner::updateCurrentValue(
|
179 kumpf 1.22 const String& name,
|
180 venkat.puvvada 1.29 const String& value,
|
181 venkat.puvvada 1.30 const String& userName,
182 Uint32 timeoutSeconds)
|
183 mike 1.2 {
|
184 ashok.pathak 1.31 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
185
|
186 mike 1.2 //
187 // make sure the property is dynamic before updating the value.
188 //
|
189 ashok.pathak 1.31 if (configProperty->dynamic != IS_DYNAMIC)
|
190 mike 1.2 {
|
191 kumpf 1.22 throw NonDynamicConfigProperty(name);
|
192 mike 1.2 }
|
193 karl 1.32
|
194 ashok.pathak 1.31 configProperty->currentValue = value;
|
195 mike 1.2 }
196
197
|
198 kumpf 1.22 /**
199 Update planned value of the specified property to the specified value.
|
200 mike 1.2 */
201 void ShutdownPropertyOwner::updatePlannedValue(
|
202 kumpf 1.22 const String& name,
|
203 mike 1.2 const String& value)
204 {
205 //
206 // Since the validations done in initPlannedValue are sufficient and
207 // no additional validations required for update, we will call
208 // initPlannedValue.
209 //
210 initPlannedValue(name, value);
211 }
212
|
213 kumpf 1.22 /**
214 Checks to see if the given value is valid or not.
|
215 mike 1.2 */
|
216 kumpf 1.22 Boolean ShutdownPropertyOwner::isValid(
217 const String& name,
218 const String& value) const
|
219 mike 1.2 {
220 //
221 // convert timeout string to integer
222 //
|
223 kumpf 1.10 long timeoutValue = strtol(value.getCString(), (char **)0, 10);
|
224 mike 1.2
|
225 kavita.gupta 1.28 if (String::equal(_shutdownTimeout->propertyName, name))
|
226 mike 1.2 {
227 // Check if the timeout value is greater than the minimum allowed
228 //
|
229 kavita.gupta 1.24 if ( timeoutValue >= MIN_SHUTDOWN_TIMEOUT )
|
230 mike 1.2 {
231 return true;
232 }
233 else
234 {
235 return false;
236 }
237 }
238 else
239 {
240 throw UnrecognizedConfigProperty(name);
241 }
242 }
243
|
244 kumpf 1.22 /**
245 Checks to see if the specified property is dynamic or not.
|
246 mike 1.2 */
|
247 vijay.eli 1.18 Boolean ShutdownPropertyOwner::isDynamic(const String& name) const
|
248 mike 1.2 {
|
249 kumpf 1.22 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
250 return (configProperty->dynamic == IS_DYNAMIC);
|
251 mike 1.2 }
252
253 PEGASUS_NAMESPACE_END
|