Config options: Centralize console options

This change moves the config options in nova/console/
manager.py, rpcapi.py and websocketproxy.py to
the new central location "nova/conf/console.py".

Implements: blueprint centralize-config-options-newton

Change-Id: I5928b7f802751c9236238579e69374794c7af697
This commit is contained in:
Sujitha
2016-03-17 19:27:11 +00:00
parent 1b69a2e578
commit 341df63822
10 changed files with 54 additions and 45 deletions

View File

@@ -27,7 +27,6 @@ from nova import service
from nova import version
CONF = cfg.CONF
CONF.import_opt('console_topic', 'nova.console.rpcapi')
def main():

View File

@@ -264,7 +264,6 @@ CONF.register_opts(interval_opts)
CONF.register_opts(timeout_opts)
CONF.register_opts(running_deleted_opts)
CONF.register_opts(instance_cleaning_opts)
CONF.import_opt('console_topic', 'nova.console.rpcapi')
CONF.import_opt('host', 'nova.netconf')
CONF.import_opt('enabled', 'nova.spice', group='spice')

View File

@@ -32,7 +32,7 @@ from nova.conf import cloudpipe
from nova.conf import compute
from nova.conf import conductor
from nova.conf import configdrive
# from nova.conf import console
from nova.conf import console
from nova.conf import consoleauth
# from nova.conf import cors
# from nova.conf import cors.subdomain
@@ -98,7 +98,7 @@ cloudpipe.register_opts(CONF)
compute.register_opts(CONF)
conductor.register_opts(CONF)
configdrive.register_opts(CONF)
# console.register_opts(CONF)
console.register_opts(CONF)
consoleauth.register_opts(CONF)
# cors.register_opts(CONF)
# cors.subdomain.register_opts(CONF)

46
nova/conf/console.py Normal file
View File

@@ -0,0 +1,46 @@
# 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.
import socket
from oslo_config import cfg
console_opts = [
cfg.ListOpt('console_allowed_origins',
default=[],
help='Allowed Origin header hostnames for access to console '
'proxy servers'),
cfg.StrOpt('console_topic',
default='console',
help='The topic console proxy nodes listen on'),
cfg.StrOpt('console_driver',
default='nova.console.xvp.XVPConsoleProxy',
help='Driver to use for the console proxy'),
cfg.BoolOpt('stub_compute',
default=False,
help='Stub calls to compute worker for tests'),
cfg.StrOpt('console_public_hostname',
default=socket.gethostname(),
help='Publicly visible name for this console host'),
]
def register_opts(conf):
conf.register_opts(console_opts)
def list_opts():
return {"DEFAULT": console_opts}

View File

@@ -15,15 +15,14 @@
"""Handles ConsoleProxy API requests."""
from oslo_config import cfg
from nova.compute import rpcapi as compute_rpcapi
import nova.conf
from nova.console import rpcapi as console_rpcapi
from nova.db import base
from nova import objects
CONF = cfg.CONF
CONF.import_opt('console_topic', 'nova.console.rpcapi')
CONF = nova.conf.CONF
class API(base.Base):

View File

@@ -15,34 +15,19 @@
"""Console Proxy Service."""
import socket
from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging as messaging
from oslo_utils import importutils
from nova.compute import rpcapi as compute_rpcapi
import nova.conf
from nova import exception
from nova.i18n import _LI
from nova import manager
from nova import utils
console_manager_opts = [
cfg.StrOpt('console_driver',
default='nova.console.xvp.XVPConsoleProxy',
help='Driver to use for the console proxy'),
cfg.BoolOpt('stub_compute',
default=False,
help='Stub calls to compute worker for tests'),
cfg.StrOpt('console_public_hostname',
default=socket.gethostname(),
help='Publicly visible name for this console host'),
]
CONF = cfg.CONF
CONF.register_opts(console_manager_opts)
CONF = nova.conf.CONF
LOG = logging.getLogger(__name__)

View File

@@ -16,20 +16,12 @@
Client side of the console RPC API.
"""
from oslo_config import cfg
import oslo_messaging as messaging
import nova.conf
from nova import rpc
rpcapi_opts = [
cfg.StrOpt('console_topic',
default='console',
help='The topic console proxy nodes listen on'),
]
CONF = nova.conf.CONF
CONF.register_opts(rpcapi_opts)
class ConsoleAPI(object):

View File

@@ -21,12 +21,12 @@ Leverages websockify.py by Joel Martin
import socket
import sys
from oslo_config import cfg
from oslo_log import log as logging
from six.moves import http_cookies as Cookie
import six.moves.urllib.parse as urlparse
import websockify
import nova.conf
from nova.consoleauth import rpcapi as consoleauth_rpcapi
from nova import context
from nova import exception
@@ -34,14 +34,7 @@ from nova.i18n import _
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
console_origin_opts = [
cfg.ListOpt('console_allowed_origins',
default=[],
help='Allowed Origin header hostnames for access to console '
'proxy servers'),
]
CONF.register_opts(console_origin_opts)
CONF = nova.conf.CONF
class NovaProxyRequestHandlerBase(object):

View File

@@ -19,7 +19,6 @@ import nova.cmd.spicehtml5proxy
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
import nova.console.xvp
@@ -48,8 +47,6 @@ def list_opts():
[nova.db.base.db_driver_opt],
[nova.ipv6.api.ipv6_backend_opt],
[nova.servicegroup.api.servicegroup_driver_opt],
nova.console.manager.console_manager_opts,
nova.console.rpcapi.rpcapi_opts,
nova.console.xvp.xvp_opts,
nova.db.api.db_opts,
nova.db.sqlalchemy.api.db_opts,

View File

@@ -29,7 +29,6 @@ from nova import objects
from nova import test
CONF = nova.conf.CONF
CONF.import_opt('console_driver', 'nova.console.manager')
class ConsoleTestCase(test.TestCase):