diff --git a/etc/aodh/aodh-config-generator.conf b/aodh/aodh-config-generator.conf similarity index 100% rename from etc/aodh/aodh-config-generator.conf rename to aodh/aodh-config-generator.conf diff --git a/aodh/cmd/__init__.py b/aodh/cmd/__init__.py index e69de29bb..a0817c171 100644 --- a/aodh/cmd/__init__.py +++ b/aodh/cmd/__init__.py @@ -0,0 +1,28 @@ +# -*- encoding: utf-8 -*- +# +# Copyright 2017 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. +import os + + +def config_generator(): + args = ['--output-file', 'etc/aodh/aodh.conf'] + try: + from oslo_config import generator + generator.main( + ['--config-file', + '%s/aodh-config-generator.conf' % os.path.dirname(__file__)] + + args) + except Exception as e: + print("Unable to build sample configuration file: %s" % e) diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 1ef37d27d..c145e8521 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -169,8 +169,6 @@ function configure_aodh { setup_colorized_logging $AODH_CONF DEFAULT fi - cp $AODH_DIR/etc/aodh/aodh-config-generator.conf $AODH_CONF_DIR - # The alarm evaluator needs these options to call gnocchi/ceilometer APIs iniset $AODH_CONF service_credentials auth_type password iniset $AODH_CONF service_credentials username aodh diff --git a/doc/source/conf.py b/doc/source/conf.py index 6301a15e1..c7e644f1f 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -51,7 +51,8 @@ extensions = [ 'oslo_config.sphinxconfiggen', ] -config_generator_config_file = os.path.join(ROOT, 'etc/aodh/aodh-config-generator.conf') +config_generator_config_file = os.path.join(ROOT, + 'aodh/aodh-config-generator.conf') sample_config_basename = '_static/aodh' wsme_protocols = ['restjson', 'restxml'] diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index 585bde91f..cad5ae00f 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -27,8 +27,7 @@ No config file is provided with the source code, it will be created during the installation. In case where no configuration file was installed, one can be easily created by running:: - oslo-config-generator --config-file=/etc/aodh/aodh-config-generator.conf \ - --output-file=/etc/aodh/aodh.conf + aodh-config-generator The following is a sample Aodh configuration for adaptation and use. It is auto-generated from Aodh when this documentation is built, and can also be diff --git a/setup.cfg b/setup.cfg index 4916b245e..92d41d27c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -27,8 +27,6 @@ setup-hooks = [files] packages = aodh -data_files = - etc/aodh = etc/aodh/* [extras] mysql = @@ -111,6 +109,7 @@ console_scripts = aodh-evaluator = aodh.cmd.alarm:evaluator aodh-notifier = aodh.cmd.alarm:notifier aodh-listener = aodh.cmd.alarm:listener + aodh-config-generator = aodh.cmd:config_generator oslo.config.opts = aodh = aodh.opts:list_opts diff --git a/tox.ini b/tox.ini index b6ef5cd0c..bb3d2799b 100644 --- a/tox.ini +++ b/tox.ini @@ -22,7 +22,7 @@ deps = .[test,{env:AODH_TEST_DEPS}] passenv = OS_TEST_TIMEOUT OS_STDOUT_CAPTURE OS_STDERR_CAPTURE OS_LOG_CAPTURE AODH_TEST_DRIVERS commands = {toxinidir}/run-tests.sh --black-regex '^aodh\.tests\.tempest\..*$' {posargs} - oslo-config-generator --config-file=etc/aodh/aodh-config-generator.conf + aodh-config-generator [testenv:functional] deps = .[mysql,postgresql,test] @@ -54,7 +54,7 @@ deps = .[doc] commands = sphinx-build -a -E -W -d install-guide/build/doctrees -b html install-guide/source install-guide/build/html [testenv:genconfig] -commands = oslo-config-generator --config-file=etc/aodh/aodh-config-generator.conf +commands = aodh-config-generator [testenv:docs] deps = .[test,doc]