From 8f82f0a442c39c0a70a17644ffa677a9f70b2b74 Mon Sep 17 00:00:00 2001 From: Andreas Scheuring Date: Thu, 26 Jan 2017 09:05:21 +0100 Subject: [PATCH] Enable configfile autogeneration This patch enables configfile autogeneration. It is triggered * implicitly on every sphinx build output dir: doc/source/html/_static/nova_dpm.conf.sample for doc inclusion * explicilty by tox -egenconfig output dir: etc/nova/nova_dpm.conf.sample * explicitly by tox -edocs output dir: etc/nova/nova_dpm.conf.sample In addition the return type of nova_dpm.conf.dpm.list_opts needed to be changed to the default format (list of tuples). Change-Id: Ib298b274f877d651dd846cac6525789c458da407 Closes-Bug: #1657701 --- .gitignore | 4 ++++ doc/source/conf.py | 7 ++++++- doc/source/index.rst | 1 + doc/source/sample_config.rst | 12 ++++++++++++ etc/nova/nova-dpm-config-generator.conf | 4 ++++ nova_dpm/conf/dpm.py | 2 +- setup.cfg | 3 +++ tox.ini | 8 +++++++- 8 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 doc/source/sample_config.rst create mode 100644 etc/nova/nova-dpm-config-generator.conf diff --git a/.gitignore b/.gitignore index 6bbe7d3..36c997b 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,7 @@ ChangeLog # Files created by releasenotes build releasenotes/build + +# Ignore autogenerated config files +etc/nova/nova_dpm.conf.sample +doc/source/_static/nova_dpm.conf.sample diff --git a/doc/source/conf.py b/doc/source/conf.py index 7655ee4..be06c7b 100755 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -26,9 +26,14 @@ extensions = [ 'sphinx.ext.autodoc', #'sphinx.ext.intersphinx', 'sphinxcontrib.seqdiag', - 'oslosphinx' + 'oslosphinx', + 'oslo_config.sphinxconfiggen' + ] +config_generator_config_file = '../../etc/nova/nova-dpm-config-generator.conf' +sample_config_basename = '_static/nova_dpm' + # autodoc generation is a bit aggressive and a nuisance when doing heavy # text edit cycles. # execute "export SPHINX_DEBUG=1" in your terminal to disable diff --git a/doc/source/index.rst b/doc/source/index.rst index 1ed20f8..9900215 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -52,6 +52,7 @@ Contents: installation usage contributing + sample_config Specifications ============== diff --git a/doc/source/sample_config.rst b/doc/source/sample_config.rst new file mode 100644 index 0000000..8915288 --- /dev/null +++ b/doc/source/sample_config.rst @@ -0,0 +1,12 @@ +============================== +Nova-dpm Configuration Options +============================== + +The following is a sample Nova-dpm configuration for adaptation and use. +It is auto-generated from Nova-dpm when this documentation is built, so +if you are having issues with an option, please compare your version of +Nova-dpm with the version of this documentation. + +The sample configuration can also be viewed in `file form <_static/nova_dpm.conf.sample>`_. + +.. literalinclude:: _static/nova_dpm.conf.sample diff --git a/etc/nova/nova-dpm-config-generator.conf b/etc/nova/nova-dpm-config-generator.conf new file mode 100644 index 0000000..a571adf --- /dev/null +++ b/etc/nova/nova-dpm-config-generator.conf @@ -0,0 +1,4 @@ +[DEFAULT] +output_file = etc/nova/nova_dpm.conf.sample +wrap_width = 80 +namespace = nova_dpm diff --git a/nova_dpm/conf/dpm.py b/nova_dpm/conf/dpm.py index e9f9c32..2240866 100644 --- a/nova_dpm/conf/dpm.py +++ b/nova_dpm/conf/dpm.py @@ -59,4 +59,4 @@ def register_opts(conf): def list_opts(): - return {dpm_group: ALL_DPM_OPTS} + return [(dpm_group, ALL_DPM_OPTS)] diff --git a/setup.cfg b/setup.cfg index 13d38d4..08cd661 100644 --- a/setup.cfg +++ b/setup.cfg @@ -52,3 +52,6 @@ all_files = 1 build-dir = releasenotes/build source-dir = releasenotes/source +[entry_points] +oslo.config.opts = + nova_dpm = nova_dpm.conf.dpm:list_opts diff --git a/tox.ini b/tox.ini index 4ef96ad..69110ae 100644 --- a/tox.ini +++ b/tox.ini @@ -4,6 +4,7 @@ envlist = py35,py34,py27,pep8 skipsdist = True [testenv] +usedevelop = True # NOTE(markus_z): We need the commands keyword, otherwise tox 2.5.0 throws an error. # See https://bugs.launchpad.net/charm-aodh/+bug/1642981 and # https://github.com/tox-dev/tox/issues/316 @@ -29,7 +30,9 @@ commands = coverage report [testenv:docs] -commands = python setup.py build_sphinx +commands = + python setup.py build_sphinx + oslo-config-generator --config-file=etc/nova/nova-dpm-config-generator.conf [testenv:debug] commands = oslo_debug_helper {posargs} @@ -41,3 +44,6 @@ show-source = True ignore = E123,E125 builtins = _ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,.tmp + +[testenv:genconfig] +commands = oslo-config-generator --config-file=etc/nova/nova-dpm-config-generator.conf \ No newline at end of file