summaryrefslogtreecommitdiff
path: root/oslo/config/cfg.py
Commit message (Collapse)AuthorAgeFilesLines
* Remove oslo namespace packageDoug Hellmann2015-07-131-13/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Move files out of the namespace packageDoug Hellmann2014-12-121-2459/+1
| | | | | | | | | | Move the public API out of oslo.config to oslo_config. Retain the ability to import from the old namespace package for backwards compatibility for this release cycle. bp/drop-namespace-packages Change-Id: I56274336802036de050efc62eb2ee6b5d4ede77b
* Fix wrong order of positional args in cliMike Fedosin2014-12-041-7/+30
| | | | | | | | | | | Positional arguments were incorrectly parsed because instead of original order there was an alphabetical. This patch brings a positional field in Opt class and then sorts all arguments by position-name. Change-Id: Ia22654442b895c3f62834428f0ec6c3e8af22ebb Closes-Bug: 1392428
* Merge "Add missing newline to stderr output when argument value is wrong"Jenkins2014-10-151-1/+1
|\
| * Add missing newline to stderr output when argument value is wrongChristian Berendt2014-08-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | For example when having an argument with possible choices and the used choice is not available the stderr output is like the following example. argument --formatting: Invalid String(choices=['check', 'fix']) value: fixaberendt@zitrone To have the shell prompt at the next line it necessary to at '\n' at the end of the stderr output. Change-Id: I99152e69bb090ea5d7102cc85d60498c3c6213eb
* | Merge "Fixed typo in docstring for _get_config_dirs"Jenkins2014-10-141-1/+1
|\ \
| * | Fixed typo in docstring for _get_config_dirsMiguel Grinberg2014-09-041-1/+1
| | | | | | | | | | | | | | | | | | | | | The docstring for function _get_config_dirs() refers to directories as "directors". Change-Id: Iede3934a9712de98dc1f39604d5dc210fbfc4672
* | | Merge "delay formatting debug log message"Jenkins2014-10-131-4/+5
|\ \ \
| * | | delay formatting debug log messageDoug Hellmann2014-10-081-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Pass arguments to the logger and let it assemble the formatted message if it will be emitted. Change-Id: I2cf66dcc98bb2324f34442e51e47691ec445d280
* | | | Merge "Check config default value is correct type"Jenkins2014-10-131-2/+23
|\ \ \ \ | |/ / /
| * | | Check config default value is correct typeTom Cammann2014-10-081-2/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Given a type of Opt, check that the default value supplied to the Opt is of the same type as the Opt. E.g. cfg.StrOpt('user_attribute_ignore', default=99) will log a warning as the default is not of type string. Closes-Bug: 1261792 Change-Id: I12cd5f4be82ac5ed0ebb348b358dd8eaf04e4e0d
* | | | Report permission denied when parsing configRyan Moore2014-10-081-2/+32
|/ / / | | | | | | | | | | | | | | | | | | | | | Previously was returning ConfigFilesNotFoundError, when underlying error was 13 - Permission Denied Change-Id: I2c418f023c510205aa12a3acb9b09e6b1681f0d4 Closes-Bug: #1071799
* | | Looks for variable subtitution in the same groupMehdi Abaakouk2014-09-101-8/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we do a variable subtitution we must try to look if the option is avialable into the same group and then into the default one for backward compatibilty. Otherwise variable subtitution doesn't works when we change the group of an option and deprecated the DEFAULT group. Change-Id: Ie5750ee028a58fba6da225a8c4b4221e23db829f Closes-bug: #1367790
* | | Explain groups for DeprecatedOptsFlavio Percoco2014-09-031-0/+12
| |/ |/| | | | | | | | | | | | | The patch extends the documentation for `DeprecatedOpt` and explains that group==None means the deprecated name will be looked up in the same group. Change-Id: I54ba414d6a6862e1b00dfbf589563ef9f4df5cf3
* | Log a fixed length string of asterisks for obfuscationZhongyue Luo2014-08-051-1/+1
|/ | | | | Change-Id: I98e95dbc92712bebb18dcf0d29af7cfe7f2c8124 Closes-bug: #1341774
* Replaced 'e.g.' with 'for example'Christian Berendt2014-07-071-13/+14
| | | | | | | According to the IBM Style Guide the Latin abbreviation 'e.g.' should be replaced by 'for example'. Change-Id: Ie85eec0f028a927a635303f7c13e76fe52a92ff5
* cfg,generator: add Opt.sample_default attributeMark McLoughlin2014-07-021-1/+5
| | | | | | | | | | | | | | | | | | | | | Some default values for configuration options are dynamic and environment dependent. For example, an option might default to the hostname of the machine. However, such default values should never end up in a sample configuration file - you don't want your hostname or path to your personal home directory to be included in sample config files. A simple solution to this is to add a 'sample_default' string attribute which is used in place of a default, for those cases where the real value is an unsuitable sample default. For example: cfg.StrOpt('hostname', default=get_my_host(), sample_default='myhostname') blueprint: oslo-config-generator Change-Id: I319d128a0a88b1197d8e2be105681f2b56240439
* Merge "Fix flaws in methods' docstring"Jenkins2014-06-301-2/+2
|\
| * Fix flaws in methods' docstringliu-sheng2014-06-301-2/+2
| | | | | | | | Change-Id: Idaebbc5702daeabc22b44672ce7b7d301a725871
* | Introduce Opts for IP addressesJakub Libosvar2014-06-301-0/+9
|/ | | | | | | | | | | | In order to validate correct input values for IP addresses new Opt was introduced. Validation is done on parsing level so there is no need to explicitly check for valid ip address in the code. Requirement for netaddr package was added. DocImpact Change-Id: I9adc30d9b989e8c636fefd435885c4c363ca540c Partial-Bug: #1284684
* Refactors _Namespace to make the code clearerDavid Stanek2014-06-271-9/+8
| | | | | | | | | | | | | The original implentation of _Namespace._get_cli_value relied on the fact that _Namespace.default doesn't exist and accessing it would raise an AttributeError. This attribute was being caught for another reason so the logic just worked. The more correct thing to do would have been to just raise a KeyError. This change does that and removes the need to catch an AttributeErrors. Change-Id: I963b31ea6ea8ab5180314be7cd2450395263e1af Closes-bug: #1284968
* Add warning about interpolating values from groupsDoug Hellmann2014-06-171-1/+10
| | | | | | | | | | | Add a warning explaining that options in groups cannot be used with the interpolation syntax. Reformat note to use directive so it is highlighted. Add "docs" section to tox.ini to make testing doc build easier. Change-Id: If5106aa44d4c87abe84a7fb7a250541bba9f5068
* Add a doc sample for how to use the required fieldMatthew Treinish2014-05-271-1/+7
| | | | | | | | This commit adds a sample to the developer documentation on setting an option as required. Previously there was no example and it just stated it could be done, which was a little confusing. Change-Id: I1eb96422fd4ac8a83a5ac9397905b58fa7d6c8e0
* log: string format arguments changed to function parametersChristian Berendt2014-05-201-4/+4
| | | | | | | | | There are files containing string format arguments inside logging messages. Using logging function parameters should be preferred. Change-Id: I22aebd928a96258c08fcaa363aed0f739825fc7e Partial-Bug: #1321274
* Fix deprecated_opts for cli optionsYAMAMOTO Takashi2014-05-071-10/+17
| | | | | | | | | | | | | | | | | | | | The following simple program raises DuplicateOptError. This commit fixes it. oslo.config.cfg.DuplicateOptError: duplicate option: argument --bar-foo: conflicting option string(s): --bar-foo from oslo.config import cfg conf = cfg.ConfigOpts() oldopts = [ cfg.DeprecatedOpt(name='oldfoo', group='oldbar'), ] conf.register_cli_opt(cfg.StrOpt(name='foo', deprecated_opts=oldopts), group='bar') conf() Change-Id: I022ed0236de97db42568106bc90c696732a05ef2 Closes-Bug: #1283960
* Merge "Add section titles and fix markup of docstring"Jenkins2014-05-061-2/+32
|\
| * Add section titles and fix markup of docstringDoug Hellmann2014-04-211-2/+32
| | | | | | | | | | | | | | | | | | | | Add section titles to the module docstring for cfg.py so http://docs.openstack.org/developer/oslo.config/cfg.html is broken up and easier to scan quickly. Fix a couple of minor markup issues at the same time. Change-Id: I03df6842b29e62de1b3c923218f174cf65fdefdb
* | Merge "Fix docstring for _Namespace._get_cli_value"Jenkins2014-05-051-1/+1
|\ \
| * | Fix docstring for _Namespace._get_cli_valueYAMAMOTO Takashi2014-02-261-1/+1
| | | | | | | | | | | | Change-Id: Idea5f7c57c5e35f6de74bc7f2caac0ea6db35f35
* | | Reject option names prefixed with '_'YAMAMOTO Takashi2014-05-021-0/+2
| |/ |/| | | | | | | | | | | Such names are used for _Namespace's internal purposes. Change-Id: I08c24f05ec3ef626b253ca3682439c1a162959e5 Related-Bug: #1284969
* | Avoid using too generic names in _NamespaceYAMAMOTO Takashi2014-04-151-15/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As _Namespace is used to hold key-values for user options, avoid using conflict-prone names for internal purposes. Namely, prefix ours with '_'. For example, consider the following. conf.register_cli_opt(cfg.BoolOpt('parser')) In this case, the option would get added to the namespace object as a "parser" attribute, which would conflict with the existing name in the object. Change-Id: Ibaf8408a118e07a8a598f87ac10a91312683df40 Closes-Bug: #1284969
* | Merge "Do substitution on overrides and defaults too"Jenkins2014-03-041-2/+2
|\ \
| * | Do substitution on overrides and defaults tooBen Nemec2014-02-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some of our consuming projects are setting defaults or overrides on config objects that look like $state_path/some/file and we're no longer handling that correctly since commit 2422d4118c97734067ea0b37ae159bc2e3c492c5 Change-Id: I4324bda6f3de3cdf05f8eb3cf16052c04018dec8 Closes-Bug: #1282250
* | | Merge "Follow style guide for help strings"Jenkins2014-03-041-11/+11
|\ \ \ | |/ / |/| |
| * | Follow style guide for help stringsAndreas Jaeger2014-02-271-11/+11
| |/ | | | | | | | | | | | | | | | | Improve help strings to follow the style guide: * Capitalize first word of each help string * Finish help strings with "." * Improve wording and follow usual capitalization Change-Id: Iecab34edd35175dcf1cccd4676e5cd91752549ad
* | Fix a whitespace in a commentYAMAMOTO Takashi2014-02-241-1/+1
|/ | | | Change-Id: I1044f278eb0159be56d4b7564e140180c8c8441a
* Merge "Fix docstring of parsing order"Jenkins2014-02-221-3/+3
|\
| * Fix docstring of parsing orderEric Guo2014-02-171-3/+3
| | | | | | | | | | | | | | | | | | There is wrong explaination of option parsing order in config files and on command line. That is only the later one takes action. The sample code shows only the later one takes action. See http://paste.openstack.org/show/64229/ Change-Id: I4d48df1b551bb130dc25fe32303fa2d0b1fecffd
* | Remove extraneous vim configuration commentsllg82122014-02-131-2/+0
|/ | | | | | | | | Remove line containing comment - # vim: tabstop=4 shiftwidth=4 softtabstop=4 Change-Id: I6e486876d5743bfbfb3a93c89f6da81c32d22ffd Closes-Bug:#1229324
* Merge "Fix misspellings in oslo.config"Jenkins2014-02-091-1/+1
|\
| * Fix misspellings in oslo.configShane Wang2014-02-081-1/+1
| | | | | | | | | | | | | | | | | | Fix misspellings detected by: * pip install misspellings * git ls-files | grep -v locale | misspellings -f - Change-Id: I96a3e5717cbce66c19ead15a9e491fe4a44f6e88 Closes-Bug: #1257295
* | Add docs for typesDoug Hellmann2014-01-311-7/+11
|/ | | | | | | | | | Add a page to pull in the docstrings for the option types, and make the docstring changes in the module necessary for that to work properly. Also fix a formatting issue in the docs for the cfg module. Change-Id: Ib1cf24e59ecc3592d3b703f99659f4a0fdbc7f5c
* Throw exception if --config-dir doesn't existJay S. Bryant2014-01-271-1/+17
| | | | | | | | | | | | | | | | | | | Currently an invalid --config-dir option is silently ignored. This means that a user could accidentally enter the wrong directory or have a typo which would cause the desired config files to not be used and no indication of the error would be produced. This change adds a ConfigDirNotFoundError exception that can be raised when the requested --config-dir isn't found. While working out the unit tests for this it was discovered that the test_config_dir_tilde test case was not correct. It could still pass when it should fail. This commit includes a fix for that issue as well. Closes-bug: 1255354 Change-Id: I386b2419d04572b14ccf11b527f871a237304e53
* Merge "Implemented support for custom opt types"Jenkins2014-01-221-193/+150
|\
| * Implemented support for custom opt typesMaxim Kulkin2014-01-161-193/+150
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Motivation: Currently oslo.config supports only basic set of types: strings, integers, floats, booleans, lists of strings and dictionaries of strings. The reason of existence of types other than string is to provide some kind of value validation (e.g. that integer contains only digits). There is a demand in community to have more complex value checks, e.g. that a port configuration option contains integer value that fits in certain range, host ip address conforms to ip address format, etc. Solution: This patch introduces support for custom Opt types that will allow a better control of value conversion and validation. Custom types are presented as type constructors - callable objects that take a string and either return converted value or raise ValueError in case value can't be converted. This concept is similar to argument types in 'argparse' library. Type constructor can be a class which instances are callable, a function or any callable object (which allows usage of parametriezed type class instances). Details: Oslo.config has Opt subclasses that control value conversion and validation: StrOpt, IntOpt, FloatOpt, etc. The type information is added to the base class - Opt - cause otherwise it would introduce confusion on what class to use when introducing e.g. NetworkPort: StrOpt or IntOpt. For each existing Opt subclass a corresponding type was implemented (see oslo.config.types). StrOpt, IntOpt, etc. classes are left for backward compatibility and present an Opt class parametrized with particular type. There are two exceptions of this rule: BoolOpt and MultiStrOpt. Those classes define a special logic for parsing values. BoolOpt was left unchanged and should be used when someone wants a Boolean option that is available through CLI. MultiStrOpt has logic to accumulate values. As it was bound to String type only, it's logic was extracted into a MultiOpt class and MultiStrOpt was left as a subclass parametrized with String type. Opt values allow value substitution. Previously it worked only for string types but now this feature only makes sense if it would work on any type. _substitute() and _do_get() methods of ConfigOpts class were updated to cover that. Also, TemplateSubstitution tests were updated to ensure that substitution is done before type conversion kicks in or otherwise type conversion will fail (e.g. if Integer type converted will get something like '$listen_port'). Advised review steps: 1. New type classes (oslo/config/types.py) and their tests (tests/test_types.py); 2. Changes to Str/Bool/Int/etc-Opt classes (those are pretty straight forward); 3. Other changes that add support for new types into existing infrastructure; 4. New cfg test cases added (mostly related to changes in substitution mechanics). blueprint oslo-config-options-validation Change-Id: I6910f1efa540cfe757b2be6da0aec072f8ed28fa
* | Merge "Fix for parsing error with Dollar Sign ($) in values"Jenkins2014-01-111-0/+5
|\ \
| * | Fix for parsing error with Dollar Sign ($) in valuesDavanum Srinivas2014-01-071-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Python String template uses '$$' as an escape when a '$' is required in the value. So add a test case to make sure that works. Many users end up trying a backslash to escape as well, let's add support and a test case for that as well DocImpact Change-Id: I403cc98505a95f633b5f29ba8f819a2e9c7d58a6 Closes-Bug: #1259729
* | | Fix spelling errors in docstrings and commentsskudriashev2013-12-221-4/+4
|/ / | | | | | | Change-Id: I20f133769b953fd3c0ab3d6904c9d7f773052214
* | Added support of operator '=='Lianhao Lu2013-12-191-0/+5
|/ | | | | | | Implemented method __eq__ for cfg.Opt. Change-Id: Ia6a3d82d19b7d239ffc0b42a47e1ce7383f10564 Partial-Bug: 1262148
* Fix to make ConfigOpts no longer obscure IOErrorsLars Butler2013-11-011-3/+6
| | | | | | | | | | | | | | This changes ConfigParser._parse_file such that it no longer interprets all IOErrors as 'No such file or directory', and instead allows these errors to propagate normally. The current behavior with respect to ConfigOpts does not change for IOErrors indicating 'No such file' or 'Permission denied'. Also added a test to exercise the case where IOErrors are reraised. The 'No such file' case is already covered by existing tests. Change-Id: I10e4e5965212737a19f4f17153143f62b5c0c83e Closes-Bug: #1244674