使用oslo_config项目来管理配置文件,下面算是一个Hello World。
from oslo_config import cfg
CONF = cfg.CONF
opts = [
cfg.BoolOpt('enabled', default=False,
help='Global toggle for caching.'),
cfg.StrOpt('backend',
default='',
help='Where instances xml are stored on disk'),
cfg.MultiStrOpt('backend_argument', default=[], secret=True,
help='Arguments supplied to the backend module. '
'Specify this option once per argument to be '
'passed to the dogpile.cache backend. Example '
'format: "<argname>:<value>".')
]
CONF.register_opts(opts, group="cache")
CONF(['--config-file', 'config.conf'])
print CONF.cache.enabled
print CONF.cache.backend
print CONF.cache.backend_argument