Merge "conf: Move consoleauth options to a group"

This commit is contained in:
Jenkins 2016-12-02 13:41:00 +00:00 committed by Gerrit Code Review
commit 82dd524434
4 changed files with 32 additions and 16 deletions

View File

@ -16,9 +16,7 @@
from oslo_config import cfg from oslo_config import cfg
default_opts = [
consoleauth_opts = [
cfg.StrOpt('consoleauth_topic', cfg.StrOpt('consoleauth_topic',
default='consoleauth', default='consoleauth',
deprecated_for_removal=True, deprecated_for_removal=True,
@ -37,25 +35,37 @@ communicate with nova-consoleauth to get a VNC console.
Possible Values: Possible Values:
* 'consoleauth' (default) or Any string representing topic exchange name. * 'consoleauth' (default) or Any string representing topic exchange name.
"""), """),
cfg.IntOpt('console_token_ttl', ]
consoleauth_group = cfg.OptGroup(
name='consoleauth',
title='Console auth options')
consoleauth_opts = [
cfg.IntOpt('token_ttl',
default=600, default=600,
min=0, min=0,
deprecated_name='console_token_ttl',
deprecated_group='DEFAULT',
help=""" help="""
This option indicates the lifetime of a console auth token. A console auth The lifetime of a console auth token.
token is used in authorizing console access for a user. Once the auth token
time to live count has elapsed, the token is considered expired. Expired A console auth token is used in authorizing console access for a user.
tokens are then deleted. Once the auth token time to live count has elapsed, the token is
considered expired. Expired tokens are then deleted.
""") """)
] ]
def register_opts(conf): def register_opts(conf):
conf.register_opts(consoleauth_opts) conf.register_opts(default_opts)
conf.register_group(consoleauth_group)
conf.register_opts(consoleauth_opts, group=consoleauth_group)
def list_opts(): def list_opts():
# TODO(aunnam): This should be moved into the consoleauth group and return {'DEFAULT': default_opts,
# oslo_config.cfg.OptGroup used consoleauth_group: consoleauth_opts}
return {'DEFAULT': consoleauth_opts}

View File

@ -52,7 +52,7 @@ class ConsoleAuthManager(manager.Manager):
@property @property
def mc(self): def mc(self):
if self._mc is None: if self._mc is None:
self._mc = cache_utils.get_client(CONF.console_token_ttl) self._mc = cache_utils.get_client(CONF.consoleauth.token_ttl)
return self._mc return self._mc
@property @property

View File

@ -52,7 +52,7 @@ class ConsoleauthTestCase(test.NoDBTestCase):
# Test that tokens expire correctly. # Test that tokens expire correctly.
self.useFixture(test.TimeOverride()) self.useFixture(test.TimeOverride())
token = u'mytok' token = u'mytok'
self.flags(console_token_ttl=1) self.flags(token_ttl=1, group='consoleauth')
self._stub_validate_console_port(True) self._stub_validate_console_port(True)
@ -121,7 +121,7 @@ class ConsoleauthTestCase(test.NoDBTestCase):
def test_delete_expired_tokens(self): def test_delete_expired_tokens(self):
self.useFixture(test.TimeOverride()) self.useFixture(test.TimeOverride())
token = u'mytok' token = u'mytok'
self.flags(console_token_ttl=1) self.flags(token_ttl=1, group='consoleauth')
self._stub_validate_console_port(True) self._stub_validate_console_port(True)

View File

@ -0,0 +1,6 @@
---
upgrade:
- |
The ``console_token_ttl`` configuration option has been moved to the
``consoleauth`` group and renamed ``token_ttl``. It should no longer be
included in the ``DEFAULT`` group.