From 112249eab00037c7b699b20cc41b5b2a0238e302 Mon Sep 17 00:00:00 2001 From: jichenjc Date: Sat, 23 Apr 2016 21:59:59 +0800 Subject: [PATCH] Support genconfig file Currently the configuration are in driver.py, but not automatically generated during build phase. This patch enables 'tox -egenconfig' to build a sample conf file and put into etc/nova-zvm.conf.sample, so if we need, we can paste those info into nova.conf.sample when we do further build. Follow up patches need to adjust the words in driver.py so the auto generated conf.sample will be more helpful to user. Change-Id: Ic35ecc8331c03bfe22e3077a8387ddfc1c8fb3d0 --- etc/nova-zvm-oslo-conf-generator.conf | 4 ++++ nova/virt/zvm/opts.py | 30 +++++++++++++++++++++++++++ setup.cfg | 4 ++++ tox.ini | 4 ++++ 4 files changed, 42 insertions(+) create mode 100644 etc/nova-zvm-oslo-conf-generator.conf create mode 100644 nova/virt/zvm/opts.py diff --git a/etc/nova-zvm-oslo-conf-generator.conf b/etc/nova-zvm-oslo-conf-generator.conf new file mode 100644 index 0000000..c58b8ea --- /dev/null +++ b/etc/nova-zvm-oslo-conf-generator.conf @@ -0,0 +1,4 @@ +[DEFAULT] +output_file = etc/nova-zvm.conf.sample +wrap_width = 79 +namespace = nova.virt.zvm diff --git a/nova/virt/zvm/opts.py b/nova/virt/zvm/opts.py new file mode 100644 index 0000000..358a3ad --- /dev/null +++ b/nova/virt/zvm/opts.py @@ -0,0 +1,30 @@ +# Copyright 2016 IBM Corp. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import itertools + +import nova.virt.zvm.driver + + +def list_opts(): + return [ + # Actually it should be [zvm], but for backward compatible issue, + # we keep this into DEFAULT. + ('DEFAULT', + itertools.chain( + nova.virt.zvm.driver.zvm_image_opts, + nova.virt.zvm.driver.zvm_opts, + nova.virt.zvm.driver.zvm_user_opts, + )), + ] diff --git a/setup.cfg b/setup.cfg index aeb75cf..37eaa91 100644 --- a/setup.cfg +++ b/setup.cfg @@ -41,3 +41,7 @@ input_file = nova_zvm/locale/nova-zvm.pot keywords = _ gettext ngettext l_ lazy_gettext mapping_file = babel.cfg output_file = nova_zvm/locale/nova-zvm.pot + +[entry_points] +oslo.config.opts = + nova.virt.zvm = nova.virt.zvm.opts:list_opts diff --git a/tox.ini b/tox.ini index e013c17..06e06e9 100644 --- a/tox.ini +++ b/tox.ini @@ -41,3 +41,7 @@ commands = pip-missing-reqs -d --ignore-file=nova/tests/* nova [testenv:bandit] deps = bandit commands = bandit -c bandit.yaml -r nova/virt/zvm -n 5 -ll + +[testenv:genconfig] +commands = /bin/cp -r {toxinidir}/nova/virt/zvm/ {toxinidir}/.tox/genconfig/src/nova/nova/virt/ + oslo-config-generator --config-file=etc/nova-zvm-oslo-conf-generator.conf