summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorTim Laszlo <tim.laszlo@gmail.com>2012-08-09 09:59:39 -0500
committerTim Laszlo <tim.laszlo@gmail.com>2012-08-09 09:59:39 -0500
commit6f93c29285cc3c688accd3f0ef25a251fb3f3372 (patch)
tree4147cdf2a01c98a9babd39420555b1b725026b27 /src/lib
parentba253e99a25540997a879356639804ffce633f00 (diff)
downloadbcfg2-6f93c29285cc3c688accd3f0ef25a251fb3f3372.tar.gz
bcfg2-6f93c29285cc3c688accd3f0ef25a251fb3f3372.tar.bz2
bcfg2-6f93c29285cc3c688accd3f0ef25a251fb3f3372.zip
Bcfg2.Options: Add support for deprecated options
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Bcfg2/Options.py31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/lib/Bcfg2/Options.py b/src/lib/Bcfg2/Options.py
index 065b80013..a1684dac9 100644
--- a/src/lib/Bcfg2/Options.py
+++ b/src/lib/Bcfg2/Options.py
@@ -61,7 +61,8 @@ class Option(object):
return value
def __init__(self, desc, default, cmd=False, odesc=False,
- env=False, cf=False, cook=False, long_arg=False):
+ env=False, cf=False, cook=False, long_arg=False,
+ deprecated_cf=None):
self.desc = desc
self.default = default
self.cmd = cmd
@@ -75,6 +76,7 @@ class Option(object):
self.odesc = odesc
self.env = env
self.cf = cf
+ self.deprecated_cf = deprecated_cf
self.boolean = False
if not odesc and not cook and isinstance(self.default, bool):
self.boolean = True
@@ -134,6 +136,15 @@ class Option(object):
return
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
pass
+ if self.deprecated_cf:
+ try:
+ self.value = self.get_cooked_value(configparser.get(*self.deprecated_cf))
+ print "Warning: [%s] %s is deprecated, use [%s] %s instead" % \
+ (self.cf[0], self.cf[1], self.deprecated_cf[0], self.deprecated_cf[1])
+ return
+ except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
+ pass
+
# Default value not cooked
self.value = self.default
@@ -429,27 +440,33 @@ SERVER_BACKEND = \
DB_ENGINE = \
Option('Database engine',
default='django.db.backends.sqlite3',
- cf=('database', 'engine'))
+ cf=('database', 'engine'),
+ deprecated_cf=('statistics', 'database_engine'))
DB_NAME = \
Option('Database name',
default=os.path.join(SERVER_REPOSITORY.default, "bcfg2.sqlite"),
- cf=('database', 'name'))
+ cf=('database', 'name'),
+ deprecated_cf=('statistics', 'database_name'))
DB_USER = \
Option('Database username',
default=None,
- cf=('database', 'user'))
+ cf=('database', 'user'),
+ deprecated_cf=('statistics', 'database_user'))
DB_PASSWORD = \
Option('Database password',
default=None,
- cf=('database', 'password'))
+ cf=('database', 'password'),
+ deprecated_cf=('statistics', 'database_password'))
DB_HOST = \
Option('Database host',
default='localhost',
- cf=('database', 'host'))
+ cf=('database', 'host'),
+ deprecated_cf=('statistics', 'database_host'))
DB_PORT = \
Option('Database port',
default='',
- cf=('database', 'port'),)
+ cf=('database', 'port'),
+ deprecated_cf=('statistics', 'database_port'))
# Django options
DJANGO_TIME_ZONE = \