[openstack-dev] How do I mark one option as deprecating another one ?
Denis Makogon
dmakogon at mirantis.com
Wed Feb 26 14:30:59 UTC 2014
Here what oslo.config documentation says.
Represents a Deprecated option. Here's how you can use it
oldopts = [cfg.DeprecatedOpt('oldfoo', group='oldgroup'),
cfg.DeprecatedOpt('oldfoo2', group='oldgroup2')]
cfg.CONF.register_group(cfg.OptGroup('blaa'))
cfg.CONF.register_opt(cfg.StrOpt('foo', deprecated_opts=oldopts),
group='blaa')
Multi-value options will return all new and deprecated
options. For single options, if the new option is present
("[blaa]/foo" above) it will override any deprecated options
present. If the new option is not present and multiple
deprecated options are present, the option corresponding to
the first element of deprecated_opts will be chosen.
I hope that it'll help you.
Best regards,
Denis Makogon.
On Wed, Feb 26, 2014 at 4:17 PM, Day, Phil <philip.day at hp.com> wrote:
> Hi Folks,
>
>
>
> I could do with some pointers on config value deprecation.
>
>
>
> All of the examples in the code and documentation seem to deal with the
> case of "old_opt" being replaced by "new_opt" but still returning the same
> value
>
> Here using deprecated_name and / or deprecated_opts in the definition of
> "new_opt" lets me still get the value (and log a warning) if the config
> still uses "old_opt"
>
>
>
> However my use case is different because while I want deprecate old-opt,
> new_opt doesn't take the same value and I need to different things
> depending on which is specified, i.e. If old_opt is specified and new_opt
> isn't I still want to do some processing specific to old_opt and log a
> deprecation warning.
>
>
>
> Clearly I can code this up as a special case at the point where I look for
> the options - but I was wondering if there is some clever magic in
> oslo.config that lets me declare this as part of the option definition ?
>
>
>
>
>
>
>
> As a second point, I thought that using a deprecated option automatically
> logged a warning, but in the latest Devstack wait_soft_reboot_seconds is
> defined as:
>
>
>
> cfg.IntOpt('wait_soft_reboot_seconds',
>
> default=120,
>
> help='Number of seconds to wait for instance to shut down
> after'
>
> ' soft reboot request is made. We fall back to hard
> reboot'
>
> ' if instance does not shutdown within this window.',
>
> deprecated_name='libvirt_wait_soft_reboot_seconds',
>
> deprecated_group='DEFAULT'),
>
>
>
>
>
>
>
> but if I include the following in nova.conf
>
>
>
> libvirt_wait_soft_reboot_seconds = 20
>
>
>
>
>
> I can see the new value of 20 being used, but there is no warning logged
> that I'm using a deprecated name ?
>
>
>
> Thanks
>
> Phil
>
>
>
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20140226/aeebd1ed/attachment.html>
More information about the OpenStack-dev
mailing list