From ffcdb42ba17dadae5074ffb7315201410ec18eb7 Mon Sep 17 00:00:00 2001 From: Maciej Szankin Date: Fri, 21 Oct 2016 12:33:05 +0200 Subject: [PATCH] conf: move few console opts to xenserver group console_allowed_origins and console_public_hostname are specific to XenServer deployments, so moving them to xenserver group. Leaving the rest as they are or will be deprecated. Implements: bp centralize-config-options-ocata Co-Authored-By: Sarafraj Singh Change-Id: I154f18ab2943465db5e3e9fcee06f2a7269df898 --- nova/conf/console.py | 65 ++++++++++--------- nova/conf/xenserver.py | 17 ++++- nova/console/manager.py | 3 +- nova/console/websocketproxy.py | 2 +- .../api_sample_tests/test_consoles.py | 2 +- .../tests/unit/console/test_websocketproxy.py | 5 +- ...opt-to-console-group-de693ac26bc9b090.yaml | 5 ++ 7 files changed, 63 insertions(+), 36 deletions(-) create mode 100644 releasenotes/notes/move-console-opt-to-console-group-de693ac26bc9b090.yaml diff --git a/nova/conf/console.py b/nova/conf/console.py index 222137fc9a59..443b4719f935 100644 --- a/nova/conf/console.py +++ b/nova/conf/console.py @@ -13,12 +13,31 @@ # License for the specific language governing permissions and limitations # under the License. -import socket - from oslo_config import cfg +console_group = cfg.OptGroup('console', + title='Console Options', + help=""" +Options under this group allow to tune the configuration of the console proxy +service. -console_opts = [ +Note: in configuration of every compute is a ``console_host`` option, +which allows to select the console proxy service to connect to. +""") + +default_opts = [ + # TODO(raj_singh): Deprecate this option + cfg.StrOpt('console_driver', + default='nova.console.xvp.XVPConsoleProxy', + help=""" +Nova-console proxy is used to set up multi-tenant VM console access. +This option allows pluggable driver program for the console session +and represents driver to use for the console proxy. + +Possible values: + +* A string representing fully classified class name of console driver. +"""), cfg.StrOpt('console_topic', default='console', deprecated_for_removal=True, @@ -37,21 +56,14 @@ host. Possible values: * A string representing topic exchange name -"""), - # TODO(pumaranikar): Move this config to stevedore plugin system. - cfg.StrOpt('console_driver', - default='nova.console.xvp.XVPConsoleProxy', - help=""" -Nova-console proxy is used to set up multi-tenant VM console access. -This option allows pluggable driver program for the console session -and represents driver to use for the console proxy. +""") +] -Possible values: - -* A string representing fully classified class name of console driver. -"""), - cfg.ListOpt('console_allowed_origins', +console_opts = [ + cfg.ListOpt('allowed_origins', default=[], + deprecated_group='default', + deprecated_name='console_allowed_origins', help=""" Adds list of allowed origins to the console websocket proxy to allow connections from other origin hostnames. @@ -62,25 +74,18 @@ values other than host are allowed in the origin header. Possible values: * A list where each element is an allowed origin hostnames, else an empty list -"""), - # TODO(sfinucan): Convert this to URIOpt - cfg.StrOpt('console_public_hostname', - default=socket.gethostname(), - help=""" -Publicly visible name for this console host. - -Possible values: - -* A string representing a valid hostname """), ] def register_opts(conf): - conf.register_opts(console_opts) + conf.register_group(console_group) + conf.register_opts(console_opts, group=console_group) + conf.register_opts(default_opts) -# TODO(pumaranikar): We can consider moving these options to console group -# and renaming them all to drop console bit. def list_opts(): - return {"DEFAULT": console_opts} + return { + console_group: console_opts, + 'DEFAULT': default_opts, + } diff --git a/nova/conf/xenserver.py b/nova/conf/xenserver.py index c702f9c86e18..68a4d33f5548 100644 --- a/nova/conf/xenserver.py +++ b/nova/conf/xenserver.py @@ -13,8 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. + from oslo_config import cfg from oslo_utils import units +import socket xenserver_group = cfg.OptGroup('xenserver', title='Xenserver Options', @@ -585,6 +587,18 @@ that adding new host will fail, thus option to force join was introduced. """), ] +xenapi_console_opts = [ + cfg.StrOpt('console_public_hostname', + default=socket.gethostname(), + deprecated_group='DEFAULT', + help=""" +Publicly visible name for this console host. + +Possible values: + +* A string representing a valid hostname +"""), +] ALL_XENSERVER_OPTS = (xenapi_agent_opts + xenapi_session_opts + @@ -594,7 +608,8 @@ ALL_XENSERVER_OPTS = (xenapi_agent_opts + xenapi_vmops_opts + xenapi_volume_utils_opts + xenapi_ovs_integration_bridge_opts + - xenapi_pool_opts) + xenapi_pool_opts + + xenapi_console_opts) def register_opts(conf): diff --git a/nova/console/manager.py b/nova/console/manager.py index 984530c67b0d..6fc8904fb83b 100644 --- a/nova/console/manager.py +++ b/nova/console/manager.py @@ -110,7 +110,8 @@ class ConsoleProxyManager(manager.Manager): pool_info['password'] = self.driver.fix_pool_password( pool_info['password']) pool_info['host'] = self.host - pool_info['public_hostname'] = CONF.console_public_hostname + pool_info['public_hostname'] = \ + CONF.xenserver.console_public_hostname pool_info['console_type'] = self.driver.console_type pool_info['compute_host'] = instance_host pool = self.db.console_pool_create(context, pool_info) diff --git a/nova/console/websocketproxy.py b/nova/console/websocketproxy.py index f9bb39b3389d..de4f09f3ca1c 100644 --- a/nova/console/websocketproxy.py +++ b/nova/console/websocketproxy.py @@ -116,7 +116,7 @@ class NovaProxyRequestHandlerBase(object): expected_origin_hostname = e.split(']')[0][1:] else: expected_origin_hostname = e.split(':')[0] - expected_origin_hostnames = CONF.console_allowed_origins + expected_origin_hostnames = CONF.console.allowed_origins expected_origin_hostnames.append(expected_origin_hostname) origin_url = self.headers.getheader('Origin') # missing origin header indicates non-browser client which is OK diff --git a/nova/tests/functional/api_sample_tests/test_consoles.py b/nova/tests/functional/api_sample_tests/test_consoles.py index c479f9d0c703..eefb9d22b5f7 100644 --- a/nova/tests/functional/api_sample_tests/test_consoles.py +++ b/nova/tests/functional/api_sample_tests/test_consoles.py @@ -22,7 +22,7 @@ class ConsolesSamplesJsonTest(test_servers.ServersSampleBase): def setUp(self): super(ConsolesSamplesJsonTest, self).setUp() - self.flags(console_public_hostname='fake') + self.flags(console_public_hostname='fake', group='xenserver') self.flags(console_host='fake') self.flags(console_driver='nova.console.fake.FakeConsoleProxy') self.console = self.start_service('console', host='fake') diff --git a/nova/tests/unit/console/test_websocketproxy.py b/nova/tests/unit/console/test_websocketproxy.py index eef8a7855127..ad96fe899215 100644 --- a/nova/tests/unit/console/test_websocketproxy.py +++ b/nova/tests/unit/console/test_websocketproxy.py @@ -27,8 +27,9 @@ class NovaProxyRequestHandlerBaseTestCase(test.NoDBTestCase): def setUp(self): super(NovaProxyRequestHandlerBaseTestCase, self).setUp() - self.flags(console_allowed_origins = ['allowed-origin-example-1.net', - 'allowed-origin-example-2.net']) + self.flags(allowed_origins=['allowed-origin-example-1.net', + 'allowed-origin-example-2.net'], + group='console') self.wh = websocketproxy.NovaProxyRequestHandlerBase() self.wh.socket = mock.MagicMock() self.wh.msg = mock.MagicMock() diff --git a/releasenotes/notes/move-console-opt-to-console-group-de693ac26bc9b090.yaml b/releasenotes/notes/move-console-opt-to-console-group-de693ac26bc9b090.yaml new file mode 100644 index 000000000000..fddeee13a8cd --- /dev/null +++ b/releasenotes/notes/move-console-opt-to-console-group-de693ac26bc9b090.yaml @@ -0,0 +1,5 @@ +--- +upgrade: + - | + ``console_public_hostname`` console options under the ``DEFAULT`` group + have been moved to the ``xenserver`` group.