oslo config reading a config file

asked 2015-05-17 01:38:30 -0500

sarath gravatar image

updated 2015-05-18 04:55:16 -0500

SGPJ gravatar image

I created a new conf file in keystone project as part of my extenstion. I wanted to use the options in that file.

I also created the config.py file

from oslo_config import cfg
from oslo_config import types
from oslo_log import log

LOG = log.getLogger(__name__)

otp_options = cfg.OptGroup(name = "otp_options",
                         title= "Options for One time password")

one_time_password_opts =[ 
    cfg.IntOpt('time_step', default = 30,
           help = ''),

cfg.IntOpt('time_step_window_back', default = 2,
           help = ''),

cfg.StrOpt('connection', default = 'mysql://keystone:root@localhost/keystone',
           help = ''),

]

CONF = cfg.CONF
CONF.register_group(otp_options)
CONF.register_opts(one_time_password_opts, otp_options)

CONF(default_config_files=['/etc/keystone/keystone.otp.conf',])

/etc/keystone/keystone.otp.conf

[otp_options]
#Options for One time password functionality

time_step = 60

time_step_window_back = 2

connection = 'mysql://keystone:root@localhost/keystone'

but when it is used on a another python file

import config

CONF = config.CONF
LOG.info(CONF.otp_options.time_step)

it displayes 30, when I run the program

edit retag flag offensive close merge delete