make registering a cli opt on a filter object work.
Change the behaviour of ConfigFilter.register_cli_opt to:
1. If the opt is already registered before parsing, then registering
just import it.
2. if the opt is not registered before, then raise an exception named
CliOptRegisteredError.
By adding this modification, the behaviour of
ConfigFilter.register_cli_opt looks more consistent to
ConfigOpts.register_cli_opt. The solution to the question mentioned in
Bug#1366946 should be like this:
from oslo_config import cfg
from oslo_config import cfgfilter
import sys
c = cfg.CONF
c.register_cli_opt(
cfg.BoolOpt('myflag',
default=False,
help='turn on myflag',
)
)
c(sys.argv[1:])
f = cfgfilter.ConfigFilter(c)
f.register_cli_opt(
cfg.BoolOpt('myflag',
default=False,
help='turn on myflag',
)
)
Reviewed: https:/ /review. openstack. org/171908 /git.openstack. org/cgit/ openstack/ oslo.config/ commit/ ?id=f1f972aeb7e 7e6f672b55fb8ee fc37de71f5d551
Committed: https:/
Submitter: Jenkins
Branch: master
commit f1f972aeb7e7e6f 672b55fb8eefc37 de71f5d551
Author: Tong Damon Da <email address hidden>
Date: Thu Apr 9 13:19:28 2015 +0800
make registering a cli opt on a filter object work.
Change the behaviour of ConfigFilter. register_ cli_opt to:
1. If the opt is already registered before parsing, then registering
just import it.
2. if the opt is not registered before, then raise an exception named
CliOptRegis teredError. r.register_ cli_opt looks more consistent to register_ cli_opt. The solution to the question mentioned in
By adding this modification, the behaviour of
ConfigFilte
ConfigOpts.
Bug#1366946 should be like this:
from oslo_config import cfg
from oslo_config import cfgfilter
import sys
c = cfg.CONF cli_opt( BoolOpt( 'myflag' ,
c.register_
cfg.
default=False,
help='turn on myflag',
)
)
c(sys.argv[1:])
f = cfgfilter. ConfigFilter( c) cli_opt( BoolOpt( 'myflag' ,
f.register_
cfg.
default=False,
help='turn on myflag',
)
)
print f.myflag
Closes-Bug: #1366946 461370b4aaf8eb2 543c52a89bb
Change-Id: I94df9409f72807