← Back to team overview

openstack team mailing list archive

Re: [RFC] Common config options module

 

On Mon, 2011-12-05 at 15:32 -0800, Andy Smith wrote:
> Took a look over the wiki for this. The approach is very similar to one
> I've used recently so I wanted to bring up something that looks like it may
> have been overlooked.
> 
> In testing it is frequent practice that you want to ensure global config
> state and somehow overwrite global config state on the fly (for example
> when you have dynamic ports being assigned to a service), passing config
> dicts around everywhere makes this task a bit harder. My solution was to
> force all instances being handed an options dict to assign it to the
> .options attribute on itself, and to use a common name for chained
> applications so that it is possible to traverse the tree:
> 
> https://github.com/termie/keystonelight/blob/master/keystonelight/test.py#L107

Glance already was passing a config dict around so, for tests, I found
it quite handy to have a little helper which actually wrote out a
temporary config file with overrides:

  https://github.com/markmc/glance/blob/31bcda2f09d49a8214fc1a56ffc3543fcad590aa/glance/tests/utils.py#L32

With Nova, it'll be quite a challenge to get to a point where we're not
using a global variable for accessing config. For Nova tests, I added
set_default() and set_override() methods:

  https://github.com/markmc/nova/blob/101dfcb0fe4f2c5db20e9c8305e8ca87bb5b7e54/nova/common/cfg.py#L855

Cheers,
Mark.



References