From 82049af90e86380043c59741fa4e1cd2cf24aaa7 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Mon, 23 Jan 2012 11:51:14 +0000 Subject: Refactor away the flags.DEFINE_* helpers The next obvious step in porting to cfg is to define all options using cfg schemas directly rather than using the flags.DEFINE_* helpers. This is a large change, but it is almost entirely pure refactoring and does not result in any functional changes. The only change to note is that the default values for glance_host, glance_api_servers and default_publisher_id options are now using opt value interpolation i.e. -glance_host=_get_my_ip() +glance_host='$my_ip' -glance_api_servers=['%s:%d' % (FLAGS.glance_host, FLAGS.glance_port)] +glance_api_servers=['$glance_host:$glance_port'] -default_publisher_id=FLAGS.host +default_publisher_id='$host' Also note that the lower_bound check on the {report,periodic}_interval options are no more, but this has been true since cfg was first added. Change-Id: Ia58c8f0aaf61628bb55b1b8485118a2a9852ed17 --- nova/consoleauth/__init__.py | 9 +++++++-- nova/consoleauth/manager.py | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) (limited to 'nova/consoleauth') diff --git a/nova/consoleauth/__init__.py b/nova/consoleauth/__init__.py index 9d578b77a..4048ae433 100644 --- a/nova/consoleauth/__init__.py +++ b/nova/consoleauth/__init__.py @@ -18,9 +18,14 @@ """Module to authenticate Consoles.""" +from nova.common import cfg from nova import flags +consoleauth_topic_opt = \ + cfg.StrOpt('consoleauth_topic', + default='consoleauth', + help='the topic console auth proxy nodes listen on') + FLAGS = flags.FLAGS -flags.DEFINE_string('consoleauth_topic', 'consoleauth', - 'the topic console auth proxy nodes listen on') +FLAGS.add_option(consoleauth_topic_opt) diff --git a/nova/consoleauth/manager.py b/nova/consoleauth/manager.py index 8f86b4b8c..08ddd5a3b 100644 --- a/nova/consoleauth/manager.py +++ b/nova/consoleauth/manager.py @@ -22,6 +22,7 @@ import os import sys import time +from nova.common import cfg from nova import flags from nova import log as logging from nova import manager @@ -29,12 +30,18 @@ from nova import utils LOG = logging.getLogger('nova.consoleauth') + +consoleauth_opts = [ + cfg.IntOpt('console_token_ttl', + default=600, + help='How many seconds before deleting tokens'), + cfg.StrOpt('consoleauth_manager', + default='nova.consoleauth.manager.ConsoleAuthManager', + help='Manager for console auth'), + ] + FLAGS = flags.FLAGS -flags.DEFINE_integer('console_token_ttl', 600, - 'How many seconds before deleting tokens') -flags.DEFINE_string('consoleauth_manager', - 'nova.consoleauth.manager.ConsoleAuthManager', - 'Manager for console auth') +FLAGS.add_options(consoleauth_opts) class ConsoleAuthManager(manager.Manager): -- cgit