summaryrefslogtreecommitdiff
path: root/oslo_config
Commit message (Collapse)AuthorAgeFilesLines
* Make tests backward compat with cliff' older versions9.1.0Hervé Beraud2022-09-291-8/+8
| | | | | | | | Change the assertion kind to support all versions of cliff. The previous related fix 78098e6b18026ff9ef03a948b57348f02d42e13b was only compatible with cliff>3.4.0. Change-Id: I7ac27919b0d58929b4c975ebb308f33124a6060f
* Disable a config test if ran under the root userHervé Beraud2022-08-031-0/+3
| | | | | | | | | | | | | | | | The `test_conf_file_permission_denied` is designed to test if a config file can't be read due to missing file permissions. However if we run unit tests with the root user we will beneficiat from the root privileges and so this test will fails. This can be reproduced by running `tox` with `sudo`. These changes propose to skip this test if root privileges are detected. Closes-bug: #1983358 Change-Id: Idd124082265032c30f83242b612d002d7093aa61
* fix CLI mismatch in unit testsHervé Beraud2022-08-031-15/+14
| | | | | | | | | | | | Since cliff > 3.4.0 we can see mismatch errors with unit tests, this patch fix this error. Also this patch fix some issues with deprecation messages. All these issues needs to be fixed together to unlock our gates. Closes-bug: #1908934 Change-Id: I8396b4f3ba74a9ea023bff2e3027710f16a74af4
* Fix tests for Python3.Cyril Roelandt2021-08-191-2/+8
| | | | Change-Id: Ifbf6f52a312929ac07154db8eeee976b0ab0d46a
* Merge "config-generator yaml format doesn't work with i18n fields"xena-em8.7.1Zuul2021-06-021-0/+14
|\
| * config-generator yaml format doesn't work with i18n fieldsDavid Vallee Delisle2021-05-161-0/+14
| | | | | | | | | | | | | | | | | | | | | | This is because there's no yaml representer for i18n Messages object. This patch aims to add this representer and allow the generation of configurations using oslo.i18n strings. One example of this is cinder. Closes-bug: #1928582 Change-Id: I70ab87c9bed093cad883b6301b8a09753fc470d9
* | Merge "Ussuri+ is python3 only"Zuul2021-06-011-1/+1
|\ \ | |/ |/|
| * Ussuri+ is python3 onlydengzhaosen2021-05-051-1/+1
| | | | | | | | | | | | update python to python3 Change-Id: I83c8c9897678f8a0628987a071adda68062ac515
* | Merge "Add the version parameter."8.7.0Zuul2021-05-051-1/+1
|\ \ | |/ |/|
| * Add the version parameter.Daniel Bengtsson2021-05-041-1/+1
| | | | | | | | | | | | Call the parent with the version parameter. Change-Id: I20016e299077a7b678ecabceacb21cc0c7d306c8
* | Merge "Remove references to 'sys.version_info'"Zuul2021-05-041-6/+1
|\ \ | |/ |/|
| * Remove references to 'sys.version_info'dengzhaosen2021-04-251-6/+1
| | | | | | | | | | | | We support Python 3.6 as a minimum now, making these checks no-ops. Change-Id: I668c1bddba29a5e823734b1cad5116ba2fdb5f75
* | Merge "Adding the missing HostDomain config option"8.6.0Zuul2021-04-263-0/+56
|\ \ | |/ |/|
| * Adding the missing HostDomain config optionHervé Beraud2021-04-223-0/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ``HostDomain`` config type have been added few months ago [1] however the config option have been forgotten and this new type isn't importable. When we try to import this type without defining a new related cfg option we get the following issue: ``` AttributeError: module 'oslo_config.cfg' has no attribute 'HostDomain' ``` These changes allow us to import this new type and allow us to use it in our configs: ``` >>> from oslo_config import cfg >>> foo = cfg.HostDomain('foo') >>> foo.type.__call__("1") ... During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "~/oslo.config/oslo_config/types.py", line 893, in __call__ raise ValueError( ValueError: 1 is not a valid host address >>> foo.type.__call__("host_name") 'host_name' ``` Also properly initialize HostDomain because The HostDomain class wasn't calling super in it's __init__() method, which resulted in the type_name not being set properly for instances of that class. [1] https://opendev.org/openstack/oslo.config/commit/6480356928c9ae6169ea1e5a5b5f1df3d6e0dc75 Change-Id: Ie947803f61ba0ef080018e0447de894a400d7975 Closes-Bug: 1924283
* | Merge "tests: Add test for config file priority order"Zuul2021-04-211-6/+39
|\ \
| * | tests: Add test for config file priority orderStephen Finucane2021-04-141-6/+39
| |/ | | | | | | | | | | | | | | This was documented in the docstring but we had nothing to assert it in tests. Correct that gap. Change-Id: I4002e7fe18c43eb5f9ba2eae16022d7da87f790d Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* | remove unicode from codexuanyandong2021-04-162-5/+3
|/ | | | Change-Id: I062829a44a62014e88f285a82b6800e37f00ff28
* inherit from object is not required for py3Moisés Guimarães de Medeiros2021-01-128-14/+14
| | | | | Change-Id: I3f3b1dca78e2e9b2515231ccc6600b64f31039fb Signed-off-by: Moisés Guimarães de Medeiros <moguimar@redhat.com>
* Adding --check-defaults to validatorDavid Vallee Delisle2020-11-242-7/+141
| | | | | | | | | | | When troubleshooting, it's often interesting to see the deltas between the default or sample configs and the running configuration. The oslo_config.validator is a great tool to integrate this feature across all projects. It can also be easily captured by data collection tools like sosreports with the current deployment packages. Change-Id: I172d82f19a81282093b0d5f7ae4c1817801cd887 Signed-off-by: David Vallee Delisle <dvd@redhat.com>
* Merge "Add a new type HostDomain."Zuul2020-10-222-4/+67
|\
| * Add a new type HostDomain.Hervé Beraud2020-10-222-4/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | HostDomain is like HostAddress with the support of _ character - RFC1033 openstack services are failing to start when a hostname with underscore _ is provided. Example: ``` overcloud-novacompute_edge1-0.internalapi.localdomain overcloud-novacompute_edge1-0.internalapi ``` Nova use `HostAddressOpt` to define `live_migration_inbound_addr`, and if a hostname with underscore is present in the config file then the service fail to start. Example: ``` /etc/nova/nova.conf live_migration_inbound_addr = overcloud-novacompute_edge1-0.internalapi.localdomain ``` FQDN is a domain name that specifies its exact location in the tree hierarchy of the Domain Name System (DNS). Underscore are allowed by RFC1033 [1][2][3]. Indeed, while a hostname may not contain other characters, such as the underscore character (_), other DNS names may contain the underscore.[1][2]. Systems such as DomainKeys and service records use the underscore. These changes allow us to use underscore with the `HostDomain`. [1] https://www.ietf.org/rfc/rfc1912.txt [2] https://www.ietf.org/rfc/rfc1033.txt [3] http://domainkeys.sourceforge.net/underscore.html Co-authored-by: Daniel Bengtsson <dbengt@redhat.com> Change-Id: I0a0670207f96a987996d329e5efa9a5eb2ce000c Closes-Bug: #1892044
* | Merge "Convert rst to plaintext for oslo.config output"Zuul2020-10-121-3/+43
|\ \
| * | Convert rst to plaintext for oslo.config outputStephen Finucane2020-07-231-3/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This lets us use powerful rST roles and directives in our help text without these being emitted to the configuration file, where they don't read quite as well. It also fixes our formatting somewhat, which is nice. Note that we're doing something funky where we disable line wrapping. We can't totally disable this due to how rst2txt works, so instead we set the line length to an arbitrarily long line length, which is taken from RFC5322 (Internet Message Format) for want of something better. I personally question whether anyone is configuring this, but that's a fight for another day. Also note that this might caught issues for people who are using invalid rST in their docstrings or use roles/directives in their config options that aren't part of the standard Sphinx set or oslo.config set. They will already be seeing the former issues if they are using the 'sphinxext' extension though, and the latter sounds like it would be fairly rare. Change-Id: I6c7208f0facfb4f334d7440cb6a9562901543dd3 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* | | Merge "sphinxext: Add 'merge_domaindata'"Zuul2020-09-221-0/+9
|\ \ \
| * | | sphinxext: Add 'merge_domaindata'Stephen Finucane2020-09-101-0/+9
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is necessary to enable parallel builds. As noted in the Sphinx docs [1], this method has the following function: Merge in data regarding docnames from a different domaindata inventory (coming from a subprocess in parallel builds). Given how simple the datatypes we're storing are, this is pretty easy to implement. [1] https://www.sphinx-doc.org/en/master/extdev/domainapi.html#sphinx.domains.Domain.merge_domaindata Change-Id: I46c7903b159f99c68896a4c3c4d20daef848f9c2 Signed-off-by: Stephen Finucane <sfinucan@redhat.com> Closes-Bug: #1895162
* | | Adding pre-commitHervé Beraud2020-09-221-8/+8
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduced changes: - pre-commit config and rules - Add pre-commit to pep8 gate, Flake8 is covered in the pre-commit hooks. - Applying fixes for pre-commit compliance in all code. Also commit hash will be used instead of version tags in pre-commit to prevend arbitrary code from running in developer's machines. pre-commit will be used to: - trailing whitespace; - Replaces or checks mixed line ending (mixed-line-ending); - Forbid files which have a UTF-8 byte-order marker (check-byte-order-marker); - Checks that non-binary executables have a proper shebang (check-executables-have-shebangs); - Check for files that contain merge conflict strings (check-merge-conflict); - Check for debugger imports and py37+ breakpoint() calls in python source (debug-statements); - Attempts to load all yaml files to verify syntax (check-yaml); - Run flake8 checks (flake8) (local) For further details about tests please refer to: https://github.com/pre-commit/pre-commit-hooks Change-Id: I65a40bbff17d92b959764846801d5e0ddd3b97ce Signed-off-by: Moisés Guimarães de Medeiros <moguimar@redhat.com>
* | Fix unit tests to work with stevedore > 2.0.18.3.1yatinkarel2020-07-231-2/+2
|/ | | | | | | | | | | | | | stevedore has switched to importlib_metadata[1] and this breaked unit test as the test relied on internal implementation of it. Instead we should switch to mock NamedExtensionManager that's what called by oslo_config. [1] https://review.opendev.org/#/c/739306/ Closes-Bug: #1888208 Change-Id: Ic4b990a387d875a351c9f8e7eaaef726734ff305
* drop use of pkg_resources8.3.0Doug Hellmann2020-07-052-6/+17
| | | | | | | | | Importing pkg_resources scans all of the installed modules for data that won't be used. Switch to using importlib.metdata, which more efficiently loads the metadata for a package. Change-Id: Idd2a0d0026fef9296172c9995b428ea43a746483 Signed-off-by: Doug Hellmann <doug@doughellmann.com>
* Merge "generator: Handle 'cfg.Opt'-type options"Zuul2020-06-081-7/+4
|\
| * generator: Handle 'cfg.Opt'-type optionsStephen Finucane2020-05-271-7/+4
| | | | | | | | | | | | | | | | | | | | These are used when declaring an option with a custom type. There's no reason they shouldn't be handled and indeed they are albeit with an ugly warning. Resolve this by making this handling explicit. Change-Id: Ib7a6f26496cf19777b020c12998e953e9aae4601 Signed-off-by: Stephen Finucane <sfinucan@redhat.com> Closes-bug: #1880852
* | Merge "Raise hacking minimum to 3.0.1"Zuul2020-05-252-9/+9
|\ \
| * | Raise hacking minimum to 3.0.1Sean McGinnis2020-05-192-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | This raises hacking to a newer version, fixes a few issues the newer version uncovered, and removes the cap for flake8 to allow that version to be controlled by the hacking constraints. Change-Id: Ie550119322bca3c217e4a74eca789f156cfa7e2c Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
* | | Resolve UnboundLocalErrorStephen Finucane2020-05-013-4/+28
| |/ |/| | | | | | | | | | | | | | | | | | | As discussed in bug 1841038, configuring a StrOpt with a regex parameter and providing an invalid environment variable will result in an ugly stacktrace due to an undefined 'alt_loc' variable. Resolve this by creating said variable. Change-Id: Id0fb6efdc435a2bd88d5dfea2b4720df453fbfec Signed-off-by: Stephen Finucane <sfinucan@redhat.com> Closes-Bug: #1841038
* | Merge "Use unittest.mock instead of third party mock"Zuul2020-04-175-5/+7
|\ \
| * | Use unittest.mock instead of third party mockSean McGinnis2020-03-315-5/+7
| |/ | | | | | | | | | | | | | | Now that we no longer support py27, we can use the standard library unittest.mock module instead of the third party mock lib. Change-Id: I2f8067eeb2aec62f098bfbb3770a67f1876ce7a2 Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
* | Mark sphinx extensions thread safeSean McGinnis2020-04-142-0/+8
| | | | | | | | | | | | | | | | | | | | This adds the return of some metadata to our sphinx extension setup to indicate they are thread safe. This is needed to allow consuming projects to do multithreaded docs builds. In some cases, this can save a noticeable amount of time in job execution. Change-Id: I53a580b336a49372e27b69d009da555c03f03e35 Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
* | Remove redundant class docstring infoSean McGinnis2020-04-131-16/+0
|/ | | | | | | | | This now fails with the newest Sphinx due to multiple entries between the added reference to the class's docstrings, and the docstrings themselves. This fixes the warnings by just removing the duplication. Change-Id: I284a49a5df9506f936ebf1846688339c94d9a6b8 Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
* Switch to hacking 2.xStephen Finucane2020-02-122-2/+2
| | | | | | | | | | | | This bumps the version of flake8 and pycodestyle to something much newer, which resolves a long-standing warning about nested sets and allows us to use new fangled features like f-strings if we so choose. Note that this requires some minor modifications to keep the 'pep8' task passing. Change-Id: I3af8eb490345a6152372730ca3e0a6702bf482ea Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* Remove sixStephen Finucane2020-02-1211-88/+65
| | | | | | | | | We don't need this in a Python 3-only world. We can't remove mock yet since there's an issue with the stdlib variant in python3.6, but that is called out. Change-Id: I9657b1fd4409be90d645175a6e177d7e1d2ebac2 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* Merge "Support hyphens in positional argument names"7.0.0Zuul2019-12-202-16/+15
|\
| * Support hyphens in positional argument namesDolph Mathews2017-03-302-16/+15
| | | | | | | | | | | | | | | | | | | | | | Currently, when you specify a positional argument with a hyphen in the name, oslo.config is not able to retrieve a value back for that argument, even if one is parsed by argparse, because there's a mismatch between where oslo.config expects to find the value (in the dest, with underscores, which positional arguments do not have), versus where argparse puts it in the namespace (using the name, with hyphens). Change-Id: Ibc44a880ffddfaeffca682ccf3b34525f3f0fe27
* | Merge "Assume positional arguments are required"Zuul2019-12-202-27/+18
|\ \ | |/
| * Assume positional arguments are requiredDolph Mathews2017-03-302-27/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The 'positional' keyword specifically applies to oslo.config's argparse support. Unlike oslo.config, argparse assumes that all positional arguments are required by default, and you have to explicitly tell it that a positional argument is optional if you'd like to opt into that behavior. This patch adopts that same behavior for oslo.config. When you define an option to be non-positional (oslo.config's default, designed for config files), then oslo.config makes that option optional: However, when you define an option to be positional, oslo.config assumes that the option is primarily going to be used on the CLI and thus sets it as required, by default. This change in behavior has the side effect of allowing argparse to enforce required arguments on the CLI *while* parsing arguments, instead of depending on oslo.config to detect the condition *after* argparse has been allowed to parse "invalid" arguments. argparse correctly raises a SystemExit in this case, and prints the actual command usage and a "hey, you forgot this required argument", instead of allowing oslo.config to dump a backtrace to the CLI with a context-less error message ("context-less" in that no useful CLI usage information is dumped along with the crash to help you correct the condition). Change-Id: Ifdc6918444fe72f7e1649483c237cce64b4c72d8 Partial-Bug: 1676989
* | Merge "Refactor unit tests for CLI usage"Zuul2019-12-201-8/+34
|\ \ | |/
| * Refactor unit tests for CLI usageDolph Mathews2017-03-301-8/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this change, CLI usage was hardcoded into the config opt fixture used for all tests. That CLI usage described two required positional arguments that were not actually part of the argument parser (FOO and BAR), but were instead just made up to have a valid-looking usage description. The trouble is that you can't then extend that argument parser with additional real arguments, and then test the configuration of those arguments by inspecting the *real* usage and --help output from argparse. For example, a unit test could not assert whether argparse was configured correctly by oslo.config, because there's simply no way to know when the usage was just statically set to the arbitrary values of "FOO BAR." This patch moves that specific unit test coverage (overriding usage with something arbitrary) into a dedicated unit test, while removing the arbitrary usage from all other unit tests. Instead, those unit tests now make assertions against the argparser's real configuration, hence options like --config-dir and --config-file now appear in those tests, because those options are included in every instance of cfg.ConfigOpts(). Change-Id: I54ba989768d074a5f24897299c85bd35fa1cbd1a Related-Bug: 1676989
* | Merge "Remove ConfigFilter"Zuul2019-12-202-752/+0
|\ \ | |/ |/|
| * Remove ConfigFilterBen Nemec2019-12-172-752/+0
| | | | | | | | | | | | | | Per the deprecation in change I04baae695a7ba0bb93c91ea642c4e33c04bf87bd this can be removed. Change-Id: I31156e2f47b0d68ea32726cde7f0c2b133022c9f
* | Ensure option groups don't change during loggingStephen Finucane2019-12-131-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | oslo.config allows us to configure groups and options dynamically. This can cause a race with our logging as we attempt to iterate through option groups that are changing under our feet. This wouldn't be a huge issue, since these are just logs are we can always log again, if needed, but we store groups in a dictionary and Python doesn't like us changing the size of a dict it's iterating through: RuntimeError: dictionary changed size during iteration Given that we're only reading through this option group and don't need to worry about a group _disappearing_, the solution is pretty simple: create a copy of our option group names ahead of time so we don't need to worry about new ones coming and messing things up. No tests are included since this is a race and the only way I see to reproduce this would involve lots of ugly threading. Change-Id: Id3b28465d645a24f0fcebff2dd68a9bd30e21594 Signed-off-by: Stephen Finucane <sfinucan@redhat.com> Closes-Bug: #1856312
* fix: fix float opt min and max value format errrorhuang.xiangdong2019-11-041-2/+2
| | | | | | | | "%d" will truncate float and generates wrong format message, use "format" to handle floats correctly. Closes-Bug: 1850879 Change-Id: If0dd3933695ac84f0e9cacefd28a9d7a60dd88d7
* Improve removing quotes logicAndrii Ostapenko2019-08-122-1/+6
| | | | | | Cover case when sting consists of one quote only. Change-Id: I1fed30f6e365e18d3e3ec11d436a432b08c6c344