[openstack-dev] [oslo] Option registration convention?

Kevin L. Mitchell kevin.mitchell at rackspace.com
Thu Jun 13 15:24:54 UTC 2013


On Thu, 2013-06-13 at 13:35 +0800, Zhongyue Luo wrote:
> First method is to change how generate.py works. Rake all modules in
> project which imports oslo.config.cfg and create a module object of it
> to inspect the cfg.CONF object inside. We can cache all the options
> which were already seen and print out newly discovered options. The
> downside of this solution is that we have to call a private function
> in ConfigOpts called _all_opt_infos() to look at all options
> registered.
> https://github.com/openstack/oslo.config/blob/master/oslo/config/cfg.py#L1822
> 
> We would have to create a public api version of it.
> 
> 
> 
> The second option is to make it a convention that all options should
> be declared in global view and also registered in the same module
> where they were defined. However it would be difficult to write a
> hacking.py routine to check this and there will be significant amount
> of code we have to change. 

A third option is to create a decorator that sets an attribute on these
functions that install config options; then, you just look for functions
with that attribute set and make sure they get called.  Then just go
through all the projects and make sure that decorator is set up on all
such functions.  That should require minimal code changes across the
OpenStack projects while still giving you what you need to auto-generate
sample configurations and documentation…
-- 
Kevin L. Mitchell <kevin.mitchell at rackspace.com>




More information about the OpenStack-dev mailing list