Add a test to show that when we encounter the same MultiStrOption in
several sources, the values are merged into one list.
Related-Bug: #1490990
Change-Id: Ie0324572191f084a3646d8bfb1d214d14221244d
The Integer type class has an option for setting a min or max value for the
integer. But the class would not recognize zero as a valid value and not
check it.
Make the Integer class honor zero as a valid value for min and/or max.
Add test cases for using zero for min and/or max.
Change-Id: I395dea133d2a92e5ca4fab913aa17483a38f7ba1
Closes-Bug: #1489688
Add a new `show-options` directive for use in sphinx documentation to
embed the help and metadata about options in the output of the rendered
docs.
Change-Id: I549c8db98bf548dd0a7e8869a57301fa4096f78c
This commit adds a sphinx extension which can be loaded in a sphinx
config.py to generate a sample config file using oslo-config-generator
during each sphinx build. This can then be incorporated into
documentation as necessary.
Co-Authored-By: Doug Hellmann <doug@doughellmann.com>
Change-Id: I2561155749fc8c6a8e31df1614ca6cdb50b4c001
The config options are an interface to a subset of users. These users
need to read and understand the help text of the options. To make it
easier to read, it should be possible to preformat the text. This
patch set keeps the preformat with line breaks.
Change-Id: I8aa871001f7da3cefcd9aa93992d50d0d9140157
The 'override' value of an option is currently stored and retrieved
with the exact value that is set through set_override method - not
taking into account the type of that option. Sometimes we want the type
of the override value to be the same as the option type and therefore
we will add an optional parameter to the set_override method that will
enforce the option value type.
Closes-Bug: #1461299
Change-Id: I008b76d3292f76d0699f0063930a3b190539740f
Blueprint remove-namespace-packages
Depends-on: I77e50f2f14345321d1b5319343c5872a92977936
for openstack/murano-agent
Depends-on: If51059c31c82d5235e2ae21143911b5561783ca6
for openstack/os-collect-config
Depends-on: I324ca86a21c27ce43cebf255b3c075b8fe110820
for openstack/sahara-dashboard
Depends-on: Icfc882db41883410f7b40fc5a22bfaae1a65dedc
for openstack/tempest
Depends-on: I396a64aa7610b5fcc0bab05bff442ae6b43c6164
for openstack/congress
Depends-on: I749f43bd6dc15717154475cc1a776ffd6164b7fa
for openstack/octavia
Depends-on: I892c0b64ff6bab666f1f23f5e7aeb2da088ea087
for stackforge/python-solumclient
Depends-on: I09b3bec4c68c7fe9379b3d5fefbceaa86ffe994e
for openstack/congress
Related fixes for projects that can't build for other reasons:
I7d35c85926c8f098e2e47051ff44b714478df1b7 for stackforge/magnetodb
needed for the gate:
Depends-On: I0f07858e96ea3baf46f8a453e253b9ed29c7f7e2
Depends-On: I33bd2d9dff9cb7dc1a50177db7286b7317966784
Change-Id: Ibe16f8d7f73234845cab94c8e351f41954eecb0a
Correctly assert the number of calls to a mocked method.
Combine this with the change to pin the version of mock used for python
2.6 and raise the minimum version of mock used elsewhere.
Change-Id: I8cf1936f06f489561a59ec3cc75a1a8d6419a9ef
The IntOpt class utilizes the types.Integer class which has
parameters for setting the minimum and maximum value. These min
and max values are not exposed through IntOpt and should be ideally.
In the docstring help for cfg.py, it gives an example of creating a
PortType instance of types.Integer to create a new type with a range.
Rather than projects having to define this new instance, seems better
to just expose the min and max to IntOpt.
Another advantage of adding min and max to IntOpt is the ability to
generate a useful sample config file that displays the range of
valid integer values.
Change-Id: Icce7b6799061711ea512d60facc57bf7d6f6c9cc
In method __getattr__ of ConfigOpts, we catch all exceptions and convert
it to NoSuchOptError. This is wrong, we need allow raise ValueError to
provide more details about the error.
Change-Id: Ic08b812424ff9ad79f03a9069877b610fcbd4172
Closes-Bug: #1471149
Add a set_default() method to the fixture to allow it to be passed to
set_default() functions in other oslo libraries that expect to be given
a ConfigObj instance. This lets tests in one project use a fixture to
set defaults for options in code they don't own, and unset those
defaults when the test is cleaned up.
Change-Id: Ifa9e6e2ab4ab4f93a7dc22d786ee6fd6ae7224ae
The latest releases of fixtures do not allow a fixture to be cleaned up
more than once, so rewrite the fixture tests to manage the fixture by
hand and not clean it up unless that is part of the test being run.
Change-Id: I1e2aaa59e713eca231a315860ef84bc272bbe280
When there are no positional arguments only N-1 arguments
were sorted. The original unit test covered this case, but
had no luck to catch the issue.
Closes bug 1466061
Change-Id: I54ac8d5b6b20dd42b6c49873e5b0000fe7b92057
Fix an error appear when trying to sort options when having many options
and many groups in python 3.4.
Change-Id: Iec7447e004f3708d92bd30aad94a17378fc25f31
Closes-Bug: #1463025
Sphinx has a directive for python object properties (it calls them
attributes)[1]. This should be used for properties since then they
can be referenced.
[1] http://sphinx-doc.org/domains.html#directive-py:attribute
Change-Id: I8c022356f88a21f5a79f1b1c0ae6e315a76d3f3b
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',
)
)
print f.myflag
Closes-Bug: #1366946
Change-Id: I94df9409f72807461370b4aaf8eb2543c52a89bb
This patch adds support for config variable interpolation with values
coming form… other groups than the current/default one!
Change-Id: Iddd21aa2da71fe332868049d4b94b75b562b61cd
There seems to be an issue when using oslo-config-generator with
cfg.OptGroup. It seems the generator was not checking if the group
was an object or not. Resulting in section names as the following:
[DEFAULT]
[<oslo_config.cfg.OptGroup object at 0x325c350>]
Change-Id: I946d55fcd713369dda4cdf490391a75901bded22
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
It's sometimes hard to find the option with a bad value. In a
couple ConfigFileValueError cases, the option is not included in
the log message.
Change-Id: Ib373f5184b7339ebd59a6d7eb53f3b02a5d59f4f
Closes-Bug: #1451479
Deployers may want to rely on specific order of the files being loaded,
so we should make sure it's not changed, and that it's documented.
Note: test_config_dir already checks for the sorting order of
configuration files, so there is no need for a new test case.
Change-Id: Idc26b926601554b5592e13da92fbe81db99eb6e0
This patch adds a set_config_files option that allows a tester to
force load a specific list of configuration files. It will override the
existing set of files, and trigger a reload of those configuration
files.
Note: This _does_ trigger the autodetection mechanism, as the
present state of oslo_config makes it so __call__ is the only thing
that sets self._args. After triggering, however, it immediately
overrides the detected file list and replaces it with the provided one.
Tests provided.
Change-Id: I0bcea8be9d2527c61bd8d150e9ed606fabdd290e
This patch adds a method by which raw key/value pairs may be
loaded into the test fixture, without them being registered
first. Tests have been provided.
Change-Id: I53d77e4782bf97aefee11edd489ff1c9ff6c69a3
Update the hacking requirement to the version used by kilo, and fix code
that fails the new tests.
Change-Id: I6e18878e4ba826528af82438f4e4394cc644d623
When a deprecated opt is used and the new opt name has the dest
property overridden, we were logging the dest property instead of
the actual opt name in the deprecation warning. This is confusing
because it leads to log messages such as:
Option "username" from group "nova" is deprecated. Use option
"username" from group "nova".
This is nonsense. In this case the proper new name was "user-name"
but because it had a dest override of "username" that's what was
logged.
Because the deprecation check code does not have access to the
actual opt itself, we need to pass the undeprecated name down from
the opt into the namespace code that does the check.
I also tried simply adding a (group, name) tuple to the beginning
of the names list, but this subtly broke the CLI opt tests because
there are specific combinations of - and _ variants expected, and
this seems to violate those assumptions. I did not pursue it any
further because I felt it was better to simply be explicit about
the current name and not mess around with adding non-existent opt
names to the lookup list solely for logging purposes.
Change-Id: Ib1ea8ae2d60a9c508935bad27d7ddc2cdb5ab505
Closes-Bug: #1438314
The docs for the class constructor parameters for several
classes weren't rendered because they were on the __init__
method, which sphinx doesn't render. When the docs are generated
for the class the __init__ parameters are shown after the class
name, so the parameters should be documented on the class where
they'll be rendered rather than on __init__.
Change-Id: I674ff76495aa4b30273083201f365bce790f447e
Docs were generating warnings
oslo_config/cfg.py:docstring of oslo_config.cfg.DeprecatedOpt:23: WARNING: Definition list ends without a blank line; unexpected unindent.
oslo_config/cfg.py:docstring of oslo_config.cfg.DeprecatedOpt:25: ERROR: Unexpected indentation.
because the rst was invalid.
Change-Id: I273dcc8085019d13230dfce2f069863295282166
Follow on to:
I3bb3621420915a6a2990440294a389b45a23c519
choices can have None (as a default) or an empty string "" (as a
default value or when read from a config file). We need to print
better message in the sample config for these two cases.
Change-Id: Iba483c0e4180fc95181b161f996cce5e627035f5
Tempest using StrOpt with choices
choices=[None, 'normal', 'direct', 'macvtap']
And oslo-config-generator does not like it. We need to
print "<None>" when we encounter None as a choice.
Closes-Bug: #1429981
Change-Id: I3bb3621420915a6a2990440294a389b45a23c519
Since the introduction of choices, the help text does not indicate
possible values of these choices. This patch adds to the help a
list of all values that are accepted.
Change-Id: I68edda59ad7a690918f8e45abe2b3b56cd01ada7
Closes-Bug: 1427913
Add some section headings, clean up some of the formatting, and add
information about how to handle modules with optional dependencies.
Change-Id: I731fd7b191e834e22a99516f1b4b584bad6868fd
Previously opts could only be deprecated by renaming them, but there
are circumstances where we may want to remove an opt completely, and
we need a way to notify users before this happens. This change adds
a deprecated_for_removal parameter to the Opt constructor that can
be used to mark opts for which this is planned. When such opts are
referenced it will log a message, but only if the default value has
been overridden.
Change-Id: I0165895d58530f5fce58cbf8a1bbe2acd90e9063