[simple]
enable=False
<pre style="background-color: rgb(255, 255, 255); font-family: Consolas; font-size: 9.8pt;"><span style="color:#000080;"><strong> </strong></span><pre name="code" class="html">from __future__ import print_function
from oslo_config import cfg
# opt group
# opt_group = cfg.OptGroup(name="simple", title='A Simple Example')
# opt
simple_opts = [cfg.BoolOpt('enable',
default=False,
help='True enables, false disables')
]
CONF = cfg.CONF
# CONF.register_group(opt_group)
# CONF.register_opts(simple_opts, opt_group)
CONF.register_opts(simple_opts, group="simple")
if __name__ == "__main__":
CONF(default_config_files=['app.conf'])
print(CONF.simple.enable)
CONF.import_opt('task_time_to_live', 'glance.common.config', group='task')
从python模块
glance.common.config中获取"task"组下的"task_time_to_live"配置的值