Generate configuration file in sdist

When building source tarball, generate the configuration file to include
it in the sources.

Change-Id: I81f4669bdf6a4fe51c247b129a1e69c13a657131
This commit is contained in:
Julien Danjou 2016-01-19 15:59:50 +01:00
parent dd1b7a4dca
commit bb424d349b
6 changed files with 32 additions and 17 deletions

1
MANIFEST.in Normal file
View File

@ -0,0 +1 @@
include etc/gnocchi/gnocchi.conf

View File

@ -2,21 +2,9 @@
Configuration
===============
Configure Gnocchi by editing `/etc/gnocchi/gnocchi.conf`.
No config file is provided with the source code, but one can be easily
created by running:
::
tox -e genconfig
This command will create an `etc/gnocchi/gnocchi.conf` file which can be used
as a base for the default configuration file at `/etc/gnocchi/gnocchi.conf`. If
you're using *devstack*, this file is already generated and put in place.
The configuration file should be pretty explicit, but here are some of the base
options you want to change and configure:
Configure Gnocchi by editing `/etc/gnocchi/gnocchi.conf`. The configuration
file should be pretty explicit, but here are some of the base options you want
to change and configure:
+---------------------+---------------------------------------------------+

21
gnocchi/genconfig.py Normal file
View File

@ -0,0 +1,21 @@
# -*- encoding: utf-8 -*-
#
# Copyright © 2016 Red Hat, Inc.
#
# 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.
from oslo_config import generator
def sdist_prehook(sdist):
generator.main(['--config-file',
'gnocchi-config-generator.conf'])

View File

@ -73,9 +73,14 @@ test =
setup-hooks =
pbr.hooks.setup_hook
[sdist]
pre-hook.build_config = gnocchi.genconfig.sdist_prehook
[files]
packages =
gnocchi
data_files =
etc/gnocchi = etc/gnocchi/*
[entry_points]
gnocchi.indexer.resources =

View File

@ -24,7 +24,7 @@ setenv =
commands =
doc8 --ignore-path doc/source/rest.rst doc/source
oslo-config-generator --config-file=etc/gnocchi/gnocchi-config-generator.conf
oslo-config-generator --config-file=gnocchi-config-generator.conf
{toxinidir}/run-tests.sh {posargs}
[testenv:bashate]
@ -64,7 +64,7 @@ show-source = true
[testenv:genconfig]
deps = .[mysql,postgresql,test,file,influxdb,ceph,swift]
commands = oslo-config-generator --config-file=etc/gnocchi/gnocchi-config-generator.conf
commands = oslo-config-generator --config-file=gnocchi-config-generator.conf
[testenv:docs]
# This does not work, see: https://bitbucket.org/hpk42/tox/issues/302