1 martin 1.106 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.107 //
|
3 martin 1.106 // 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.107 //
|
10 martin 1.106 // 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.107 //
|
17 martin 1.106 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.107 //
|
20 martin 1.106 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.107 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.106 // 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.107 //
|
28 martin 1.106 //////////////////////////////////////////////////////////////////////////
|
29 mike 1.2 //
30 //%////////////////////////////////////////////////////////////////////////////
31
32
33 /////////////////////////////////////////////////////////////////////////////
|
34 chip 1.68 // ConfigManager
|
35 mike 1.2 /////////////////////////////////////////////////////////////////////////////
36
|
37 kumpf 1.20 #include <Pegasus/Common/Tracer.h>
|
38 thilo.boehm 1.87 #include <Pegasus/Common/Logger.h>
|
39 kumpf 1.12 #include <Pegasus/Common/PegasusVersion.h>
|
40 tony 1.32 #include <Pegasus/Common/FileSystem.h>
|
41 kumpf 1.81 #include <Pegasus/Common/Constants.h>
|
42 karl 1.128 #include <Pegasus/Common/StringConversion.h>
|
43 kumpf 1.12
|
44 mike 1.2 #include "ConfigExceptions.h"
45 #include "ConfigManager.h"
46
47 PEGASUS_NAMESPACE_BEGIN
48
49 /////////////////////////////////////////////////////////////////////////////
50 //
51 // When a new property owner is created be sure to create a static
52 // object of the new property owner.
53 //
54 /////////////////////////////////////////////////////////////////////////////
55
|
56 kumpf 1.96 TracePropertyOwner ConfigManager::traceOwner;
57 LogPropertyOwner ConfigManager::logOwner;
58 DefaultPropertyOwner ConfigManager::defaultOwner;
59 SecurityPropertyOwner ConfigManager::securityOwner;
60 RepositoryPropertyOwner ConfigManager::repositoryOwner;
61 ShutdownPropertyOwner ConfigManager::shutdownOwner;
62 FileSystemPropertyOwner ConfigManager::fileSystemOwner;
63 ProviderDirPropertyOwner ConfigManager::providerDirOwner;
64 NormalizationPropertyOwner ConfigManager::normalizationOwner;
65
|
66 venkat.puvvada 1.114 #ifdef PEGASUS_ENABLE_DMTF_INDICATION_PROFILE_SUPPORT
67 IndicationServicePropertyOwner ConfigManager::indicationServiceOwner;
68 #endif
|
69 mike 1.2
70 /////////////////////////////////////////////////////////////////////////////
71 //
|
72 chip 1.68 // When a new property is created be sure to add the new property name
|
73 kumpf 1.10 // and the owner object to the OwnerEntry table below.
|
74 mike 1.2 //
75 /////////////////////////////////////////////////////////////////////////////
76
|
77 kumpf 1.10 struct OwnerEntry
78 {
79 const char* propertyName;
80 ConfigPropertyOwner* propertyOwner;
81 };
82
|
83 kumpf 1.14 static struct OwnerEntry _properties[] =
|
84 mike 1.2 {
|
85 kumpf 1.88 {"traceLevel",
|
86 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::traceOwner},
|
87 kumpf 1.88 {"traceComponents",
|
88 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::traceOwner},
|
89 kumpf 1.88 {"traceFilePath",
|
90 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::traceOwner},
|
91 r.kieninger 1.98 {"traceFacility",
92 (ConfigPropertyOwner*)&ConfigManager::traceOwner},
|
93 thilo.boehm 1.102 {"traceMemoryBufferKbytes",
94 (ConfigPropertyOwner*)&ConfigManager::traceOwner},
|
95 amit99shah 1.121 {"traceFileSizeKBytes",
96 (ConfigPropertyOwner*)&ConfigManager::traceOwner},
97 {"numberOfTraceFiles",
98 (ConfigPropertyOwner*)&ConfigManager::traceOwner},
|
99 konrad.r 1.71 #if !defined(PEGASUS_USE_SYSLOGS)
|
100 kumpf 1.88 {"logdir",
|
101 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::logOwner},
|
102 mreddy 1.103 {"maxLogFileSizeKBytes",
103 (ConfigPropertyOwner*)&ConfigManager::logOwner},
|
104 konrad.r 1.71 #endif
|
105 kumpf 1.88 {"logLevel",
|
106 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::logOwner},
|
107 kumpf 1.88 {"enableHttpConnection",
|
108 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::defaultOwner},
|
109 kumpf 1.88 {"enableHttpsConnection",
|
110 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::defaultOwner},
|
111 kumpf 1.88 {"httpPort",
|
112 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::defaultOwner},
|
113 kumpf 1.88 {"httpsPort",
|
114 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::defaultOwner},
|
115 kumpf 1.88 {"daemon",
|
116 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::defaultOwner},
|
117 s.kodali 1.104 #ifdef PEGASUS_ENABLE_SLP
|
118 kumpf 1.88 {"slp",
|
119 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::defaultOwner},
|
120 marek 1.120 {"slpProviderStartupTimeout",
121 (ConfigPropertyOwner*)&ConfigManager::defaultOwner},
|
122 s.kodali 1.104 #endif
|
123 kumpf 1.88 {"enableAssociationTraversal",
|
124 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::defaultOwner},
|
125 kumpf 1.88 {"enableIndicationService",
|
126 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::defaultOwner},
|
127 kumpf 1.88 {"enableAuthentication",
|
128 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::securityOwner},
|
129 kumpf 1.88 {"enableNamespaceAuthorization",
|
130 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::securityOwner},
|
131 kumpf 1.88 {"httpAuthType",
|
132 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::securityOwner},
|
133 kumpf 1.88 {"passwordFilePath",
|
134 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::securityOwner},
|
135 kumpf 1.88 {"sslCertificateFilePath",
|
136 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::securityOwner},
|
137 kumpf 1.88 {"sslKeyFilePath",
|
138 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::securityOwner},
|
139 kumpf 1.88 {"sslTrustStore",
|
140 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::securityOwner},
|
141 ashok.pathak 1.123 {"sslBackwardCompatibility",
142 (ConfigPropertyOwner*)&ConfigManager::securityOwner},
|
143 sushma.fernandes 1.79 #ifdef PEGASUS_ENABLE_SSL_CRL_VERIFICATION
|
144 kumpf 1.88 {"crlStore",
|
145 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::securityOwner},
|
146 sushma.fernandes 1.79 #endif
|
147 kumpf 1.88 {"sslClientVerificationMode",
|
148 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::securityOwner},
|
149 kumpf 1.88 {"sslTrustStoreUserName",
|
150 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::securityOwner},
|
151 thilo.boehm 1.94 #ifdef PEGASUS_OS_ZOS
152 {"enableCFZAPPLID",
|
153 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::securityOwner},
|
154 thilo.boehm 1.94 #endif
|
155 rohini.deshpande 1.115 {"sslCipherSuite",
156 (ConfigPropertyOwner*)&ConfigManager::securityOwner},
|
157 kumpf 1.88 {"repositoryIsDefaultInstanceProvider",
|
158 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::repositoryOwner},
|
159 kumpf 1.88 {"enableBinaryRepository",
|
160 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::repositoryOwner},
|
161 kumpf 1.88 {"shutdownTimeout",
|
162 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::shutdownOwner},
|
163 kumpf 1.88 {"repositoryDir",
|
164 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::fileSystemOwner},
|
165 b.whiteley 1.97 {"providerManagerDir",
166 (ConfigPropertyOwner*)&ConfigManager::fileSystemOwner},
|
167 kumpf 1.88 {"providerDir",
|
168 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::providerDirOwner},
|
169 kumpf 1.88 {"enableRemotePrivilegedUserAccess",
|
170 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::securityOwner},
|
171 kumpf 1.88 {"enableSubscriptionsForNonprivilegedUsers",
|
172 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::securityOwner},
|
173 kumpf 1.57 #ifdef PEGASUS_ENABLE_USERGROUP_AUTHORIZATION
|
174 kumpf 1.88 {"authorizedUserGroups",
|
175 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::securityOwner},
|
176 kumpf 1.57 #endif
|
177 kumpf 1.88 {"messageDir",
|
178 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::fileSystemOwner},
|
179 chip 1.68 #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
|
180 kumpf 1.88 {"enableNormalization",
|
181 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::normalizationOwner},
|
182 kumpf 1.88 {"excludeModulesFromNormalization",
|
183 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::normalizationOwner},
|
184 chip 1.68 #endif
|
185 kumpf 1.88 {"forceProviderProcesses",
|
186 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::defaultOwner},
|
187 kumpf 1.88 {"maxProviderProcesses",
|
188 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::defaultOwner},
|
189 kumpf 1.91 #ifdef PEGASUS_ENABLE_AUDIT_LOGGER
|
190 kumpf 1.88 {"enableAuditLog",
|
191 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::defaultOwner},
|
192 yi.zhou 1.86 #endif
|
193 lawrence.luo 1.124 #ifdef PEGASUS_ENABLE_PROTOCOL_WEB
194 {"webRoot",
195 (ConfigPropertyOwner*)&ConfigManager::defaultOwner},
196 {"indexFile",
197 (ConfigPropertyOwner*)&ConfigManager::defaultOwner},
198 {"mimeTypesFile",
199 (ConfigPropertyOwner*)&ConfigManager::defaultOwner},
200 #endif
|
201 kumpf 1.88 {"socketWriteTimeout",
|
202 kumpf 1.96 (ConfigPropertyOwner*)&ConfigManager::defaultOwner},
|
203 dave.sudlik 1.95 {"idleConnectionTimeout",
|
204 venkat.puvvada 1.113 (ConfigPropertyOwner*)&ConfigManager::defaultOwner},
205 {"maxFailedProviderModuleRestarts",
|
206 dev.meetei 1.116 (ConfigPropertyOwner*)&ConfigManager::defaultOwner},
207 {"listenAddress",
|
208 marek 1.117 (ConfigPropertyOwner*)&ConfigManager::defaultOwner},
209 {"hostname",
210 (ConfigPropertyOwner*)&ConfigManager::defaultOwner},
211 {"fullyQualifiedHostName",
|
212 jsafrane 1.129 (ConfigPropertyOwner*)&ConfigManager::defaultOwner}
213
214 #ifdef PEGASUS_ENABLE_SESSION_COOKIES
215 ,{"httpSessionTimeout",
|
216 jsafrane 1.127 (ConfigPropertyOwner*)&ConfigManager::securityOwner}
|
217 jsafrane 1.129 #endif
|
218 dev.meetei 1.116
|
219 venkat.puvvada 1.114 #ifdef PEGASUS_ENABLE_DMTF_INDICATION_PROFILE_SUPPORT
220 ,{"maxIndicationDeliveryRetryAttempts",
221 (ConfigPropertyOwner*)&ConfigManager::indicationServiceOwner},
222 {"minIndicationDeliveryRetryInterval",
223 (ConfigPropertyOwner*)&ConfigManager::indicationServiceOwner}
224 #endif
|
225 jsafrane 1.126
226 #ifdef PEGASUS_NEGOTIATE_AUTHENTICATION
227 ,{"mapToLocalName",
228 (ConfigPropertyOwner*)&ConfigManager::securityOwner}
229 #endif
|
230 karl 1.128 ,{"pullOperationsMaxObjectCount",
231 (ConfigPropertyOwner*)&ConfigManager::defaultOwner},
232 {"pullOperationsMaxTimeout",
233 (ConfigPropertyOwner*)&ConfigManager::defaultOwner},
234 {"pullOperationsDefaultTimeout",
235 (ConfigPropertyOwner*)&ConfigManager::defaultOwner}
|
236 mike 1.2 };
237
|
238 lawrence.luo 1.124 const Uint32 NUM_PROPERTIES = sizeof(_properties) / sizeof(_properties[0]);
|
239 kumpf 1.10
240
241 /////////////////////////////////////////////////////////////////////////////
242 //
243 // To use a fixed value for a property rather than delegating to a property
244 // owner, add the property to the FixedValueEntry table below. An entry in
245 // the OwnerEntry table above for this same property will be initialized
246 // and given the (fixed) initial current value, but will thereafter be
247 // ignored.
248 //
249 // Fixed values are only returned by getDefaultValue(), getCurrentValue(),
250 // and getPlannedValue(). All other methods will treat fixed properties as
251 // unrecognized properties.
252 //
253 /////////////////////////////////////////////////////////////////////////////
254
255 struct FixedValueEntry
256 {
257 const char* propertyName;
258 const char* fixedValue;
259 };
260 kumpf 1.10
|
261 kumpf 1.14 static struct FixedValueEntry _fixedValues[] =
|
262 kumpf 1.10 {
|
263 kumpf 1.28 #include "FixedPropertyTable.h"
|
264 kumpf 1.10 };
265
|
266 chip 1.68 const Uint32 NUM_FIXED_PROPERTIES =
|
267 lawrence.luo 1.124 sizeof(_fixedValues) / sizeof( _fixedValues[0]);
|
268 kumpf 1.10
|
269 mike 1.2
|
270 kumpf 1.6 /**
|
271 kumpf 1.88 Initialize the default PEGASUS_HOME location, the default is set to the
272 current directory.
|
273 kumpf 1.6 */
|
274 kumpf 1.88 const String ConfigManager::PEGASUS_HOME_DEFAULT = ".";
|
275 mike 1.2
|
276 kumpf 1.6 String ConfigManager::_pegasusHome = PEGASUS_HOME_DEFAULT;
|
277 mike 1.2
|
278 kumpf 1.59 //
|
279 kumpf 1.96 // The singleton ConfigManager instance
|
280 kumpf 1.59 //
|
281 kumpf 1.96 AutoPtr<ConfigManager> ConfigManager::_instance;
|
282 mike 1.2
283
284 /** Constructor. */
|
285 kumpf 1.59 ConfigManager::ConfigManager()
286 : useConfigFiles(false)
|
287 mike 1.2 {
288 //
289 // Initialize the instance variables
290 //
|
291 a.arora 1.58 _propertyTable.reset(new PropertyTable);
|
292 mike 1.2
293 //
294 // Initialize the property owners
295 //
|
296 kumpf 1.10 _initPropertyTable();
|
297 mike 1.2 }
298
|
299 konrad.r 1.75 /**
|
300 kumpf 1.59 Get a reference to the singleton ConfigManager instance. If no
301 ConfigManager instance exists, construct one.
|
302 mike 1.2 */
|
303 chip 1.68 ConfigManager* ConfigManager::getInstance()
|
304 mike 1.2 {
|
305 kumpf 1.96 if (!_instance.get())
|
306 mike 1.2 {
|
307 kumpf 1.96 _instance.reset(new ConfigManager());
|
308 mike 1.2 }
|
309 kumpf 1.96 return _instance.get();
|
310 mike 1.2 }
311
312
|
313 chip 1.68 /**
|
314 kumpf 1.59 Initialize the current value of a config property
315 */
316 Boolean ConfigManager::initCurrentValue(
317 const String& propertyName,
318 const String& propertyValue)
319 {
320 ConfigPropertyOwner* propertyOwner = 0;
321
322 //
323 // get property owner object from the config table.
324 //
325 if (!_propertyTable->ownerTable.lookup(propertyName, propertyOwner))
326 {
|
327 chip 1.68 throw UnrecognizedConfigProperty(propertyName);
|
328 kumpf 1.59 }
329
|
330 kumpf 1.73 if (useConfigFiles && !propertyOwner->isValid(propertyName, propertyValue))
331 {
332 throw InvalidPropertyValue(propertyName, propertyValue);
333 }
334
335 //
336 // update the value with the property owner
337 //
338 propertyOwner->initCurrentValue(propertyName, propertyValue);
339
|
340 lawrence.luo 1.124 Boolean success = true;
|
341 kumpf 1.73 if (useConfigFiles)
|
342 kumpf 1.59 {
|
343 thilo.boehm 1.109 try
344 {
345 // update the value in the current config file
346 success = _configFileHandler->updateCurrentValue(
|
347 venkat.puvvada 1.111 propertyName,
348 propertyValue,
349 String(),
|
350 venkat.puvvada 1.112 0,
|
351 venkat.puvvada 1.111 false);
|
352 thilo.boehm 1.109 }
353 catch (Exception& e)
354 {
355 throw FailedSaveProperties(e.getMessage());
356 }
|
357 kumpf 1.59 }
|
358 thilo.boehm 1.109 return success;
|
359 kumpf 1.59 }
360
|
361 chip 1.68 /**
|
362 kumpf 1.88 Update current value of a property.
|
363 mike 1.2 */
364 Boolean ConfigManager::updateCurrentValue(
|
365 chip 1.68 const String& name,
|
366 kumpf 1.13 const String& value,
|
367 venkat.puvvada 1.111 const String& userName,
|
368 venkat.puvvada 1.112 Uint32 timeoutSeconds,
|
369 kumpf 1.13 Boolean unset)
|
370 mike 1.2 {
371
372 //
373 // get property owner object from the config table.
374 //
375 ConfigPropertyOwner* propertyOwner;
376
|
377 kumpf 1.10 if (!_propertyTable->ownerTable.lookup(name, propertyOwner))
|
378 mike 1.2 {
|
379 chip 1.68 throw UnrecognizedConfigProperty(name);
|
380 mike 1.2 }
381
|
382 kumpf 1.73 //
383 // keep a copy of the existing config value
384 //
|
385 lawrence.luo 1.124 String prevValue = propertyOwner->getCurrentValue(name);
|
386 kumpf 1.73
387 //
388 // ask owner to update the current value
389 //
390 if (unset)
|
391 mike 1.2 {
|
392 venkat.puvvada 1.111 propertyOwner->updateCurrentValue(
393 name,
394 propertyOwner->getDefaultValue(name),
|
395 venkat.puvvada 1.112 userName,
396 timeoutSeconds);
|
397 kumpf 1.73 }
398 else
399 {
400 if (useConfigFiles && !propertyOwner->isValid(name, value))
401 {
402 throw InvalidPropertyValue(name, value);
403 }
404
|
405 venkat.puvvada 1.112 propertyOwner->updateCurrentValue(
406 name, value, userName, timeoutSeconds);
|
407 kumpf 1.73 }
|
408 mike 1.2
|
409 kumpf 1.73 if (useConfigFiles)
410 {
|
411 thilo.boehm 1.109 try
412 {
413 //
414 // update the new value in the current config file
415 //
|
416 venkat.puvvada 1.111 if (!_configFileHandler->updateCurrentValue(
|
417 venkat.puvvada 1.112 name, value, userName, timeoutSeconds, unset))
|
418 thilo.boehm 1.109 {
419 // Failed to update the current value, so roll back.
|
420 venkat.puvvada 1.112 propertyOwner->updateCurrentValue(
421 name, prevValue, userName, timeoutSeconds);
|
422 thilo.boehm 1.109 return false;
423 }
424 }
425 catch (Exception& e)
|
426 mike 1.2 {
|
427 kumpf 1.73 // Failed to update the current value, so roll back.
|
428 venkat.puvvada 1.112 propertyOwner->updateCurrentValue(
429 name, prevValue, userName, timeoutSeconds);
|
430 thilo.boehm 1.109 throw FailedSaveProperties(e.getMessage());
|
431 mike 1.2 }
432 }
|
433 kumpf 1.29
|
434 kumpf 1.59 return true;
|
435 mike 1.2 }
436
437
|
438 chip 1.68 /**
|
439 mike 1.2 Update planned value of a property.
440 */
441 Boolean ConfigManager::updatePlannedValue(
|
442 chip 1.68 const String& name,
|
443 kumpf 1.13 const String& value,
444 Boolean unset)
|
445 mike 1.2 {
446
447 //
448 // get property owner object from the config table.
449 //
450 ConfigPropertyOwner* propertyOwner;
451
|
452 kumpf 1.10 if (!_propertyTable->ownerTable.lookup(name, propertyOwner))
|
453 mike 1.2 {
|
454 chip 1.68 throw UnrecognizedConfigProperty(name);
|
455 mike 1.2 }
456
|
457 kumpf 1.73 //
458 // keep a copy of the existing config value
459 //
|
460 lawrence.luo 1.124 String prevValue = propertyOwner->getPlannedValue(name);
|
461 kumpf 1.73
462 //
463 // ask owner to update the planned value to new value
464 //
465 if (unset)
466 {
467 propertyOwner->updatePlannedValue(name,
468 propertyOwner->getDefaultValue(name));
469 }
470 else
|
471 mike 1.2 {
|
472 kumpf 1.73 if (useConfigFiles && !propertyOwner->isValid(name, value))
473 {
474 throw InvalidPropertyValue(name, value);
475 }
476
477 propertyOwner->updatePlannedValue(name, value);
478 }
|
479 mike 1.2
|
480 kumpf 1.73 if (useConfigFiles)
481 {
|
482 thilo.boehm 1.109 try
483 {
484 //
485 // update the new value in the planned config file
486 //
487 if (!_configFileHandler->updatePlannedValue(name, value, unset))
488 {
489 // Failed to update the planned value, so roll back.
490 propertyOwner->updatePlannedValue(name, prevValue);
491 return false;
492 }
493 }
494 catch (Exception& e)
|
495 kumpf 1.13 {
|
496 kumpf 1.73 // Failed to update the planned value, so roll back.
497 propertyOwner->updatePlannedValue(name, prevValue);
|
498 thilo.boehm 1.109 throw FailedSaveProperties(e.getMessage());
|
499 mike 1.2 }
500 }
|
501 kumpf 1.29
|
502 kumpf 1.59 return true;
|
503 mike 1.2 }
504
505
|
506 chip 1.68 /**
|
507 mike 1.2 Validate the value of a specified property.
508 */
509 Boolean ConfigManager::validatePropertyValue(
|
510 chip 1.68 const String& name,
|
511 mike 1.2 const String& value)
512 {
513 //
514 // get property owner object from config table
515 //
516 ConfigPropertyOwner* propertyOwner;
517
|
518 kumpf 1.10 if (!_propertyTable->ownerTable.lookup(name, propertyOwner))
|
519 mike 1.2 {
|
520 chip 1.68 throw UnrecognizedConfigProperty(name);
|
521 mike 1.2 }
522
|
523 kumpf 1.88 return propertyOwner->isValid(name, value);
|
524 mike 1.2 }
525
526 /**
527 Get default value of the specified property.
528 */
|
529 aruran.ms 1.77 String ConfigManager::getDefaultValue(const String& name) const
|
530 karl 1.119 {
|
531 marek 1.118 String fixedValue;
532 if (_fixedValueCheck(name, fixedValue))
|
533 kumpf 1.10 {
534 return fixedValue;
535 }
536
537 //
|
538 mike 1.2 // get property owner object from config table
539 //
540 ConfigPropertyOwner* propertyOwner;
541
|
542 kumpf 1.10 if (!_propertyTable->ownerTable.lookup(name, propertyOwner))
|
543 mike 1.2 {
544 throw UnrecognizedConfigProperty(name);
545 }
546
|
547 kumpf 1.88 return propertyOwner->getDefaultValue(name);
|
548 mike 1.2 }
549
|
550 chip 1.68 /**
|
551 kumpf 1.88 Get current value of the specified property.
|
552 mike 1.2 */
|
553 aruran.ms 1.77 String ConfigManager::getCurrentValue(const String& name) const
|
554 mike 1.2 {
|
555 marek 1.118 String fixedValue;
556 if (_fixedValueCheck(name, fixedValue))
|
557 kumpf 1.10 {
558 return fixedValue;
559 }
560
561 //
|
562 mike 1.2 // get property owner object from config table
563 //
564 ConfigPropertyOwner* propertyOwner;
565
|
566 kumpf 1.10 if (!_propertyTable->ownerTable.lookup(name, propertyOwner))
|
567 mike 1.2 {
|
568 chip 1.68 throw UnrecognizedConfigProperty(name);
|
569 mike 1.2 }
570
|
571 kumpf 1.88 return propertyOwner->getCurrentValue(name);
|
572 mike 1.2 }
573
574
|
575 chip 1.68 /**
|
576 mike 1.2 Get planned value of the specified property.
577 */
|
578 aruran.ms 1.77 String ConfigManager::getPlannedValue(const String& name) const
|
579 mike 1.2 {
|
580 marek 1.118 String fixedValue;
581 if (_fixedValueCheck(name, fixedValue))
|
582 kumpf 1.10 {
583 return fixedValue;
584 }
585
586 //
|
587 mike 1.2 // get property owner object from config table
588 //
589 ConfigPropertyOwner* propertyOwner;
590
|
591 kumpf 1.10 if (!_propertyTable->ownerTable.lookup(name, propertyOwner))
|
592 mike 1.2 {
|
593 chip 1.68 throw UnrecognizedConfigProperty(name);
|
594 mike 1.2 }
595
|
596 kumpf 1.88 return propertyOwner->getPlannedValue(name);
|
597 mike 1.2 }
598
|
599 karl 1.119 /**
600 Get help on specified attribute
601 */
602 void ConfigManager::getPropertyHelp(
603 const String& name,
604 String& propertyHelp) const
605 {
606 //
607 // get property owner object from config table
608 //
609 ConfigPropertyOwner* propertyOwner;
610 if ( !_propertyTable->ownerTable.lookup(name,
611 propertyOwner))
612 {
613 throw UnrecognizedConfigProperty(name);
614 }
615 propertyHelp.append(propertyOwner->getPropertyHelp(name));
|
616 karl 1.122 propertyHelp.append(propertyOwner->getPropertyHelpSupplement(name));
|
617 karl 1.119 }
|
618 mike 1.2
|
619 chip 1.68 /**
|
620 mike 1.2 Get all the attributes of the specified property.
621 */
622 void ConfigManager::getPropertyInfo(
|
623 chip 1.68 const String& name,
|
624 aruran.ms 1.77 Array<String>& propertyInfo) const
|
625 mike 1.2 {
626 //
627 // get property owner object from config table
628 //
629 ConfigPropertyOwner* propertyOwner;
630
|
631 kumpf 1.10 if (!_propertyTable->ownerTable.lookup(name, propertyOwner))
|
632 mike 1.2 {
|
633 chip 1.68 throw UnrecognizedConfigProperty(name);
|
634 mike 1.2 }
635
636 propertyOwner->getPropertyInfo(name, propertyInfo);
637 }
638
639
|
640 chip 1.68 /**
|
641 mike 1.2 Get a list of all property names.
642 */
|
643 kumpf 1.59 void ConfigManager::getAllPropertyNames(
644 Array<String>& propertyNames,
|
645 aruran.ms 1.77 Boolean includeHiddenProperties) const
|
646 mike 1.2 {
|
647 kumpf 1.41 Array<String> propertyInfo;
|
648 mike 1.2 propertyNames.clear();
649
|
650 kumpf 1.10 for (OwnerTable::Iterator i = _propertyTable->ownerTable.start(); i; i++)
|
651 mike 1.2 {
|
652 kumpf 1.59 if (includeHiddenProperties)
|
653 kumpf 1.41 {
654 propertyNames.append(i.key());
655 }
|
656 kumpf 1.59 else
657 {
658 //
659 // Check if property is to be externally visible or not.
660 // If the property should not be externally visible do not list the
661 // property information.
662 //
663 propertyInfo.clear();
664 getPropertyInfo(i.key(), propertyInfo);
665
666 if (propertyInfo[5] == STRING_TRUE)
667 {
668 propertyNames.append(i.key());
669 }
670 }
|
671 mike 1.2 }
672 }
673
674
|
675 chip 1.68 /**
|
676 kumpf 1.88 Merge the config properties from the specified planned config file
677 with the properties in the specified current config file.
|
678 mike 1.2 */
679 void ConfigManager::mergeConfigFiles(
|
680 chip 1.68 const String& currentFile,
|
681 mike 1.2 const String& plannedFile)
682 {
|
683 kumpf 1.59 PEGASUS_ASSERT(useConfigFiles);
684
|
685 kumpf 1.73 _configFileHandler.reset(new ConfigFileHandler(currentFile, plannedFile));
|
686 mike 1.2
|
687 mateus.baur 1.89 //
688 // copy the contents of planned config file over
689 // the current config file
690 //
691 _configFileHandler->copyPlannedFileOverCurrentFile();
692
|
693 kumpf 1.73 _loadConfigProperties();
|
694 mike 1.2 }
695
696
|
697 chip 1.68 /**
|
698 kumpf 1.88 Merge the config properties from the default planned config file
699 with the properties in the default current config file.
|
700 mike 1.2 */
701 void ConfigManager::mergeConfigFiles()
702 {
|
703 kumpf 1.59 PEGASUS_ASSERT(useConfigFiles);
704
|
705 kumpf 1.73 _configFileHandler.reset(new ConfigFileHandler());
|
706 mike 1.2
|
707 mateus.baur 1.89 //
708 // copy the contents of planned config file over
709 // the current config file
710 //
711 _configFileHandler->copyPlannedFileOverCurrentFile();
712
713 _loadConfigProperties();
714 }
715
716
717 /**
718 Load the config properties from the current and planned files.
719 */
720 void ConfigManager::loadConfigFiles()
721 {
722 PEGASUS_ASSERT(useConfigFiles);
723
724 _configFileHandler.reset(new ConfigFileHandler());
725
|
726 kumpf 1.73 _loadConfigProperties();
|
727 mike 1.2 }
728
729
|
730 chip 1.68 /**
|
731 kumpf 1.88 Merge config properties specified on the command line
|
732 mike 1.2 */
733 void ConfigManager::mergeCommandLine(int& argc, char**& argv)
734 {
735 // Remove the command name from the command line
|
736 kumpf 1.3 if (argc > 0)
737 {
738 memmove(&argv[0], &argv[1], (argc) * sizeof(char*));
739 argc--;
740 }
|
741 mike 1.2
742 //
743 // Merge properties from the command line
744 //
|
745 kumpf 1.9 for (Sint32 i = 0; i < argc; )
|
746 mike 1.2 {
747 const char* arg = argv[i];
748
|
749 kumpf 1.34 if (*arg == '-')
750 {
751 throw UnrecognizedCommandLineOption();
752 }
753
|
754 thilo.boehm 1.109 // Set porperty with command line value.
|
755 tony 1.33 if (!_initPropertyWithCommandLineOption(arg))
|
756 mike 1.2 {
|
757 chip 1.68 throw UnrecognizedConfigProperty(arg);
|
758 mike 1.2 }
759
760 // Remove the option from the command line
761 memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
762 argc--;
763 }
764 }
765
766
|
767 chip 1.68 /**
|
768 kumpf 1.88 load config properties from the file
|
769 mike 1.2 */
770 void ConfigManager::_loadConfigProperties()
771 {
|
772 kumpf 1.59 PEGASUS_ASSERT(useConfigFiles);
773
|
774 mike 1.2 //
775 // load all the properties from the current and planned
776 // config files in to tables.
777 //
778 _configFileHandler->loadAllConfigProperties();
779
|
780 kumpf 1.49 Array<CIMName> propertyNames;
781 Array<String> propertyValues;
782
783 _configFileHandler->getAllCurrentProperties(propertyNames, propertyValues);
784
785 Uint32 size = propertyNames.size();
786
|
787 mike 1.2 //
788 // initialize all the property owners with the values
789 // from the config files.
790 //
|
791 kumpf 1.49 for (Uint32 i = 0; i < size; i++)
|
792 mike 1.2 {
|
793 kumpf 1.49 //
794 // initialize the current value of the property owner
795 // with the value from the config file handler
796 //
797 try
|
798 mike 1.2 {
|
799 kumpf 1.13 //
|
800 kumpf 1.49 // get property owner object from the config table.
|
801 kumpf 1.13 //
|
802 kumpf 1.49 ConfigPropertyOwner* propertyOwner;
803
804 String propertyName = propertyNames[i].getString();
805
806 if (_propertyTable->ownerTable.lookup(
807 propertyName, propertyOwner))
|
808 mike 1.2 {
|
809 kumpf 1.49 if (propertyOwner->isValid(
810 propertyName, propertyValues[i]))
811 {
812 propertyOwner->initCurrentValue(
813 propertyName, propertyValues[i]);
|
814 mike 1.2
|
815 kumpf 1.49 propertyOwner->initPlannedValue(
816 propertyName, propertyValues[i]);
817 }
818 else
|
819 mike 1.2 {
|
820 kumpf 1.49 throw InvalidPropertyValue(propertyName, propertyValues[i]);
|
821 mike 1.2 }
822 }
|
823 kumpf 1.49 else
|
824 mike 1.2 {
|
825 kumpf 1.88 // if the property is a fixed property then just log that
826 // this property is not supported and continue. In all other
827 // cases terminate the cimserver
|
828 thilo.boehm 1.87 if (_propertyTable->fixedValueTable.contains(propertyName))
829 {
|
830 kumpf 1.88 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
831 Logger::WARNING,
|
832 kumpf 1.100 MessageLoaderParms(
833 "Config.ConfigManager.NOTSUPPORTED_CONFIG_PROPERTY",
834 "Configuration property $0 is not supported. "
835 "Setting ignored.",
836 propertyName));
|
837 kumpf 1.88 }
838 else
|
839 thilo.boehm 1.87 {
|
840 kumpf 1.88 throw UnrecognizedConfigProperty(propertyName);
|
841 thilo.boehm 1.87 }
|
842 mike 1.2 }
|
843 kumpf 1.49 }
|
844 kumpf 1.88 catch (UnrecognizedConfigProperty& ucp)
|
845 kumpf 1.49 {
|
846 kumpf 1.108 PEG_TRACE_CSTRING(TRC_CONFIG, Tracer::LEVEL1,
|
847 thilo.boehm 1.101 (const char*)ucp.getMessage().getCString());
|
848 kumpf 1.49 throw;
849 }
|
850 kumpf 1.88 catch (InvalidPropertyValue& ipv)
|
851 kumpf 1.49 {
|
852 kumpf 1.108 PEG_TRACE_CSTRING(TRC_CONFIG, Tracer::LEVEL1,
|
853 thilo.boehm 1.101 (const char*)ipv.getMessage().getCString());
|
854 kumpf 1.49 throw;
|
855 mike 1.2 }
856 }
857 }
858
859
|
860 chip 1.68 /**
|
861 kumpf 1.88 Initialize config property with the value specified in the command line.
|
862 mike 1.2 */
863 Boolean ConfigManager::_initPropertyWithCommandLineOption(
|
864 chip 1.68 const String& option)
|
865 mike 1.2 {
|
866 kumpf 1.59 Uint32 pos = option.find('=');
|
867 thilo.boehm 1.109
|
868 mike 1.2 if (pos == PEG_NOT_FOUND)
869 {
870 //
871 // The property value was not specified
872 //
|
873 chip 1.68 throw UnrecognizedConfigProperty(option);
|
874 mike 1.2 }
875
876 //
877 // Get the property name and value
878 //
|
879 kumpf 1.59 String propertyName = option.subString(0, pos);
|
880 kumpf 1.88 String propertyValue = option.subString(pos + 1);
|
881 mike 1.2
|
882 kumpf 1.59 return initCurrentValue(propertyName, propertyValue);
|
883 mike 1.2 }
884
|
885 chip 1.68 /**
|
886 kumpf 1.88 Initialize config property owners and add them to the property owner table
|
887 mike 1.2 */
|
888 kumpf 1.10 void ConfigManager::_initPropertyTable()
|
889 mike 1.2 {
890 //
|
891 kumpf 1.10 // add config property and its fixed value to fixed value table
892 //
893 for (Uint32 i = 0; i < NUM_FIXED_PROPERTIES; i++)
894 {
|
895 kumpf 1.14 _propertyTable->fixedValueTable.insert(_fixedValues[i].propertyName,
896 _fixedValues[i].fixedValue);
|
897 kumpf 1.10 }
898
899 //
900 // add config property and its owner object to owners table (but only if
901 // the property is not also listed in the fixed value table.
|
902 mike 1.2 //
903 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
904 {
|
905 w.otsuka 1.80 const char* fixedValue = 0;
|
906 mike 1.2
|
907 kumpf 1.31 _properties[i].propertyOwner->initialize();
908
|
909 kumpf 1.10 if (!_propertyTable->fixedValueTable.lookup(
|
910 kumpf 1.14 _properties[i].propertyName, fixedValue))
|
911 kumpf 1.10 {
|
912 kumpf 1.14 _propertyTable->ownerTable.insert(_properties[i].propertyName,
913 _properties[i].propertyOwner);
|
914 kumpf 1.31 }
915 else
916 {
917 //
918 // Set the value for the fixed properties
919 //
920 _properties[i].propertyOwner->initCurrentValue(
921 _properties[i].propertyName, fixedValue);
|
922 kumpf 1.10 }
|
923 mike 1.2 }
924 }
925
|
926 marek 1.118 Boolean ConfigManager::_fixedValueCheck(const String& name,String & value) const
|
927 marek 1.117 {
928 //
929 // Check for a property with a fixed value
930 //
931 const char* fixedValue = 0;
932
933 _propertyTable->fixedValueTable.lookup(name, fixedValue);
934
935 // no fixed property 'name' in FixedPropertyTable, bail out
936 if (0 == fixedValue)
937 {
|
938 marek 1.118 return false;
|
939 marek 1.117 }
|
940 karl 1.119
|
941 marek 1.117 // if the fixed value is set to blank, need to replace the value with
942 // the system-supplied host name
943 if (String::equalNoCase(name, "fullyQualifiedHostName"))
944 {
945 if (0 == strlen(fixedValue))
946 {
|
947 marek 1.118 value.assign(System::getFullyQualifiedHostName());
|
948 marek 1.117 }
949 else
950 {
|
951 marek 1.118 value.assign(fixedValue);
952 System::setFullyQualifiedHostName(value);
|
953 marek 1.117 }
|
954 marek 1.118 // returning here already to avoid the following and in this case
955 // unnecessary string compare and assign
956 return true;
|
957 marek 1.117 }
958 if (String::equalNoCase(name, "hostname"))
959 {
960 if (0 == strlen(fixedValue))
961 {
|
962 marek 1.118 value.assign(System::getHostName());
|
963 marek 1.117 }
964 else
965 {
|
966 marek 1.118 value.assign(fixedValue);
967 System::setHostName(value);
|
968 marek 1.117 }
|
969 marek 1.118 // returning here already to avoid the following and in this case
970 // unnecessary assign
971 return true;
|
972 marek 1.117 }
|
973 marek 1.118 value.assign(fixedValue);
974 return true;
|
975 marek 1.117 }
976
|
977 kumpf 1.6 /**
|
978 kumpf 1.88 Get Pegasus Home
|
979 kumpf 1.6 */
980 String ConfigManager::getPegasusHome()
981 {
982 return _pegasusHome;
983 }
984
985 /**
|
986 kumpf 1.88 Set Pegasus Home variable
|
987 kumpf 1.6 */
|
988 aruran.ms 1.74 void ConfigManager::setPegasusHome(const String& home)
|
989 kumpf 1.6 {
|
990 kumpf 1.88 if (home != String::EMPTY)
|
991 kumpf 1.6 {
|
992 kumpf 1.88 _pegasusHome = home;
|
993 kumpf 1.6 }
994 }
995
996 /**
|
997 kumpf 1.88 Get the homed path for a given property.
|
998 kumpf 1.6 */
999 String ConfigManager::getHomedPath(const String& value)
1000 {
|
1001 kumpf 1.90 String homedPath;
|
1002 kumpf 1.88
|
1003 lawrence.luo 1.124 if (value.size() != 0 )
|
1004 kumpf 1.88 {
1005 if (System::is_absolute_path((const char *)value.getCString()))
1006 {
1007 return value;
1008 }
|
1009 chip 1.68
|
1010 kumpf 1.88 //
1011 // Get the pegasusHome and prepend it
1012 //
1013
1014 String temp = value;
1015 Uint32 pos = 0;
1016 Uint32 token = 0;
1017 do
1018 {
1019 if ((pos = temp.find(FileSystem::getPathDelimiter())) ==
1020 PEG_NOT_FOUND)
1021 {
1022 pos = temp.size();
1023 token = 0;
1024 }
1025 else
1026 {
1027 token = 1;
1028 }
1029
1030 if (System::is_absolute_path(
1031 kumpf 1.88 (const char *)temp.subString(0, pos).getCString()))
1032 {
1033 homedPath.append(temp.subString(0,pos));
1034 }
1035 else
1036 {
1037 homedPath.append(_pegasusHome + "/" + temp.subString(0, pos));
1038 }
1039
1040 if (token == 1)
|
1041 lawrence.luo 1.124 {
|
1042 kumpf 1.88 homedPath.append(FileSystem::getPathDelimiter());
|
1043 lawrence.luo 1.124 }
|
1044 kumpf 1.88 temp.remove(0, pos + token);
1045 } while (temp.size() > 0);
|
1046 konrad.r 1.50 }
|
1047 kumpf 1.88 return homedPath;
|
1048 kumpf 1.6 }
|
1049 chip 1.68
|
1050 kumpf 1.83 Boolean ConfigManager::parseBooleanValue(const String& propertyValue)
1051 {
1052 return String::equalNoCase(propertyValue, "true");
1053 }
1054
|
1055 kavita.gupta 1.110 Boolean ConfigManager::isValidBooleanValue(const String& value)
1056 {
1057 if ((String::equalNoCase(value, STRING_TRUE)) ||
1058 (String::equalNoCase(value, STRING_FALSE)))
1059 {
1060 return true;
1061 }
1062 return false;
1063 }
|
1064 karl 1.128
1065 Uint32 ConfigManager::parseUint32Value(const String& propertyValue)
1066 {
1067 Uint64 v;
1068 StringConversion::decimalStringToUint64(
1069 (const char*)propertyValue.getCString(), v);
1070 return (Uint32) v;
1071 }
1072
1073 Boolean ConfigManager::isValidUint32Value(const String& strValue,
1074 Uint32 min,
1075 Uint32 max)
1076 {
|
1077 karl 1.130 Uint32 v;
1078 Boolean rtn = StringConversion::decimalStringToUint32(strValue, v);
|
1079 karl 1.128 if (rtn && ( (v >= min) && (v <= max)) )
1080 {
1081 return true;
1082 }
1083 return false;
1084 }
|
1085 karl 1.130
|
1086 dev.meetei 1.116 Array<HostAddress> ConfigManager::getListenAddress(const String &propertyValue)
1087 {
1088 Array<String> interfaces = DefaultPropertyOwner::parseAndGetListenAddress (
1089 propertyValue);
1090
1091 HostAddress theAddress;
1092 Array<HostAddress> listenAddrs;
1093 for(Uint32 i = 0, n = interfaces.size(); i < n; i++)
1094 {
1095 theAddress.setHostAddress(interfaces[i]);
1096 listenAddrs.append(theAddress);
1097 }
1098 return listenAddrs;
1099 }
|
1100 kavita.gupta 1.110
|
1101 karl 1.119 String ConfigManager::getDynamicAttributeStatus(const String& name)
1102 {
1103 //
1104 // get property owner object from config table
1105 //
1106 ConfigPropertyOwner* propertyOwner;
1107 if ( !_propertyTable->ownerTable.lookup(name, propertyOwner))
1108 {
1109 throw UnrecognizedConfigProperty(name);
1110 }
1111
1112 Boolean _isDynamic = propertyOwner->isDynamic(name);
1113
1114 MessageLoaderParms parms(
1115 (_isDynamic? "Config.ConfigManager.DYNAMIC":
1116 "Config.ConfigManager.STATIC"),
1117 (_isDynamic? "Dynamic" : "Static"));
1118
1119 parms.msg_src_path = "pegasus/pegasusServer";
1120 return MessageLoader::getMessage(parms);
1121 }
1122 karl 1.119
|
1123 mike 1.2 PEGASUS_NAMESPACE_END
|