From 887f2c5814262c21c60f0a9e2fa33b9e668245a6 Mon Sep 17 00:00:00 2001 From: Ken'ichi Ohmichi Date: Thu, 23 Mar 2017 10:58:59 -0700 Subject: [PATCH] Separate config module config module contained not only processor's ones, but also dashboard's ones. So it is better to separate the module into accurate modules to avoid developers misunderstand another config module exists for the dashboard. Change-Id: Ib7b8a953907fb99182295f8c850481fe6331fb32 --- config-generator.conf | 1 + setup.cfg | 1 + stackalytics/dashboard/config.py | 43 ++++++++++++++++++++++++++++++++ stackalytics/dashboard/web.py | 5 ++-- stackalytics/processor/config.py | 23 +---------------- 5 files changed, 49 insertions(+), 24 deletions(-) create mode 100644 stackalytics/dashboard/config.py diff --git a/config-generator.conf b/config-generator.conf index bc5fa00e7..8e7f9cdf3 100644 --- a/config-generator.conf +++ b/config-generator.conf @@ -2,4 +2,5 @@ output_file = etc/stackalytics.conf wrap_width = 79 namespace = stackalytics.processor.config +namespace = stackalytics.dashboard.config namespace = oslo_log diff --git a/setup.cfg b/setup.cfg index 8f552211c..f8c72a2ff 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,4 +37,5 @@ console_scripts = oslo.config.opts = oslo_log = oslo_log._options:list_opts + stackalytics.dashboard.config = stackalytics.dashboard.config:list_opts stackalytics.processor.config = stackalytics.processor.config:list_opts diff --git a/stackalytics/dashboard/config.py b/stackalytics/dashboard/config.py new file mode 100644 index 000000000..3852c1153 --- /dev/null +++ b/stackalytics/dashboard/config.py @@ -0,0 +1,43 @@ +# Copyright (c) 2013 Mirantis 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 copy + +from oslo_config import cfg + + +DASHBOARD_OPTS = [ + cfg.StrOpt('listen-host', default='127.0.0.1', + help='The address dashboard listens on'), + cfg.IntOpt('listen-port', default=8080, + help='The port dashboard listens on'), + cfg.StrOpt('default-metric', default='marks', + help='Default metric'), + cfg.StrOpt('default-release', + help='Default release, the most recent if not set'), + cfg.StrOpt('default-project-type', default='openstack', + help='Default project type'), + cfg.IntOpt('dashboard-update-interval', default=3600, + help='The interval specifies how frequently dashboard should ' + 'check for updates in seconds'), + cfg.StrOpt('collect-profiler-stats', + help='Name of file to store python profiler data'), + cfg.IntOpt('age-warn', default=2 * 24 * 60 * 60, + help='Warn if the age of data is more than this value, sec'), +] + + +def list_opts(): + yield (None, copy.deepcopy(DASHBOARD_OPTS)) diff --git a/stackalytics/dashboard/web.py b/stackalytics/dashboard/web.py index 69de115c8..1f3e84a28 100644 --- a/stackalytics/dashboard/web.py +++ b/stackalytics/dashboard/web.py @@ -23,13 +23,14 @@ from oslo_config import cfg from oslo_log import log as logging import six +from stackalytics.dashboard import config from stackalytics.dashboard import decorators from stackalytics.dashboard import helpers from stackalytics.dashboard import kpi from stackalytics.dashboard import parameters from stackalytics.dashboard import reports from stackalytics.dashboard import vault -from stackalytics.processor import config +from stackalytics.processor import config as processor_cfg from stackalytics.processor import utils # Application objects --------- @@ -43,7 +44,7 @@ app.register_blueprint(kpi.blueprint) LOG = logging.getLogger(__name__) CONF = cfg.CONF -CONF.register_opts(config.CONNECTION_OPTS + config.DASHBOARD_OPTS) +CONF.register_opts(processor_cfg.CONNECTION_OPTS + config.DASHBOARD_OPTS) # Handlers --------- diff --git a/stackalytics/processor/config.py b/stackalytics/processor/config.py index 5ce661374..18e922554 100644 --- a/stackalytics/processor/config.py +++ b/stackalytics/processor/config.py @@ -62,27 +62,6 @@ PROCESSOR_OPTS = [ help='How many times to retry after Gerrit errors'), ] -DASHBOARD_OPTS = [ - cfg.StrOpt('listen-host', default='127.0.0.1', - help='The address dashboard listens on'), - cfg.IntOpt('listen-port', default=8080, - help='The port dashboard listens on'), - cfg.StrOpt('default-metric', default='marks', - help='Default metric'), - cfg.StrOpt('default-release', - help='Default release, the most recent if not set'), - cfg.StrOpt('default-project-type', default='openstack', - help='Default project type'), - cfg.IntOpt('dashboard-update-interval', default=3600, - help='The interval specifies how frequently dashboard should ' - 'check for updates in seconds'), - cfg.StrOpt('collect-profiler-stats', - help='Name of file to store python profiler data'), - cfg.IntOpt('age-warn', default=2 * 24 * 60 * 60, - help='Warn if the age of data is more than this value, sec'), -] - def list_opts(): - yield (None, copy.deepcopy(CONNECTION_OPTS + PROCESSOR_OPTS + - DASHBOARD_OPTS)) + yield (None, copy.deepcopy(CONNECTION_OPTS + PROCESSOR_OPTS))