| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The cfg API is now available via the oslo-config library, so switch to
it and remove the copied-and-pasted version.
Add the 2013.1b3 tarball to tools/pip-requires - this will be changed
to 'oslo-config>=2013.1' when oslo-config is published to pypi. This
will happen in time for grizzly final.
Remove the 'deps = pep8==1.3.3' and 'deps = pyflakes' from tox.ini as
it means all the other deps get installed with easy_install which can't
install oslo-config from the URL.
Change-Id: I4815aeb8a9341a31a250e920157f15ee15cfc5bc
|
|
|
|
|
|
|
|
|
| |
Created import_group method in cfg.py
Added testcases
Fixes bug #1107843
Change-Id: I427d4069dacbb6e586687370adbb08b5d50f7b63
|
|
|
|
|
|
|
|
| |
BaseTestCase properly hooks stubout into fixtures. Just use that.
Part of blueprint grizzly-testtools.
Change-Id: I4bf6b92b9b16d051d8c6ecaf52cf70925848ed8c
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
On the path to testr migration, we need to replace the unittest base classes
with testtools.
Replace tearDown with addCleanup, addCleanup is more resilient than tearDown.
The fixtures library has excellent support for managing and cleaning
tempfiles. Use it.
Replace skip_ with testtools.skipTest
Part of blueprint grizzly-testtools.
Change-Id: I45e11bbb1ff9b31f3278d3b016737dcb7850cd98
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We learned a lesson in Nova - it's best to declare and use config
options within a single module if possible. Globally declared and
use config options grow like weeds and it becomes harder to find out
if, where and how individual options are used.
Strangely, in cfg itself, we randomly declare a bunch of logging options
which are only used within the openstack.common.log module - let's move
the options there and remove the CommonConfigOpts class before they
become part of the API we commit to when oslo-config is released.
A minor detail in the patch - the logfile and logdir options are already
deprecated in favour of log_file and log_dir, but we never got around to
removing all other traces of the deprecated options.
Change-Id: I3913ea54465658d93dc56e014dfe5d911b0541d6
|
|
|
|
| |
Change-Id: I3e35230dd2d96ab9f5a8c11b9ec1cd8d2d00e347
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This reverts commit 525ac47.
There are already two ways to reference an option in a group:
CONF.group.key
CONF[group].key
Adding a third variant doesn't seem ideal. Also, for the specific case
of LazyPluggable in Nova, we can easily just pass an optional config
group name to the constructor.
Change-Id: I1a29a18d90e8af3ce2563bd1b3eeb64422140016
|
|
|
|
|
|
|
|
|
|
|
|
| |
Let us check if the opt_name has a '.', if it does then split it
into a group/key and try lookup using that combination. Since
LazyPluggable uses "CONF[self.__pivot]" if we just add this
capability to cfg, we get "LazyPluggable doesn't support
option groups" for free.
Fixes LP #1093043
Change-Id: I9cedcf22014038e9fe4ed5e66ca5427aa99b5091
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| | |
--logfile and --logdir are aliases Nova has for the --log-file and
--log-dir. If we're to support --logfile as a deprecated common
option, we should do the same for --logdir.
Change-Id: I16485a93070d9ad7789a287d5b035c6f270ffead
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This adds a deprecated common options for --logfile which
is an alias for --log_file. This resolves some backwards compatability
issues with the most recent oslo common code where --logfile
was no longer a valid opt.
Change-Id: I17b1277da94a2d81ae439d650a6d7321420dfe14
|
|\ \
| |/
|/| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
- In log.py, indicate that logging module allows tweaking
of just logging_context_format_string option
- In cfg.py, add a method that can alter the default given
the options and new default
- add testcases for log.set_defaults and cfg.set_defaults
Fixes LP #1083218
Change-Id: Iefdbce8505eb7a07f2b59d4ed7564b0146f1b0cd
|
|\ \
| |/
|/| |
|
| |
| |
| |
| |
| |
| | |
Fixes Bug 1087018
Change-Id: I1c2d34166ae85add86daab6a7483b63297d00f66
|
|\ \ |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Porting to argparse broke set_default() with boolean CLI options. The
new test case shows this borkage.
The issue is that, by default, argparse differs subtly from optparse in
its handling of defaults for boolean options. Compare:
>>> p = optparse.OptionParser()
>>> p.add_option('--foo', action='store_true')
>>> p.add_option('--bar', action='store_true', default=False)
>>> p.parse_args([])
(<Values at 0x7f28aba066c8: {'foo': None, 'bar': False}>, [])
to:
>>> p = argparse.ArgumentParser()
>>> p.add_argument('--foo', action='store_true')
>>> p.add_argument('--bar', action='store_true', default=False)
>>> p.add_argument('--blaa', action='store_true', default=None)
>>> p.parse_args([])
Namespace(bar=False, blaa=None, foo=False)
i.e. unless you specify a default for a boolean option, optparse
defaults to None whereas argparse defaults to False. To get the
same optparse behaviour with argparse, you need default=None.
Change-Id: Ifc92a834c4ba59e939d80ac5de24d7051232f5b5
|
|\| |
| |/
|/| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
In order for sub-parsers to be useful, you need some way of knowing
which sub-parser was chosen during argument parsing. It's pretty obvious
from the current sub-parsers test case that we don't have a convenient
interface for this.
One way of doing it is to use the 'dest' argument when adding
sub-parsers:
>>> subparsers = parser.add_subparsers(dest='cmd')
>>> subparsers.add_parser('a')
>>> subparsers.add_parser('b')
>>> parser.parse_args(['a'])
Namespace(cmd='a')
The most sensible way to map this into cfg concepts is to register
sub-parsers as an Opt. This way, we can make name and argument values
of the sub-parser as an attribute on the ConfigOpts object:
>>> def add_parsers(subparsers):
... a = subparsers.add_parser('a')
... a.add_argument('id')
... b = subparsers.add_parser('b')
...
>>> CONF.register_cli_opt(SubCommandOpt('cmd', handler=add_parsers))
True
>>> CONF(['a', '10'])
>>> CONF.cmd.name, CONF.cmd.id
('a', '10')
The handler method is a bit awkward, but each time cfg is to parse
command line args it takes all the registered opts and creates a new
argparse parser. So we need to be able to re-add the sub-parsers each
time.
Change-Id: I01bfd01bf8853cf57a9248b1663eb3da142366a4
|
|\ \ |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
There's no reason why an option group shouldn't have options called
'group' or 'conf'.
Add a test case which would have failed because the 'conf' attribute
would have been a ConfigOpts instance and fix it by making those
attributes private.
Change-Id: Ic3e41a546c0d1b7b6aae04e1dbac2933ac661f57
|
|\ \ \
| | |/
| |/| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Fixes bug #1082279
Only options registered using register_cli_opt() should be available via
the CLI, but since e42276a all options are added to the CLI.
Also modify one of the existing unit tests to catch this problem.
Change-Id: I742a4ae4e0fc17cd9ae5e4424c2edd38e2bc50a2
|
|\ \ \ |
|
| | |/
| |/|
| | |
| | |
| | |
| | | |
This gets the code coverage of the tests back up to 100%.
Change-Id: I737c1cfa52d10b3813237a9cb88b15211e0872c1
|
|\ \ \
| |_|/
|/| | |
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Since we switched to argparse, the way help strings are interpolated
have changed and broken --help with the options registered by
CommonConfigOpts.
Fix and add a new test case which would catch the issue.
Change-Id: I10e42efe4721e22ff41d0efbf390c805ccb9a6a0
|
|/
|
|
|
|
|
|
|
| |
- throw in an extra strip() in the list parsing code
- add a test case to verify that it works!
Fixes LP #1079299
Change-Id: I4f0864c72ecd2569d0461c301acda395c87a93e0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
argparse makes it awkward to implement the current cfg API where we
simply return the leftover arguments to the caller.
Very few cfg users actually rely on this functionality and for those
cases it probably makes more sense for them to explicitly register
positional arguments or sub-parsers.
Add support for positional arguments via a 'required' Opt attribute:
opt = StrOpt('foo', positional=True)
conf.register_cli_opt(opt)
conf(['bar'])
conf.foo == 'bar'
Change-Id: Iea746d710237e1ea26c1ef4871643941d1df09bd
|
|
|
|
|
|
|
|
| |
optparse would print "Options" but argparse prints "optional arguments".
The default argparse behaviour is fine, let's stick with that.
Change-Id: Ib53a2581af9d776e9a7c1cd90eebe89b70034e57
|
|
|
|
|
|
|
|
|
|
|
| |
optparse would substitute the program name for %prog, but argparse
requires %(prog)s. Also, optparse would print 'Usage:' whereas
argparse prints 'usage:'.
Neither optparse behaviour that's worth retaining, let's just use
the default argparse behaviour.
Change-Id: Ied2acb37c366f1a45aed72b6b76f11e2de23828e
|
|
|
|
|
|
|
|
|
|
| |
optparse prints the version to stdout, argparse prints the version to
stderr.
There's no need to preserve the old optparse behaviour, let's just stick
with argparse behaviour.
Change-Id: Ie141c72112a63149d098afa9db55a95a309e79d7
|
|
|
|
|
|
|
|
| |
The use case for disable_interspersed_args() is that nova-manage
needs to be able to parse sub-commands. We now have a
add_cli_subparsers() method which better supports this use case.
Change-Id: I1fcd15889745fe4ddff0ac4bacf385004f9b61af
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* openstack/common/cfg.py
Optparse is fading out since python 2.7, this
patch will help openstack/common work on more
advanded version of python(argparse).
Now, disable_interspersed_args() has no effect.
Added new method add_cli_subparsers, return
argparse subparser, for usages such as
subcommand.
* tests/unit/test_cfg.py
SubcommandTestCase added.
Disabled test_disable_interspersed_args test entry
for happiness of tox, temporarily.
Modified test_help for port of argparse.
* tools/pip-requires
include argparse module for python 2.6
Change-Id: Ie5cbde1a92a92786d64dea0ddfcfbf288c29f960
|
|
|
|
|
|
|
|
|
| |
If an option has a dash in it and is required, the check fails because it
tries to self._get() on the name (with dash) rather than the dest (with
underscore).
Change-Id: I6448019f70f98bc2e58a325d0cf9ce88b8bb085b
Signed-off-by: Julien Danjou <julien@danjou.info>
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The current implementation interprets set_default('foo', None) and
set_override('foo', None) as 'clear the existing default or override',
which makes it impossible to override a value with None.
This patch adds support for overriding with a None value by adding
a special internal class. set_override('foo', None) will now override
the existing value with None. This is a slight change to the existing
behavior, so this patch adds two calls for the old functionality of
clearing defaults and overrides. Example syntax for the new calls
are shown below:
conf.clear_default('foo')
conf.clear_override('foo')
The patch also updates the tests to reflect the change in functionality
and adds new tests to verify the new functionality.
Fixes bug 1035478
Change-Id: Iee5e20e44da9bef6b86e0483ab0b48b625fe503c
|
|/
|
|
|
|
|
|
|
| |
Fixes bug #1012671
Allow a filename starting with ~ or ~user to be passed for
--config-file or --config-dir.
Change-Id: I67705401ed1c35c0cc2161095e36616552740aba
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Related to blueprint cfg-global-object
When using the global config object pattern, you often have modules
which define options that are referenced in other options.
So, for example if module A defined option 'foo' and module be needed
to reference that option, you might do:
import A
print CONF.foo
However, this makes it entirely unclear to the casual reader why
module A was imported.
Nova has a flags.DECLARE() function that helps with this problem
by allowing you to do:
flags.DECLARE('foo', 'A')
The function simply imports module A and checks that the 'foo'
option is now defined in the global config object.
This is fine, but it is also implicit that this function applies
to the global config object. Instead, let's do the following:
CONF.import_opt('foo', 'A')
Change-Id: I7b98f5be71068bbde70cc0eab991eaebb577de52
|
|
|
|
|
|
|
|
|
|
| |
This change fixes bug 999307
Currently, the check for duplicate options is done by checking
whether they are the same object. The proposed fix is to check whether
all the object fields have the same value.
Change-Id: I2b72d630a0c8821df1d81e25d316d8d9195be492
|
|
|
|
|
|
| |
bug 1014216
Change-Id: I3f8fa2e11c9d3f3d34fb20f65ce886bb9c94463d
|
|
|
|
|
|
|
|
|
|
| |
Implements blueprint config-aliases
* Supports loading deprecated aliased options from a config file
* Supports using deprecated aliased CLI options
* For MultiStrOpt Can use mix of name and alias
Change-Id: I04678880bc8ee1f85335f5656367bd1437245c6e
|
|
|
|
|
|
| |
Fixes a couple of pep8 errors that appeared due to a pep8 tool update.
Change-Id: Ida70b1fb962529d3a157f44dcf2e71af773a4431
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In order to effectively use a global ConfigOpts object, you
need to be able to initialize the global object with none of
the information we currently require at construction.
By moving those constructor args to the __call__() method,
we enable the global object usage model but also make the API
generally more flexible. For example, you can now reset the
object and re-use it for parsing a different set of config
files with the same options.
There are a couple of other minor behavior changes as a
result:
- print_usage() and print_help() no longer works before
the object has been called to parse options
- registration of duplicate short options are no longer
detected until the options are parsed
- the --config-file and --config-dir options aren't
registered until just before parsing the options since
the default set of config files can be specified at
that time
- find_file() can't be used until after the options have
been parsed, again because of the late registration
of --config-file and --config-dir
Finally, an unregister_opt() method is added to support
the re-registeration of the --config-file and --config-dir
options.
Change-Id: I650d8e299e92cbc5d10da47a7ce1b73ca8066bd0
|
|
|
|
|
|
|
| |
I noticed that pep8 wasn't running on the tests. This patch fixes that,
as well as a couple of pep8 errors in test_cfg.
Change-Id: I4429bfe6813a2e9394efb1753cbebbadb9f23833
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixes bug #998396
Both Nova and Keystone need to clear the overrides on their config
object between test runs. It's reasonable to expect the reset()
method would do this, so let's make it so.
Also add a clear() method with the old behaviour.
Change-Id: I192c5bb07e81f0fb844fa2fd429dc2e7133800de
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Implements blueprint cfg-auto-create-groups
Remove the restriction that groups must be explicitly created. Often
you only need a group to have a name (not e.g. a title or help string)
so we can easily just auto-create groups for that case.
Change-Id: I150ab3900e3aad0068b93487c8d396d21d26cfea
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
| |
Implements blueprint cfg-required-options
Add a 'required' flag to option schemas:
StrOpt('foo', required=True)
which causes a RequiredOptError exception to be raised if the
user fails to supply a value for the option on the CLI or in
a config file.
Change-Id: Ied7bb25f0c1582c4991d0f212f4871b9358b73fb
|