diff --git a/nova/cmd/console.py b/nova/cmd/console.py index 83d64f15cd50..ae3bb3b36e34 100644 --- a/nova/cmd/console.py +++ b/nova/cmd/console.py @@ -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(): diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 12538e574da9..9e726efd8c39 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -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') diff --git a/nova/conf/__init__.py b/nova/conf/__init__.py index f1062c1bbb43..b0af97408ae2 100644 --- a/nova/conf/__init__.py +++ b/nova/conf/__init__.py @@ -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) diff --git a/nova/conf/console.py b/nova/conf/console.py new file mode 100644 index 000000000000..975e7beb0781 --- /dev/null +++ b/nova/conf/console.py @@ -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} diff --git a/nova/console/api.py b/nova/console/api.py index 3f772b8c29ad..1bba7bf727e2 100644 --- a/nova/console/api.py +++ b/nova/console/api.py @@ -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): diff --git a/nova/console/manager.py b/nova/console/manager.py index b5854910c5c3..52e1b9f26d0c 100644 --- a/nova/console/manager.py +++ b/nova/console/manager.py @@ -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__) diff --git a/nova/console/rpcapi.py b/nova/console/rpcapi.py index 5002396749fa..b0b26a314d8d 100644 --- a/nova/console/rpcapi.py +++ b/nova/console/rpcapi.py @@ -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): diff --git a/nova/console/websocketproxy.py b/nova/console/websocketproxy.py index 7dc68e16f84c..f7104f79652e 100644 --- a/nova/console/websocketproxy.py +++ b/nova/console/websocketproxy.py @@ -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): diff --git a/nova/opts.py b/nova/opts.py index b6a415e80638..a9128c687c29 100644 --- a/nova/opts.py +++ b/nova/opts.py @@ -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, diff --git a/nova/tests/unit/console/test_console.py b/nova/tests/unit/console/test_console.py index f5bbc45a8da9..8eefa13bdea0 100644 --- a/nova/tests/unit/console/test_console.py +++ b/nova/tests/unit/console/test_console.py @@ -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):