| 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
|
|
|
|
|
|
|
|
| |
explicitly sort options when adding them to argparse.
it's a bit silly to print them in a dict iteration order.
Change-Id: Id508331d7ee3b24e76be7fa958d27d29905bd3d2
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
|
|
|
|
|
|
|
|
|
| |
Created import_group method in cfg.py
Added testcases
Fixes bug #1107843
Change-Id: I427d4069dacbb6e586687370adbb08b5d50f7b63
|
|
|
|
|
|
|
|
| |
Replaced "not ... is" to "is not"
Replaced "not ... in" to "not in"
Removed a redundant parenthesis
Change-Id: I9564ab1207ccdcb32d7c2bb9e8f29658b2232ff9
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Use 'nosetests --with-doctests' to run any doctests found. We currently
only use doctests in a handful of places, but we may as well run them
to ensure they work.
Make the cfg doctests avoid using the global CONF since we would need
to reset its state between each doctest.
Fix the cliutils doctests to actually pass.
Use 'nosetests --exclude-dir=tests/testmods' to avoid loading the
modules from this dir while discovering doctests. The cfg unit tests
rely on these modules not having been previously loaded.
Change-Id: I19ad70767fa5c8352b994dc963b5d3a7c9d9eb95
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixes LP #989269
Currently setting --verbose in will still allow DEBUG level
message to be logged to python logger object. we need to check
for --debug first (set DEBUG level), then --verbose (set INFO
level) and if neither is set then set default to WARNING
DocImpact
Change-Id: Ic9e3cb5979b2d7283552ad3a461870373f45a239
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|\ \ \
| |/ /
|/| | |
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
|
|
|
|
|
|
|
|
|
| |
* adding openstack theming (copied from keystone project theme)
* updating .gitignore to ignore generated API docs
* updated formatting in index.rst page
* updaed openstack/common/processutils.py to match hacking docstring
* updated docstrings to resolve sphinx warnings
Change-Id: Ie89afe20eeab1efd2daf440fc65ccdf90f723c51
|
|
|
|
|
|
|
| |
This is a private implementation detail of argparse, so we don't want
to rely on it. Just sub-class Action instead.
Change-Id: Icfcc782cc334d1bc1d4940bec23af48ead692a9d
|
|
|
|
|
|
| |
Use the same style of exception handling used everywhere else.
Change-Id: I5436de1996f69ea6210f48c11ef231eb950ad21d
|
|
|
|
|
|
| |
This sub-class of ArgumentParser isn't really justified anymore.
Change-Id: I705224b6e18e4609a8e2deba283767233b0bd578
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
argparse just has an add_argument() method, so there's no reason for us
to keep add_option() around.
Change-Id: I6f4be089ceaf0fd8c4c99565af392b445916172e
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
Change-Id: I1f75c7da1ab1543637198ecbb80a81b39ad35fde
|
|
|
|
|
|
|
|
|
| |
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>
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| | |
Remove the need for an internal NoneValue class by making the existence
of the 'default' or 'override' keys signify whether a default or
override is set.
Change-Id: Iacf49553df5ba8414307904a3ee334c7b8c55758
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
|
|
|
|
|
| |
with with -> with
Change-Id: I7a524c024b05639ec7ab4d57b6a52f70a95d2235
|
|
|
|
|
|
| |
bug 1014216
Change-Id: I3f8fa2e11c9d3f3d34fb20f65ce886bb9c94463d
|