[openstack-dev] [nova][oslo] oslo.config and import chains

Matt Riedemann mriedem at linux.vnet.ibm.com
Thu Aug 7 15:55:55 UTC 2014



On 8/7/2014 10:27 AM, Kevin L. Mitchell wrote:
> On Thu, 2014-08-07 at 12:15 +0100, Matthew Booth wrote:
>> A (the?) solution is to register_opts() in foo before importing any
>> modules which might also use oslo.config.
>
> Actually, I disagree.  The real problem here is the definition of
> bar_func().  The default value of the parameter "arg" will likely always
> be the default value of foo_opt, rather than the configured value,
> because "CONF.foo_opt" will be evaluated at module load time.  The way
> bar_func() should be defined would be:
>
>          def bar_func(arg=None):
>              if not arg:
>                  arg = CONF.foo_opt
>>
> That ensures that arg will be the configured value, and should also
> solve the import conflict.
>

Surely you mean:

if arg is not None:

right?! I'm pretty sure there is a hacking check for that now too...

:)

-- 

Thanks,

Matt Riedemann




More information about the OpenStack-dev mailing list