1 karl 1.78 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.2 //
|
3 karl 1.65 // 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.44 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.65 // 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.69 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.78 // 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 kumpf 1.21 // 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 mike 1.2 // 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.78 //
|
21 kumpf 1.21 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
22 mike 1.2 // 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 kumpf 1.21 // 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 mike 1.2 // 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.21 //==============================================================================
|
31 mike 1.2 //
32 // Author: Nag Boranna (nagaraja_boranna@hp.com)
33 //
|
34 chip 1.68 // Modified By:
35 // Sushma Fernandes, Hewlett-Packard Company (sushma_fernandes@hp.com)
36 // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
37 // Bapu Patil, Hewlett-Packard Company (bapu_patil@hp.com)
38 // Jenny Yu, Hewlett-Packard Company (jenny_yu@hp.com)
39 // Carol Ann Krug Graves, Hewlett-Packard Company (carolann_graves@hp.com)
40 // Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
41 // Heather Sterling, IBM (hsterl@us.ibm.com)
42 // Dave Sudlik, IBM (dsudlik@us.ibm.com)
43 // Dave Rosckes (rosckes@us.ibm.com)
44 // Chip Vincent (cvincent@us.ibm.com)
|
45 david.dillard 1.70 // David Dillard, VERITAS Software Corp.
46 // (david.dillard@veritas.com)
|
47 aruran.ms 1.74 // Aruran, IBM (ashanmug@in.ibm.com) for Bug# 3612
|
48 aruran.ms 1.77 // Aruran, IBM (ashanmug@in.ibm.com) for Bug# 3610
|
49 david 1.35 //
|
50 mike 1.2 //%////////////////////////////////////////////////////////////////////////////
51
52
53 /////////////////////////////////////////////////////////////////////////////
|
54 chip 1.68 // ConfigManager
|
55 mike 1.2 /////////////////////////////////////////////////////////////////////////////
56
|
57 kumpf 1.20 #include <Pegasus/Common/Tracer.h>
|
58 kumpf 1.12 #include <Pegasus/Common/PegasusVersion.h>
|
59 tony 1.32 #include <Pegasus/Common/FileSystem.h>
|
60 kumpf 1.12
|
61 mike 1.2 #include "ConfigExceptions.h"
62 #include "ConfigManager.h"
63
64 PEGASUS_NAMESPACE_BEGIN
65
66 /////////////////////////////////////////////////////////////////////////////
67 //
68 // When a new property owner is created be sure to create a static
69 // object of the new property owner.
70 //
71 /////////////////////////////////////////////////////////////////////////////
72
73 TracePropertyOwner* ConfigManager::traceOwner = new TracePropertyOwner;
74 LogPropertyOwner* ConfigManager::logOwner = new LogPropertyOwner;
75 DefaultPropertyOwner* ConfigManager::defaultOwner = new DefaultPropertyOwner;
76 SecurityPropertyOwner* ConfigManager::securityOwner= new SecurityPropertyOwner;
77 RepositoryPropertyOwner* ConfigManager::repositoryOwner= new RepositoryPropertyOwner;
78 ShutdownPropertyOwner* ConfigManager::shutdownOwner= new ShutdownPropertyOwner;
|
79 kumpf 1.10 FileSystemPropertyOwner* ConfigManager::fileSystemOwner= new FileSystemPropertyOwner;
|
80 konrad.r 1.50 ProviderDirPropertyOwner* ConfigManager::providerDirOwner= new ProviderDirPropertyOwner;
|
81 chip 1.68 NormalizationPropertyOwner* ConfigManager::normalizationOwner = new NormalizationPropertyOwner;
|
82 mike 1.2
83 /////////////////////////////////////////////////////////////////////////////
84 //
|
85 chip 1.68 // When a new property is created be sure to add the new property name
|
86 kumpf 1.10 // and the owner object to the OwnerEntry table below.
|
87 mike 1.2 //
88 /////////////////////////////////////////////////////////////////////////////
89
|
90 kumpf 1.10 struct OwnerEntry
91 {
92 const char* propertyName;
93 ConfigPropertyOwner* propertyOwner;
94 };
95
|
96 kumpf 1.14 static struct OwnerEntry _properties[] =
|
97 mike 1.2 {
98 {"traceLevel", (ConfigPropertyOwner* )ConfigManager::traceOwner},
|
99 kumpf 1.6 {"traceComponents", (ConfigPropertyOwner* )ConfigManager::traceOwner},
|
100 mike 1.2 {"traceFilePath", (ConfigPropertyOwner* )ConfigManager::traceOwner},
|
101 konrad.r 1.71 #if !defined(PEGASUS_USE_SYSLOGS)
|
102 kumpf 1.6 {"logdir", (ConfigPropertyOwner* )ConfigManager::logOwner},
|
103 konrad.r 1.71 #endif
|
104 david 1.35 {"logLevel", (ConfigPropertyOwner* )ConfigManager::logOwner},
|
105 kumpf 1.30 {"enableHttpConnection", (ConfigPropertyOwner* )ConfigManager::defaultOwner},
106 {"enableHttpsConnection",(ConfigPropertyOwner* )ConfigManager::defaultOwner},
|
107 kumpf 1.16 {"httpPort", (ConfigPropertyOwner* )ConfigManager::defaultOwner},
108 {"httpsPort", (ConfigPropertyOwner* )ConfigManager::defaultOwner},
|
109 mike 1.2 {"home", (ConfigPropertyOwner* )ConfigManager::defaultOwner},
110 {"daemon", (ConfigPropertyOwner* )ConfigManager::defaultOwner},
111 {"slp", (ConfigPropertyOwner* )ConfigManager::defaultOwner},
|
112 kumpf 1.19 {"enableAssociationTraversal", (ConfigPropertyOwner* )ConfigManager::defaultOwner},
113 {"enableIndicationService", (ConfigPropertyOwner* )ConfigManager::defaultOwner},
|
114 karl 1.38 // Removed because unresolved PEP 66 KS{"maximumEnumerationBreadth", (ConfigPropertyOwner* )ConfigManager::defaultOwner},
|
115 kumpf 1.17 {"enableAuthentication", (ConfigPropertyOwner* )ConfigManager::securityOwner},
116 {"enableNamespaceAuthorization", (ConfigPropertyOwner* )ConfigManager::securityOwner},
|
117 mike 1.2 {"httpAuthType", (ConfigPropertyOwner* )ConfigManager::securityOwner},
|
118 kumpf 1.6 {"passwordFilePath", (ConfigPropertyOwner* )ConfigManager::securityOwner},
|
119 kumpf 1.18 {"sslCertificateFilePath", (ConfigPropertyOwner* )ConfigManager::securityOwner},
|
120 kumpf 1.39 {"sslKeyFilePath", (ConfigPropertyOwner* )ConfigManager::securityOwner},
|
121 h.sterling 1.55 {"sslTrustStore", (ConfigPropertyOwner* )ConfigManager::securityOwner},
|
122 kumpf 1.56 {"exportSSLTrustStore", (ConfigPropertyOwner* )ConfigManager::securityOwner},
|
123 sushma.fernandes 1.79 #ifdef PEGASUS_ENABLE_SSL_CRL_VERIFICATION
|
124 h.sterling 1.66 {"crlStore", (ConfigPropertyOwner* )ConfigManager::securityOwner},
|
125 sushma.fernandes 1.79 #endif
|
126 h.sterling 1.55 {"sslClientVerificationMode", (ConfigPropertyOwner* )ConfigManager::securityOwner},
|
127 h.sterling 1.61 {"sslTrustStoreUserName", (ConfigPropertyOwner* )ConfigManager::securityOwner},
|
128 gerarda 1.42 #ifdef PEGASUS_KERBEROS_AUTHENTICATION
129 {"kerberosServiceName", (ConfigPropertyOwner* )ConfigManager::securityOwner},
130 #endif
|
131 mike 1.2 {"repositoryIsDefaultInstanceProvider", (ConfigPropertyOwner* )ConfigManager::repositoryOwner},
|
132 dave.sudlik 1.62 {"enableBinaryRepository", (ConfigPropertyOwner* )ConfigManager::repositoryOwner}, // PEP 164
|
133 kumpf 1.5 {"shutdownTimeout", (ConfigPropertyOwner* )ConfigManager::shutdownOwner},
|
134 kumpf 1.17 {"repositoryDir", (ConfigPropertyOwner* )ConfigManager::fileSystemOwner},
|
135 konrad.r 1.50 {"providerDir", (ConfigPropertyOwner* )ConfigManager::providerDirOwner},
|
136 kumpf 1.7 {"enableRemotePrivilegedUserAccess", (ConfigPropertyOwner* )ConfigManager::securityOwner},
|
137 kumpf 1.43 {"enableSubscriptionsForNonprivilegedUsers", (ConfigPropertyOwner* )ConfigManager::securityOwner},
|
138 kumpf 1.56 {"enableSSLExportClientVerification", (ConfigPropertyOwner* )ConfigManager::securityOwner},
|
139 kumpf 1.57 #ifdef PEGASUS_ENABLE_USERGROUP_AUTHORIZATION
140 {"authorizedUserGroups", (ConfigPropertyOwner* )ConfigManager::securityOwner},
141 #endif
|
142 david 1.52 {"messageDir", (ConfigPropertyOwner* )ConfigManager::fileSystemOwner},
|
143 chip 1.68 #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
144 { "enableNormalization", (ConfigPropertyOwner *)ConfigManager::normalizationOwner },
145 { "excludeModulesFromNormalization", (ConfigPropertyOwner *)ConfigManager::normalizationOwner },
146 #endif
|
147 kumpf 1.67 {"forceProviderProcesses", (ConfigPropertyOwner* )ConfigManager::defaultOwner},
148 {"maxProviderProcesses", (ConfigPropertyOwner* )ConfigManager::defaultOwner}
|
149 mike 1.2 };
150
|
151 kumpf 1.14 const Uint32 NUM_PROPERTIES = sizeof(_properties) / sizeof(struct OwnerEntry);
|
152 kumpf 1.10
153
154 /////////////////////////////////////////////////////////////////////////////
155 //
156 // To use a fixed value for a property rather than delegating to a property
157 // owner, add the property to the FixedValueEntry table below. An entry in
158 // the OwnerEntry table above for this same property will be initialized
159 // and given the (fixed) initial current value, but will thereafter be
160 // ignored.
161 //
162 // Fixed values are only returned by getDefaultValue(), getCurrentValue(),
163 // and getPlannedValue(). All other methods will treat fixed properties as
164 // unrecognized properties.
165 //
166 /////////////////////////////////////////////////////////////////////////////
167
168 struct FixedValueEntry
169 {
170 const char* propertyName;
171 const char* fixedValue;
172 };
173 kumpf 1.10
|
174 kumpf 1.14 static struct FixedValueEntry _fixedValues[] =
|
175 kumpf 1.10 {
|
176 kumpf 1.28 #include "FixedPropertyTable.h"
|
177 kumpf 1.10 };
178
|
179 chip 1.68 const Uint32 NUM_FIXED_PROPERTIES =
|
180 kumpf 1.14 sizeof(_fixedValues) / sizeof(struct FixedValueEntry);
|
181 kumpf 1.10
|
182 mike 1.2
|
183 kumpf 1.6 /**
184 Initialize the default PEGASUS_HOME location, the default is set to the current directory.
185 */
186 const String ConfigManager::PEGASUS_HOME_DEFAULT = ".";
|
187 mike 1.2
|
188 kumpf 1.6 String ConfigManager::_pegasusHome = PEGASUS_HOME_DEFAULT;
|
189 mike 1.2
|
190 kumpf 1.59 //
|
191 chip 1.68 // Initialize ConfigManager instance
|
192 kumpf 1.59 //
|
193 mike 1.2 ConfigManager* ConfigManager::_instance = 0;
194
195
196 /** Constructor. */
|
197 kumpf 1.59 ConfigManager::ConfigManager()
198 : useConfigFiles(false)
|
199 mike 1.2 {
200 //
201 // Initialize the instance variables
202 //
|
203 a.arora 1.58 _propertyTable.reset(new PropertyTable);
|
204 mike 1.2
205 //
206 // Initialize the property owners
207 //
|
208 kumpf 1.10 _initPropertyTable();
|
209 mike 1.2 }
210
|
211 konrad.r 1.75 /**
212 Terminate the ConfigManager
213 */
214 void
|
215 konrad.r 1.76 ConfigManager::destroy( void )
|
216 konrad.r 1.75 {
217 if (_instance)
218 {
219 delete _instance->traceOwner;
220 delete _instance->logOwner;
221 delete _instance->defaultOwner;
222 delete _instance->securityOwner;
223 delete _instance->repositoryOwner;
224 delete _instance->shutdownOwner;
225 delete _instance->fileSystemOwner;
226 delete _instance->providerDirOwner;
227 delete _instance->normalizationOwner;
228 delete _instance;
229 _instance = 0;
230 }
231 }
|
232 chip 1.68 /**
|
233 kumpf 1.59 Get a reference to the singleton ConfigManager instance. If no
234 ConfigManager instance exists, construct one.
|
235 mike 1.2 */
|
236 chip 1.68 ConfigManager* ConfigManager::getInstance()
|
237 mike 1.2 {
|
238 chip 1.68 if (!_instance)
|
239 mike 1.2 {
240 _instance = new ConfigManager();
241 }
242 return _instance;
243 }
244
245
|
246 chip 1.68 /**
|
247 kumpf 1.59 Initialize the current value of a config property
248 */
249 Boolean ConfigManager::initCurrentValue(
250 const String& propertyName,
251 const String& propertyValue)
252 {
253 ConfigPropertyOwner* propertyOwner = 0;
254
255 //
256 // get property owner object from the config table.
257 //
258 if (!_propertyTable->ownerTable.lookup(propertyName, propertyOwner))
259 {
|
260 chip 1.68 throw UnrecognizedConfigProperty(propertyName);
|
261 kumpf 1.59 }
262
|
263 kumpf 1.73 if (useConfigFiles && !propertyOwner->isValid(propertyName, propertyValue))
264 {
265 throw InvalidPropertyValue(propertyName, propertyValue);
266 }
267
268 //
269 // update the value with the property owner
270 //
271 propertyOwner->initCurrentValue(propertyName, propertyValue);
272
273 if (useConfigFiles)
|
274 kumpf 1.59 {
275 //
|
276 kumpf 1.73 // update the value in the current config file
|
277 kumpf 1.59 //
|
278 kumpf 1.73 return (_configFileHandler->updateCurrentValue(
279 propertyName, propertyValue, false));
|
280 kumpf 1.59 }
281
282 return true;
283 }
284
|
285 chip 1.68 /**
|
286 mike 1.2 Update current value of a property.
287 */
288 Boolean ConfigManager::updateCurrentValue(
|
289 chip 1.68 const String& name,
|
290 kumpf 1.13 const String& value,
291 Boolean unset)
|
292 mike 1.2 {
293 String prevValue = String::EMPTY;
294
295 //
296 // get property owner object from the config table.
297 //
298 ConfigPropertyOwner* propertyOwner;
299
|
300 kumpf 1.10 if (!_propertyTable->ownerTable.lookup(name, propertyOwner))
|
301 mike 1.2 {
|
302 chip 1.68 throw UnrecognizedConfigProperty(name);
|
303 mike 1.2 }
304
|
305 kumpf 1.73 //
306 // keep a copy of the existing config value
307 //
308 prevValue = propertyOwner->getCurrentValue(name);
309
310 //
311 // ask owner to update the current value
312 //
313 if (unset)
|
314 mike 1.2 {
|
315 kumpf 1.73 propertyOwner->updateCurrentValue(name,
316 propertyOwner->getDefaultValue(name));
317 }
318 else
319 {
320 if (useConfigFiles && !propertyOwner->isValid(name, value))
321 {
322 throw InvalidPropertyValue(name, value);
323 }
324
325 propertyOwner->updateCurrentValue(name, value);
326 }
|
327 mike 1.2
|
328 kumpf 1.73 if (useConfigFiles)
329 {
|
330 mike 1.2 //
|
331 kumpf 1.73 // update the new value in the current config file
|
332 mike 1.2 //
|
333 kumpf 1.73 if (!_configFileHandler->updateCurrentValue(name, value, unset))
|
334 mike 1.2 {
|
335 kumpf 1.73 // Failed to update the current value, so roll back.
336 propertyOwner->updateCurrentValue(name, prevValue);
337 return false;
|
338 mike 1.2 }
339 }
|
340 kumpf 1.29
|
341 kumpf 1.59 return true;
|
342 mike 1.2 }
343
344
|
345 chip 1.68 /**
|
346 mike 1.2 Update planned value of a property.
347 */
348 Boolean ConfigManager::updatePlannedValue(
|
349 chip 1.68 const String& name,
|
350 kumpf 1.13 const String& value,
351 Boolean unset)
|
352 mike 1.2 {
353 String prevValue = String::EMPTY;
354
355 //
356 // get property owner object from the config table.
357 //
358 ConfigPropertyOwner* propertyOwner;
359
|
360 kumpf 1.10 if (!_propertyTable->ownerTable.lookup(name, propertyOwner))
|
361 mike 1.2 {
|
362 chip 1.68 throw UnrecognizedConfigProperty(name);
|
363 mike 1.2 }
364
|
365 kumpf 1.73 //
366 // keep a copy of the existing config value
367 //
368 prevValue = propertyOwner->getPlannedValue(name);
369
370 //
371 // ask owner to update the planned value to new value
372 //
373 if (unset)
374 {
375 propertyOwner->updatePlannedValue(name,
376 propertyOwner->getDefaultValue(name));
377 }
378 else
|
379 mike 1.2 {
|
380 kumpf 1.73 if (useConfigFiles && !propertyOwner->isValid(name, value))
381 {
382 throw InvalidPropertyValue(name, value);
383 }
384
385 propertyOwner->updatePlannedValue(name, value);
386 }
|
387 mike 1.2
|
388 kumpf 1.73 if (useConfigFiles)
389 {
|
390 mike 1.2 //
|
391 kumpf 1.73 // update the new value in the planned config file
|
392 mike 1.2 //
|
393 kumpf 1.73 if (!_configFileHandler->updatePlannedValue(name, value, unset))
|
394 kumpf 1.13 {
|
395 kumpf 1.73 // Failed to update the planned value, so roll back.
396 propertyOwner->updatePlannedValue(name, prevValue);
397 return false;
|
398 mike 1.2 }
399 }
|
400 kumpf 1.29
|
401 kumpf 1.59 return true;
|
402 mike 1.2 }
403
404
|
405 chip 1.68 /**
|
406 mike 1.2 Validate the value of a specified property.
407 */
408 Boolean ConfigManager::validatePropertyValue(
|
409 chip 1.68 const String& name,
|
410 mike 1.2 const String& value)
411 {
412 //
413 // get property owner object from config table
414 //
415 ConfigPropertyOwner* propertyOwner;
416
|
417 kumpf 1.10 if (!_propertyTable->ownerTable.lookup(name, propertyOwner))
|
418 mike 1.2 {
|
419 chip 1.68 throw UnrecognizedConfigProperty(name);
|
420 mike 1.2 }
421
422 return (propertyOwner->isValid(name, value));
423 }
424
425 /**
426 Get default value of the specified property.
427 */
|
428 aruran.ms 1.77 String ConfigManager::getDefaultValue(const String& name) const
|
429 mike 1.2 {
430 //
|
431 kumpf 1.10 // Check for a property with a fixed value
432 //
433 const char* fixedValue;
434
435 if (_propertyTable->fixedValueTable.lookup(name, fixedValue))
436 {
437 return fixedValue;
438 }
439
440 //
|
441 mike 1.2 // get property owner object from config table
442 //
443 ConfigPropertyOwner* propertyOwner;
444
|
445 kumpf 1.10 if (!_propertyTable->ownerTable.lookup(name, propertyOwner))
|
446 mike 1.2 {
447 throw UnrecognizedConfigProperty(name);
448 }
449
450 return (propertyOwner->getDefaultValue(name));
451 }
452
|
453 chip 1.68 /**
|
454 mike 1.2 Get current value of the specified property.
455 */
|
456 aruran.ms 1.77 String ConfigManager::getCurrentValue(const String& name) const
|
457 mike 1.2 {
458 //
|
459 kumpf 1.10 // Check for a property with a fixed value
460 //
461 const char* fixedValue;
462
463 if (_propertyTable->fixedValueTable.lookup(name, fixedValue))
464 {
465 return fixedValue;
466 }
467
468 //
|
469 mike 1.2 // get property owner object from config table
470 //
471 ConfigPropertyOwner* propertyOwner;
472
|
473 kumpf 1.10 if (!_propertyTable->ownerTable.lookup(name, propertyOwner))
|
474 mike 1.2 {
|
475 chip 1.68 throw UnrecognizedConfigProperty(name);
|
476 mike 1.2 }
477
478 return (propertyOwner->getCurrentValue(name));
479 }
480
481
|
482 chip 1.68 /**
|
483 mike 1.2 Get planned value of the specified property.
484 */
|
485 aruran.ms 1.77 String ConfigManager::getPlannedValue(const String& name) const
|
486 mike 1.2 {
487 //
|
488 kumpf 1.10 // Check for a property with a fixed value
489 //
490 const char* fixedValue;
491
492 if (_propertyTable->fixedValueTable.lookup(name, fixedValue))
493 {
494 return fixedValue;
495 }
496
497 //
|
498 mike 1.2 // get property owner object from config table
499 //
500 ConfigPropertyOwner* propertyOwner;
501
|
502 kumpf 1.10 if (!_propertyTable->ownerTable.lookup(name, propertyOwner))
|
503 mike 1.2 {
|
504 chip 1.68 throw UnrecognizedConfigProperty(name);
|
505 mike 1.2 }
506
507 return (propertyOwner->getPlannedValue(name));
508 }
509
510
|
511 chip 1.68 /**
|
512 mike 1.2 Get all the attributes of the specified property.
513 */
514 void ConfigManager::getPropertyInfo(
|
515 chip 1.68 const String& name,
|
516 aruran.ms 1.77 Array<String>& propertyInfo) const
|
517 mike 1.2 {
518 //
519 // get property owner object from config table
520 //
521 ConfigPropertyOwner* propertyOwner;
522
|
523 kumpf 1.10 if (!_propertyTable->ownerTable.lookup(name, propertyOwner))
|
524 mike 1.2 {
|
525 chip 1.68 throw UnrecognizedConfigProperty(name);
|
526 mike 1.2 }
527
528 propertyOwner->getPropertyInfo(name, propertyInfo);
529 }
530
531
|
532 chip 1.68 /**
|
533 mike 1.2 Get a list of all property names.
534 */
|
535 kumpf 1.59 void ConfigManager::getAllPropertyNames(
536 Array<String>& propertyNames,
|
537 aruran.ms 1.77 Boolean includeHiddenProperties) const
|
538 mike 1.2 {
|
539 kumpf 1.41 Array<String> propertyInfo;
|
540 mike 1.2 propertyNames.clear();
541
|
542 kumpf 1.10 for (OwnerTable::Iterator i = _propertyTable->ownerTable.start(); i; i++)
|
543 mike 1.2 {
|
544 kumpf 1.59 if (includeHiddenProperties)
|
545 kumpf 1.41 {
546 propertyNames.append(i.key());
547 }
|
548 kumpf 1.59 else
549 {
550 //
551 // Check if property is to be externally visible or not.
552 // If the property should not be externally visible do not list the
553 // property information.
554 //
555 propertyInfo.clear();
556 getPropertyInfo(i.key(), propertyInfo);
557
558 if (propertyInfo[5] == STRING_TRUE)
559 {
560 propertyNames.append(i.key());
561 }
562 }
|
563 mike 1.2 }
564 }
565
566
|
567 chip 1.68 /**
|
568 mike 1.2 Merge the config properties from the specified planned config file
569 with the properties in the specified current config file.
570 */
571 void ConfigManager::mergeConfigFiles(
|
572 chip 1.68 const String& currentFile,
|
573 mike 1.2 const String& plannedFile)
574 {
|
575 kumpf 1.59 PEGASUS_ASSERT(useConfigFiles);
576
|
577 kumpf 1.73 _configFileHandler.reset(new ConfigFileHandler(currentFile, plannedFile));
|
578 mike 1.2
|
579 kumpf 1.73 _loadConfigProperties();
|
580 mike 1.2 }
581
582
|
583 chip 1.68 /**
|
584 mike 1.2 Merge the config properties from the default planned config file
585 with the properties in the default current config file.
586 */
587 void ConfigManager::mergeConfigFiles()
588 {
|
589 kumpf 1.59 PEGASUS_ASSERT(useConfigFiles);
590
|
591 kumpf 1.73 _configFileHandler.reset(new ConfigFileHandler());
|
592 mike 1.2
|
593 kumpf 1.73 _loadConfigProperties();
|
594 mike 1.2 }
595
596
|
597 chip 1.68 /**
598 Merge config properties specified on the command line
|
599 mike 1.2 */
600 void ConfigManager::mergeCommandLine(int& argc, char**& argv)
601 {
602 // Remove the command name from the command line
|
603 kumpf 1.3 if (argc > 0)
604 {
605 memmove(&argv[0], &argv[1], (argc) * sizeof(char*));
606 argc--;
607 }
|
608 mike 1.2
609 //
610 // Merge properties from the command line
611 //
|
612 kumpf 1.9 for (Sint32 i = 0; i < argc; )
|
613 mike 1.2 {
614 const char* arg = argv[i];
615
|
616 kumpf 1.34 if (*arg == '-')
617 {
618 throw UnrecognizedCommandLineOption();
619 }
620
|
621 tony 1.33 // Get the config option
622 //const char* configOption = argv[i];
623 if (!_initPropertyWithCommandLineOption(arg))
|
624 mike 1.2 {
|
625 chip 1.68 throw UnrecognizedConfigProperty(arg);
|
626 mike 1.2 }
627
628 // Remove the option from the command line
629 memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
630 argc--;
631 }
632 }
633
634
|
635 chip 1.68 /**
636 load config properties from the file
|
637 mike 1.2 */
638 void ConfigManager::_loadConfigProperties()
639 {
|
640 kumpf 1.59 PEGASUS_ASSERT(useConfigFiles);
641
|
642 mike 1.2 //
643 // copy the contents of planned config file over
644 // the current config file
645 //
646 _configFileHandler->copyPlannedFileOverCurrentFile();
647
648 //
649 // load all the properties from the current and planned
650 // config files in to tables.
651 //
652 _configFileHandler->loadAllConfigProperties();
653
|
654 kumpf 1.49 Array<CIMName> propertyNames;
655 Array<String> propertyValues;
656
657 _configFileHandler->getAllCurrentProperties(propertyNames, propertyValues);
658
659 Uint32 size = propertyNames.size();
660
|
661 mike 1.2 //
662 // initialize all the property owners with the values
663 // from the config files.
664 //
|
665 kumpf 1.49 for (Uint32 i = 0; i < size; i++)
|
666 mike 1.2 {
|
667 kumpf 1.49 //
668 // initialize the current value of the property owner
669 // with the value from the config file handler
670 //
671 try
|
672 mike 1.2 {
|
673 kumpf 1.13 //
|
674 kumpf 1.49 // get property owner object from the config table.
|
675 kumpf 1.13 //
|
676 kumpf 1.49 ConfigPropertyOwner* propertyOwner;
677
678 String propertyName = propertyNames[i].getString();
679
680 if (_propertyTable->ownerTable.lookup(
681 propertyName, propertyOwner))
|
682 mike 1.2 {
|
683 kumpf 1.49 if (propertyOwner->isValid(
684 propertyName, propertyValues[i]))
685 {
686 propertyOwner->initCurrentValue(
687 propertyName, propertyValues[i]);
|
688 mike 1.2
|
689 kumpf 1.49 propertyOwner->initPlannedValue(
690 propertyName, propertyValues[i]);
691 }
692 else
|
693 mike 1.2 {
|
694 kumpf 1.49 throw InvalidPropertyValue(propertyName, propertyValues[i]);
|
695 mike 1.2 }
696 }
|
697 kumpf 1.49 else
|
698 mike 1.2 {
|
699 kumpf 1.49 throw UnrecognizedConfigProperty(propertyName);
|
700 mike 1.2 }
|
701 kumpf 1.49 }
702 catch(UnrecognizedConfigProperty& ucp)
703 {
704 PEG_TRACE_STRING(TRC_CONFIG, Tracer::LEVEL2, ucp.getMessage());
705 throw;
706 }
707 catch(InvalidPropertyValue& ipv)
708 {
709 PEG_TRACE_STRING(TRC_CONFIG, Tracer::LEVEL2, ipv.getMessage());
710 throw;
|
711 mike 1.2 }
712 }
713 }
714
715
|
716 chip 1.68 /**
717 Initialize config property with the value specified
|
718 mike 1.2 in the command line.
719 */
720 Boolean ConfigManager::_initPropertyWithCommandLineOption(
|
721 chip 1.68 const String& option)
|
722 mike 1.2 {
|
723 kumpf 1.59 Uint32 pos = option.find('=');
|
724 mike 1.2 if (pos == PEG_NOT_FOUND)
725 {
726 //
727 // The property value was not specified
728 //
|
729 chip 1.68 throw UnrecognizedConfigProperty(option);
|
730 mike 1.2 }
731
732 //
733 // Get the property name and value
734 //
|
735 kumpf 1.59 String propertyName = option.subString(0, pos);
736 String propertyValue = option.subString(pos+1);
|
737 mike 1.2
|
738 kumpf 1.59 return initCurrentValue(propertyName, propertyValue);
|
739 mike 1.2 }
740
|
741 chip 1.68 /**
|
742 mike 1.2 Initialize config property owners and add them to the property owner table
743 */
|
744 kumpf 1.10 void ConfigManager::_initPropertyTable()
|
745 mike 1.2 {
746 //
|
747 kumpf 1.10 // add config property and its fixed value to fixed value table
748 //
749 for (Uint32 i = 0; i < NUM_FIXED_PROPERTIES; i++)
750 {
|
751 kumpf 1.14 _propertyTable->fixedValueTable.insert(_fixedValues[i].propertyName,
752 _fixedValues[i].fixedValue);
|
753 kumpf 1.10 }
754
755 //
756 // add config property and its owner object to owners table (but only if
757 // the property is not also listed in the fixed value table.
|
758 mike 1.2 //
759 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
760 {
|
761 kumpf 1.10 const char* fixedValue;
|
762 mike 1.2
|
763 kumpf 1.31 _properties[i].propertyOwner->initialize();
764
|
765 kumpf 1.10 if (!_propertyTable->fixedValueTable.lookup(
|
766 kumpf 1.14 _properties[i].propertyName, fixedValue))
|
767 kumpf 1.10 {
|
768 kumpf 1.14 _propertyTable->ownerTable.insert(_properties[i].propertyName,
769 _properties[i].propertyOwner);
|
770 kumpf 1.31 }
771 else
772 {
773 //
774 // Set the value for the fixed properties
775 //
776 _properties[i].propertyOwner->initCurrentValue(
777 _properties[i].propertyName, fixedValue);
|
778 kumpf 1.10 }
|
779 mike 1.2 }
780 }
781
|
782 kumpf 1.6 /**
783 Get Pegasus Home
784 */
785 String ConfigManager::getPegasusHome()
786 {
787 return _pegasusHome;
788 }
789
790 /**
791 Set Pegasus Home variable
792 */
|
793 aruran.ms 1.74 void ConfigManager::setPegasusHome(const String& home)
|
794 kumpf 1.6 {
795 if ( home != String::EMPTY )
796 {
797 _pegasusHome = home;
798 }
799 }
800
801 /**
|
802 chip 1.68 Get the homed path for a given property.
|
803 kumpf 1.6 */
804 String ConfigManager::getHomedPath(const String& value)
805 {
|
806 tony 1.32 String homedPath = String::EMPTY;
|
807 chip 1.68
|
808 tony 1.32 if ( value != String::EMPTY )
809 {
810 if ( System::is_absolute_path((const char *)value.getCString()) )
811 {
|
812 chip 1.68 return value;
|
813 tony 1.32 }
814
815 //
816 // Get the pegasusHome and prepend it
817 //
|
818 konrad.r 1.50
819 String temp = value;
820 Uint32 pos =0;
821 Uint32 token=0;
822 do {
|
823 konrad.r 1.51 if (( pos = temp.find(FileSystem::getPathDelimiter())) == PEG_NOT_FOUND) {
|
824 konrad.r 1.50 pos = temp.size();
825 token = 0;
826 }
827 else {
828 token = 1;
829 }
|
830 chip 1.68 if (System::is_absolute_path((const char *)temp.subString(0,pos).getCString()))
|
831 konrad.r 1.50 {
832 homedPath.append(temp.subString(0,pos));
833 } else
834 homedPath.append( _pegasusHome + "/" + temp.subString(0, pos));
835
836 if (token == 1)
|
837 konrad.r 1.51 homedPath.append(FileSystem::getPathDelimiter());
|
838 chip 1.68 temp.remove(0,pos+token);
|
839 konrad.r 1.50 }
|
840 chip 1.68 while ( temp.size() > 0 );
841
|
842 tony 1.32 }
843 return homedPath;
|
844 kumpf 1.6 }
|
845 chip 1.68
|
846 mike 1.2 PEGASUS_NAMESPACE_END
847
|