config options: centralize section "serial_console"
The config options of the "nova.conf" section "serial_console" got moved to the new central location "nova/conf/serial_console.py". The way the centralization is done establishes a directed non-cyclic dependency: functional-module (e.g. virt.libvirt.driver.py) => nova.conf.__init__.py => section_module (e.g. nova.conf.serial_console.py) Which makes me believe that the "import_opt" calls are not necessary to ensure that the proper module gets imported under the cover. That's why I removed these "import_opt" calls. bp centralize-config-options A subsequent patch will then improve the help texts. bp centralize-config-options Change-Id: I597f427455e976892f60262cc823be3946c83e88
This commit is contained in:
parent
201090b0bc
commit
c55edcf0e1
@ -19,25 +19,14 @@ Based on nova-novncproxy.
|
||||
"""
|
||||
import sys
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from nova.cmd import baseproxy
|
||||
import nova.conf
|
||||
from nova.conf import serial_console as serial
|
||||
from nova import config
|
||||
|
||||
|
||||
opts = [
|
||||
cfg.StrOpt('serialproxy_host',
|
||||
default='0.0.0.0',
|
||||
help='Host on which to listen for incoming requests'),
|
||||
cfg.IntOpt('serialproxy_port',
|
||||
default=6083,
|
||||
min=1,
|
||||
max=65535,
|
||||
help='Port on which to listen for incoming requests'),
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_cli_opts(opts, group="serial_console")
|
||||
CONF = nova.conf.CONF
|
||||
serial.register_cli_opts(CONF)
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -65,6 +65,7 @@ from nova.compute import task_states
|
||||
from nova.compute import utils as compute_utils
|
||||
from nova.compute import vm_states
|
||||
from nova import conductor
|
||||
import nova.conf
|
||||
from nova import consoleauth
|
||||
import nova.context
|
||||
from nova import exception
|
||||
@ -249,7 +250,7 @@ instance_cleaning_opts = [
|
||||
'files.'),
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF = nova.conf.CONF
|
||||
CONF.register_opts(compute_opts)
|
||||
CONF.register_opts(interval_opts)
|
||||
CONF.register_opts(timeout_opts)
|
||||
@ -265,8 +266,6 @@ CONF.import_opt('enabled', 'nova.rdp', group='rdp')
|
||||
CONF.import_opt('html5_proxy_base_url', 'nova.rdp', group='rdp')
|
||||
CONF.import_opt('enabled', 'nova.mks', group='mks')
|
||||
CONF.import_opt('mksproxy_base_url', 'nova.mks', group='mks')
|
||||
CONF.import_opt('enabled', 'nova.console.serial', group='serial_console')
|
||||
CONF.import_opt('base_url', 'nova.console.serial', group='serial_console')
|
||||
CONF.import_opt('destroy_after_evacuate', 'nova.utils', group='workarounds')
|
||||
CONF.import_opt('scheduler_tracks_instance_changes',
|
||||
'nova.scheduler.host_manager')
|
||||
|
26
nova/conf/__init__.py
Normal file
26
nova/conf/__init__.py
Normal file
@ -0,0 +1,26 @@
|
||||
# Copyright 2015 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.
|
||||
|
||||
# This package got introduced during the Mitaka cycle in 2015 to
|
||||
# have a central place where the config options of Nova can be maintained.
|
||||
# For more background see the blueprint "centralize-config-options"
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from nova.conf import serial_console
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
serial_console.register_opts(CONF)
|
76
nova/conf/serial_console.py
Normal file
76
nova/conf/serial_console.py
Normal file
@ -0,0 +1,76 @@
|
||||
# Copyright 2015 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
|
||||
|
||||
DEFAULT_PORT_RANGE = '10000:20000'
|
||||
|
||||
enabled_opt = cfg.BoolOpt('enabled',
|
||||
default=False,
|
||||
help='Enable serial console related features')
|
||||
|
||||
port_range_opt = cfg.StrOpt('port_range',
|
||||
default=DEFAULT_PORT_RANGE,
|
||||
help='Range of TCP ports to use for serial ports '
|
||||
'on compute hosts')
|
||||
|
||||
base_url_opt = cfg.StrOpt('base_url',
|
||||
default='ws://127.0.0.1:6083/',
|
||||
help='Location of serial console proxy.')
|
||||
|
||||
listen_opt = cfg.StrOpt('listen',
|
||||
default='127.0.0.1',
|
||||
deprecated_for_removal=True,
|
||||
help='IP address on which instance serial console '
|
||||
'should listen')
|
||||
|
||||
proxyclient_address_opt = cfg.StrOpt('proxyclient_address',
|
||||
default='127.0.0.1',
|
||||
help='The address to which proxy clients '
|
||||
'(like nova-serialproxy) should '
|
||||
'connect')
|
||||
|
||||
serialproxy_host_opt = cfg.StrOpt('serialproxy_host',
|
||||
default='0.0.0.0',
|
||||
help='Host on which to listen for incoming '
|
||||
'requests')
|
||||
|
||||
serialproxy_port_opt = cfg.IntOpt('serialproxy_port',
|
||||
default=6083,
|
||||
min=1,
|
||||
max=65535,
|
||||
help='Port on which to listen for incoming '
|
||||
'requests')
|
||||
|
||||
ALL_OPTS = [enabled_opt,
|
||||
port_range_opt,
|
||||
base_url_opt,
|
||||
listen_opt,
|
||||
proxyclient_address_opt,
|
||||
serialproxy_host_opt,
|
||||
serialproxy_port_opt]
|
||||
|
||||
|
||||
def register_opts(conf):
|
||||
conf.register_opts(ALL_OPTS, group="serial_console")
|
||||
|
||||
|
||||
def register_cli_opts(conf):
|
||||
conf.register_cli_opt(serialproxy_host_opt, "serial_console")
|
||||
conf.register_cli_opt(serialproxy_port_opt, "serial_console")
|
||||
|
||||
|
||||
def list_opts():
|
||||
return ("serial_console", ALL_OPTS)
|
@ -16,10 +16,10 @@
|
||||
|
||||
import socket
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import six.moves
|
||||
|
||||
import nova.conf
|
||||
from nova import exception
|
||||
from nova.i18n import _LW
|
||||
from nova import utils
|
||||
@ -28,31 +28,8 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
ALLOCATED_PORTS = set() # in-memory set of already allocated ports
|
||||
SERIAL_LOCK = 'serial-lock'
|
||||
DEFAULT_PORT_RANGE = '10000:20000'
|
||||
|
||||
serial_opts = [
|
||||
cfg.BoolOpt('enabled',
|
||||
default=False,
|
||||
help='Enable serial console related features'),
|
||||
cfg.StrOpt('port_range',
|
||||
default=DEFAULT_PORT_RANGE,
|
||||
help='Range of TCP ports to use for serial ports '
|
||||
'on compute hosts'),
|
||||
cfg.StrOpt('base_url',
|
||||
default='ws://127.0.0.1:6083/',
|
||||
help='Location of serial console proxy.'),
|
||||
cfg.StrOpt('listen',
|
||||
default='127.0.0.1',
|
||||
help='IP address on which instance serial console '
|
||||
'should listen'),
|
||||
cfg.StrOpt('proxyclient_address',
|
||||
default='127.0.0.1',
|
||||
help='The address to which proxy clients '
|
||||
'(like nova-serialproxy) should connect'),
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(serial_opts, group='serial_console')
|
||||
CONF = nova.conf.CONF
|
||||
|
||||
# TODO(sahid): Add a method to initialize ALOCATED_PORTS with the
|
||||
# already binded TPC port(s). (cf from danpb: list all running guests and
|
||||
@ -95,12 +72,13 @@ def _get_port_range():
|
||||
if start >= stop:
|
||||
raise ValueError
|
||||
except ValueError:
|
||||
default_port_range = nova.conf.serial_console.DEFAULT_PORT_RANGE
|
||||
LOG.warning(_LW("serial_console.port_range should be <num>:<num>. "
|
||||
"Given value %(port_range)s could not be parsed. "
|
||||
"Taking the default port range %(default)s."),
|
||||
{'port_range': config_range,
|
||||
'default': DEFAULT_PORT_RANGE})
|
||||
start, stop = map(int, DEFAULT_PORT_RANGE.split(':'))
|
||||
'default': default_port_range})
|
||||
start, stop = map(int, default_port_range.split(':'))
|
||||
return start, stop
|
||||
|
||||
|
||||
|
@ -23,6 +23,7 @@ import nova.cmd.spicehtml5proxy
|
||||
import nova.conductor.api
|
||||
import nova.conductor.rpcapi
|
||||
import nova.conductor.tasks.live_migrate
|
||||
import nova.conf
|
||||
import nova.console.manager
|
||||
import nova.console.rpcapi
|
||||
import nova.console.serial
|
||||
@ -77,7 +78,6 @@ def list_opts():
|
||||
nova.cloudpipe.pipelib.cloudpipe_opts,
|
||||
nova.cmd.novnc.opts,
|
||||
nova.cmd.novncproxy.opts,
|
||||
nova.cmd.serialproxy.opts,
|
||||
nova.cmd.spicehtml5proxy.opts,
|
||||
nova.console.manager.console_manager_opts,
|
||||
nova.console.rpcapi.rpcapi_opts,
|
||||
@ -117,11 +117,7 @@ def list_opts():
|
||||
nova.keymgr.keymgr_opts,
|
||||
)),
|
||||
('rdp', nova.rdp.rdp_opts),
|
||||
('serial_console',
|
||||
itertools.chain(
|
||||
nova.cmd.serialproxy.opts,
|
||||
nova.console.serial.serial_opts,
|
||||
)),
|
||||
nova.conf.serial_console.list_opts(),
|
||||
('spice',
|
||||
itertools.chain(
|
||||
nova.cmd.spicehtml5proxy.opts,
|
||||
|
@ -290,9 +290,6 @@ CONF.import_opt('server_proxyclient_address', 'nova.spice', group='spice')
|
||||
CONF.import_opt('vcpu_pin_set', 'nova.virt.hardware')
|
||||
CONF.import_opt('vif_plugging_is_fatal', 'nova.virt.driver')
|
||||
CONF.import_opt('vif_plugging_timeout', 'nova.virt.driver')
|
||||
CONF.import_opt('enabled', 'nova.console.serial', group='serial_console')
|
||||
CONF.import_opt('proxyclient_address', 'nova.console.serial',
|
||||
group='serial_console')
|
||||
CONF.import_opt('hw_disk_discard', 'nova.virt.libvirt.imagebackend',
|
||||
group='libvirt')
|
||||
CONF.import_group('workarounds', 'nova.utils')
|
||||
|
Loading…
x
Reference in New Issue
Block a user