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