config options: centralize exception options

The config option to change the behavior of the exceptions got moved to
the new central location "nova/conf/exceptions.py".

A follow up change will improve the help text.

bp centralize-config-options-newton

Change-Id: I7fc24ad07da2b9e0a979ac23ad13fa28a700aaff
This commit is contained in:
Markus Zoeller 2016-05-09 15:03:33 +02:00
parent 1fe2508682
commit a31505fd62
4 changed files with 34 additions and 9 deletions

View File

@ -40,6 +40,7 @@ from nova.conf import crypto
from nova.conf import database from nova.conf import database
# from nova.conf import disk # from nova.conf import disk
from nova.conf import ephemeral_storage from nova.conf import ephemeral_storage
from nova.conf import exceptions
from nova.conf import flavors from nova.conf import flavors
from nova.conf import floating_ips from nova.conf import floating_ips
from nova.conf import glance from nova.conf import glance
@ -114,6 +115,7 @@ crypto.register_opts(CONF)
database.register_opts(CONF) database.register_opts(CONF)
# disk.register_opts(CONF) # disk.register_opts(CONF)
ephemeral_storage.register_opts(CONF) ephemeral_storage.register_opts(CONF)
exceptions.register_opts(CONF)
floating_ips.register_opts(CONF) floating_ips.register_opts(CONF)
flavors.register_opts(CONF) flavors.register_opts(CONF)
glance.register_opts(CONF) glance.register_opts(CONF)

30
nova/conf/exceptions.py Normal file
View File

@ -0,0 +1,30 @@
# Copyright 2016 OpenStack Foundation
# All Rights Reserved.
#
# 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}

View File

@ -26,26 +26,20 @@ import functools
import inspect import inspect
import sys import sys
from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import excutils from oslo_utils import excutils
import six import six
import webob.exc import webob.exc
from webob import util as woutil from webob import util as woutil
import nova.conf
from nova.i18n import _, _LE from nova.i18n import _, _LE
from nova import safe_utils from nova import safe_utils
LOG = logging.getLogger(__name__) 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 = nova.conf.CONF
CONF.register_opts(exc_log_opts)
class ConvertedException(webob.exc.WSGIHTTPException): class ConvertedException(webob.exc.WSGIHTTPException):

View File

@ -30,7 +30,6 @@ def list_opts():
return [ return [
('DEFAULT', ('DEFAULT',
itertools.chain( itertools.chain(
nova.exception.exc_log_opts,
nova.volume._volume_opts, nova.volume._volume_opts,
)), )),
] ]