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
This commit is contained in:
jichenjc 2016-04-23 21:59:59 +08:00
parent 0b5e815418
commit 112249eab0
4 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,4 @@
[DEFAULT]
output_file = etc/nova-zvm.conf.sample
wrap_width = 79
namespace = nova.virt.zvm

30
nova/virt/zvm/opts.py Normal file
View File

@ -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,
)),
]

View File

@ -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

View File

@ -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