From 888be36d6959ea7e6ac216d1c3f435dcab153fd9 Mon Sep 17 00:00:00 2001 From: Pushkar Umaranikar Date: Sat, 30 Jan 2016 00:44:12 +0000 Subject: [PATCH] Config options: Centralize debugger options The config options of the "nova/debugger" got moved to the new central location "nova/conf/remote_debug.py" Implements: blueprint centralize-config-options-newton Change-Id: Ic0c858aac92c95dc20992c06218f9823e7e683e5 --- nova/conf/__init__.py | 3 +++ nova/conf/remote_debug.py | 46 +++++++++++++++++++++++++++++++++++++++ nova/config.py | 7 +++--- nova/debugger.py | 29 ++---------------------- 4 files changed, 54 insertions(+), 31 deletions(-) create mode 100644 nova/conf/remote_debug.py diff --git a/nova/conf/__init__.py b/nova/conf/__init__.py index 439429486c52..8fd5816d0dbe 100644 --- a/nova/conf/__init__.py +++ b/nova/conf/__init__.py @@ -60,6 +60,7 @@ from nova.conf import network # from nova.conf import osapi_v21 from nova.conf import pci from nova.conf import rdp +from nova.conf import remote_debug from nova.conf import scheduler # from nova.conf import security from nova.conf import serial_console @@ -136,3 +137,5 @@ wsgi.register_opts(CONF) xenserver.register_opts(CONF) # xvp.register_opts(CONF) # zookeeper.register_opts(CONF) + +remote_debug.register_cli_opts(CONF) diff --git a/nova/conf/remote_debug.py b/nova/conf/remote_debug.py new file mode 100644 index 000000000000..3c763e1769ad --- /dev/null +++ b/nova/conf/remote_debug.py @@ -0,0 +1,46 @@ +# Copyright (c) 2016 Intel, Inc. +# Copyright (c) 2013 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 + +debugger_group = cfg.OptGroup('remote_debug', + title='debugger options') + +host = cfg.StrOpt('host', + help='Debug host (IP or name) to connect. Note ' + 'that using the remote debug option changes how ' + 'Nova uses the eventlet library to support async IO. ' + 'This could result in failures that do not occur ' + 'under normal operation. Use at your own risk.') + +port = cfg.IntOpt('port', + min=1, + max=65535, + help='Debug port to connect. Note ' + 'that using the remote debug option changes how ' + 'Nova uses the eventlet library to support async IO. ' + 'This could result in failures that do not occur ' + 'under normal operation. Use at your own risk.') + +CLI_OPTS = [host, port] + + +def register_cli_opts(conf): + conf.register_cli_opts(CLI_OPTS, group=debugger_group) + + +def list_opts(): + return {debugger_group: CLI_OPTS} diff --git a/nova/config.py b/nova/config.py index ba544781bc22..bdefd09f3d9c 100644 --- a/nova/config.py +++ b/nova/config.py @@ -16,18 +16,18 @@ # under the License. from oslo_cache import core as cache -from oslo_config import cfg from oslo_db import options from oslo_log import log from nova.common import config +import nova.conf from nova.db.sqlalchemy import api as sqlalchemy_api -from nova import debugger from nova import paths from nova import rpc from nova import version -CONF = cfg.CONF + +CONF = nova.conf.CONF _DEFAULT_SQL_CONNECTION = 'sqlite:///' + paths.state_path_def('nova.sqlite') @@ -45,7 +45,6 @@ def parse_args(argv, default_config_files=None, configure_db=True, sqlite_db='nova.sqlite') rpc.set_defaults(control_exchange='nova') cache.configure(CONF) - debugger.register_cli_opts() config.set_middleware_defaults() CONF(argv[1:], diff --git a/nova/debugger.py b/nova/debugger.py index e4d42768f65c..de228f9555b6 100644 --- a/nova/debugger.py +++ b/nova/debugger.py @@ -26,34 +26,9 @@ def enabled(): '--remote_debug-port' in sys.argv) -def register_cli_opts(): - from oslo_config import cfg - - cli_opts = [ - cfg.StrOpt('host', - help='Debug host (IP or name) to connect. Note ' - 'that using the remote debug option changes how ' - 'Nova uses the eventlet library to support async IO. ' - 'This could result in failures that do not occur ' - 'under normal operation. Use at your own risk.'), - - cfg.IntOpt('port', - min=1, - max=65535, - help='Debug port to connect. Note ' - 'that using the remote debug option changes how ' - 'Nova uses the eventlet library to support async IO. ' - 'This could result in failures that do not occur ' - 'under normal operation. Use at your own risk.') - - ] - - cfg.CONF.register_cli_opts(cli_opts, 'remote_debug') - - def init(): - from oslo_config import cfg - CONF = cfg.CONF + import nova.conf + CONF = nova.conf.CONF # NOTE(markmc): gracefully handle the CLI options not being registered if 'remote_debug' not in CONF: