config options: centralize 'spice' options

This change moves the spice configuration options previously
defined in the nova/spice and nova/cmd folders to the nova/conf
folder.

Implements: blueprint centralize-config-options-newton
Change-Id: I2a8130b51ce3975c6cfd3c6181ea7e7d53fbc49f
Co-Authored-By: Allen Gao <wanlong.gao@gmail.com>
This commit is contained in:
Chuck Carmack 2016-01-06 16:46:35 +00:00 committed by Allen Gao
parent db851200d3
commit dc2e3130fe
8 changed files with 110 additions and 71 deletions

View File

@ -106,7 +106,6 @@ import nova.scheduler.weights.metrics
import nova.scheduler.weights.ram
import nova.service
import nova.servicegroup.api
import nova.spice
import nova.utils
import nova.vnc
import nova.vnc.xvp_proxy

View File

@ -20,25 +20,14 @@ SPICE HTML5 consoles. Leverages websockify.py by Joel Martin
import sys
from oslo_config import cfg
from nova.cmd import baseproxy
import nova.conf
from nova.conf import spice
from nova import config
opts = [
cfg.StrOpt('html5proxy_host',
default='0.0.0.0',
help='Host on which to listen for incoming requests'),
cfg.IntOpt('html5proxy_port',
default=6082,
min=1,
max=65535,
help='Port on which to listen for incoming requests'),
]
CONF = cfg.CONF
CONF.register_cli_opts(opts, group='spice')
CONF = nova.conf.CONF
spice.register_cli_opts(CONF)
def main():

View File

@ -265,7 +265,6 @@ CONF.register_opts(timeout_opts)
CONF.register_opts(running_deleted_opts)
CONF.register_opts(instance_cleaning_opts)
CONF.import_opt('host', 'nova.netconf')
CONF.import_opt('enabled', 'nova.spice', group='spice')
LOG = logging.getLogger(__name__)

View File

@ -71,7 +71,7 @@ from nova.conf import scheduler
# from nova.conf import security
from nova.conf import serial_console
from nova.conf import service
# from nova.conf import spice
from nova.conf import spice
# from nova.conf import ssl
# from nova.conf import trusted_computing
from nova.conf import upgrade_levels
@ -138,7 +138,7 @@ scheduler.register_opts(CONF)
# security.register_opts(CONF)
serial_console.register_opts(CONF)
service.register_opts(CONF)
# spice.register_opts(CONF)
spice.register_opts(CONF)
# ssl.register_opts(CONF)
# trusted_computing.register_opts(CONF)
upgrade_levels.register_opts(CONF)

104
nova/conf/spice.py Normal file
View File

@ -0,0 +1,104 @@
# 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
GROUP_NAME = 'spice'
spice_opt_group = cfg.OptGroup(GROUP_NAME)
enabled_opt = cfg.BoolOpt('enabled',
default=False,
help="""
Enable spice related features.
""")
agent_enabled_opt = cfg.BoolOpt('agent_enabled',
default=True,
help="""
Enable the spice guest agent support.
""")
html5proxy_base_url_opt = cfg.StrOpt('html5proxy_base_url',
default='http://127.0.0.1:6082/spice_auto.html',
help="""
Location of spice HTML5 console proxy, in the form
"http://127.0.0.1:6082/spice_auto.html"
""")
html5proxy_host_opt = cfg.StrOpt('html5proxy_host',
default='0.0.0.0',
help="""
Host on which to listen for incoming requests
""")
html5proxy_port_opt = cfg.IntOpt('html5proxy_port',
default=6082,
min=1,
max=65535,
help="""
Port on which to listen for incoming requests
""")
server_listen_opt = cfg.StrOpt('server_listen',
default='127.0.0.1',
help="""
IP address on which instance spice server should listen
""")
server_proxyclient_address_opt = cfg.StrOpt('server_proxyclient_address',
default='127.0.0.1',
help="""
The address to which proxy clients (like nova-spicehtml5proxy) should connect
""")
keymap_opt = cfg.StrOpt('keymap',
default='en-us',
help="""
Keymap for spice
""")
ALL_OPTS = [html5proxy_base_url_opt,
server_listen_opt,
server_proxyclient_address_opt,
enabled_opt,
agent_enabled_opt,
keymap_opt,
html5proxy_host_opt,
html5proxy_port_opt]
CLI_OPTS = [html5proxy_host_opt,
html5proxy_port_opt]
def register_opts(conf):
conf.register_opts(ALL_OPTS, group=spice_opt_group)
def register_cli_opts(conf):
conf.register_cli_opts(CLI_OPTS, group=spice_opt_group)
def list_opts():
return {spice_opt_group: ALL_OPTS}

View File

@ -30,7 +30,6 @@ import nova.image.download.file
import nova.netconf
import nova.paths
import nova.servicegroup.api
import nova.spice
import nova.volume
import nova.volume.cinder
@ -52,9 +51,4 @@ def list_opts():
('cinder', nova.volume.cinder.cinder_opts),
('api_database', nova.db.sqlalchemy.api.api_db_opts),
('database', nova.db.sqlalchemy.api.oslo_db_options.database_opts),
('spice',
itertools.chain(
nova.cmd.spicehtml5proxy.opts,
nova.spice.spice_opts,
))
]

View File

@ -1,45 +0,0 @@
#!/usr/bin/env python
# Copyright (c) 2012 Red Hat, 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.
"""Module for SPICE Proxying."""
from oslo_config import cfg
spice_opts = [
cfg.StrOpt('html5proxy_base_url',
default='http://127.0.0.1:6082/spice_auto.html',
help='Location of spice HTML5 console proxy, in the form '
'"http://127.0.0.1:6082/spice_auto.html"'),
cfg.StrOpt('server_listen',
default='127.0.0.1',
help='IP address on which instance spice server should listen'),
cfg.StrOpt('server_proxyclient_address',
default='127.0.0.1',
help='The address to which proxy clients '
'(like nova-spicehtml5proxy) should connect'),
cfg.BoolOpt('enabled',
default=False,
help='Enable spice related features'),
cfg.BoolOpt('agent_enabled',
default=True,
help='Enable spice guest agent support'),
cfg.StrOpt('keymap',
default='en-us',
help='Keymap for spice'),
]
CONF = cfg.CONF
CONF.register_opts(spice_opts, group='spice')

View File

@ -315,7 +315,6 @@ CONF.register_opts(libvirt_opts, 'libvirt')
CONF.import_opt('host', 'nova.netconf')
CONF.import_opt('my_ip', 'nova.netconf')
CONF.import_opt('live_migration_retry_count', 'nova.compute.manager')
CONF.import_opt('server_proxyclient_address', 'nova.spice', group='spice')
CONF.import_opt('hw_disk_discard', 'nova.virt.libvirt.imagebackend',
group='libvirt')
CONF.import_opt('iscsi_use_multipath', 'nova.virt.libvirt.volume.iscsi',