From 9e4bf718daad32f66e2f084bc3fb3f17c640166d Mon Sep 17 00:00:00 2001 From: Prudhvi Rao Shedimbi Date: Tue, 29 Nov 2016 22:21:53 +0000 Subject: [PATCH] Implemented exception config module Implemented exception config module Partially Implements: blueprint centralise-config-opts Change-Id: Ic1b94e28a960a7306f15afbf69382edc15b5999e --- watcher/common/exception.py | 12 +++--------- watcher/conf/__init__.py | 2 ++ watcher/conf/_opts.py | 2 +- watcher/conf/exception.py | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 watcher/conf/exception.py diff --git a/watcher/common/exception.py b/watcher/common/exception.py index 00e5fdb27..75892d244 100644 --- a/watcher/common/exception.py +++ b/watcher/common/exception.py @@ -26,22 +26,16 @@ import functools import sys from keystoneclient import exceptions as keystone_exceptions -from oslo_config import cfg from oslo_log import log as logging import six from watcher._i18n import _, _LE +from watcher import conf + LOG = logging.getLogger(__name__) -EXC_LOG_OPTS = [ - cfg.BoolOpt('fatal_exception_format_errors', - default=False, - help='Make exception message format errors fatal.'), -] - -CONF = cfg.CONF -CONF.register_opts(EXC_LOG_OPTS) +CONF = conf.CONF def wrap_keystone_exception(func): diff --git a/watcher/conf/__init__.py b/watcher/conf/__init__.py index 551c8ec65..3535d9516 100644 --- a/watcher/conf/__init__.py +++ b/watcher/conf/__init__.py @@ -20,6 +20,7 @@ from oslo_config import cfg from watcher.conf import api +from watcher.conf import exception from watcher.conf import paths from watcher.conf import service from watcher.conf import utils @@ -30,3 +31,4 @@ service.register_opts(CONF) api.register_opts(CONF) utils.register_opts(CONF) paths.register_opts(CONF) +exception.register_opts(CONF) diff --git a/watcher/conf/_opts.py b/watcher/conf/_opts.py index 688aca35b..4765daf36 100644 --- a/watcher/conf/_opts.py +++ b/watcher/conf/_opts.py @@ -20,8 +20,8 @@ from keystoneauth1 import loading as ka_loading from watcher.applier import manager as applier_manager from watcher.common import clients -from watcher.common import exception from watcher.conf import api as conf_api +from watcher.conf import exception from watcher.conf import paths from watcher.conf import utils from watcher.db.sqlalchemy import models diff --git a/watcher/conf/exception.py b/watcher/conf/exception.py new file mode 100644 index 000000000..3d9f67d9c --- /dev/null +++ b/watcher/conf/exception.py @@ -0,0 +1,33 @@ +# -*- encoding: utf-8 -*- +# Copyright (c) 2016 Intel Corp +# +# Authors: Prudhvi Rao Shedimbi +# +# 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 cfg + +EXC_LOG_OPTS = [ + cfg.BoolOpt('fatal_exception_format_errors', + default=False, + help='Make exception message format errors fatal.'), +] + + +def register_opts(conf): + conf.register_opts(EXC_LOG_OPTS) + + +def list_opts(): + return [('DEFAULT', EXC_LOG_OPTS)]