summaryrefslogtreecommitdiffstats
path: root/nova/console
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2012-01-23 11:51:14 +0000
committerMark McLoughlin <markmc@redhat.com>2012-01-28 12:37:16 +0000
commit82049af90e86380043c59741fa4e1cd2cf24aaa7 (patch)
treefd5a35b7a373de888ece003929f8c499b34ce83c /nova/console
parent02b872625b94c3c63674d8c64b23f80215b04a15 (diff)
downloadnova-82049af90e86380043c59741fa4e1cd2cf24aaa7.tar.gz
nova-82049af90e86380043c59741fa4e1cd2cf24aaa7.tar.xz
nova-82049af90e86380043c59741fa4e1cd2cf24aaa7.zip
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
Diffstat (limited to 'nova/console')
-rw-r--r--nova/console/manager.py22
-rw-r--r--nova/console/vmrc.py17
-rw-r--r--nova/console/vmrc_manager.py14
-rw-r--r--nova/console/xvp.py35
4 files changed, 55 insertions, 33 deletions
diff --git a/nova/console/manager.py b/nova/console/manager.py
index bb58bcf1f..220ac32c5 100644
--- a/nova/console/manager.py
+++ b/nova/console/manager.py
@@ -19,6 +19,7 @@
import socket
+from nova.common import cfg
from nova import exception
from nova import flags
from nova import log as logging
@@ -27,15 +28,20 @@ from nova import rpc
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 visable name for this console host'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('console_driver',
- 'nova.console.xvp.XVPConsoleProxy',
- 'Driver to use for the console proxy')
-flags.DEFINE_boolean('stub_compute', False,
- 'Stub calls to compute worker for tests')
-flags.DEFINE_string('console_public_hostname',
- socket.gethostname(),
- 'Publicly visable name for this console host')
+FLAGS.add_options(console_manager_opts)
class ConsoleProxyManager(manager.Manager):
diff --git a/nova/console/vmrc.py b/nova/console/vmrc.py
index 4b7f1cdfc..e29254d60 100644
--- a/nova/console/vmrc.py
+++ b/nova/console/vmrc.py
@@ -20,18 +20,23 @@
import base64
import json
+from nova.common import cfg
from nova import exception
from nova import flags
from nova.virt.vmwareapi import vim_util
+vmrc_opts = [
+ cfg.IntOpt('console_vmrc_port',
+ default=443,
+ help="port for VMware VMRC connections"),
+ cfg.IntOpt('console_vmrc_error_retries',
+ default=10,
+ help="number of retries for retrieving VMRC information"),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_integer('console_vmrc_port',
- 443,
- "port for VMware VMRC connections")
-flags.DEFINE_integer('console_vmrc_error_retries',
- 10,
- "number of retries for retrieving VMRC information")
+FLAGS.add_options(vmrc_opts)
class VMRCConsole(object):
diff --git a/nova/console/vmrc_manager.py b/nova/console/vmrc_manager.py
index 0b5ce4a49..03cc46bf6 100644
--- a/nova/console/vmrc_manager.py
+++ b/nova/console/vmrc_manager.py
@@ -17,6 +17,7 @@
"""VMRC Console Manager."""
+from nova.common import cfg
from nova import exception
from nova import flags
from nova import log as logging
@@ -28,12 +29,17 @@ from nova.virt import vmwareapi_conn
LOG = logging.getLogger("nova.console.vmrc_manager")
+vmrc_manager_opts = [
+ cfg.StrOpt('console_public_hostname',
+ default='',
+ help='Publicly visible name for this console host'),
+ cfg.StrOpt('console_driver',
+ default='nova.console.vmrc.VMRCConsole',
+ help='Driver to use for the console'),
+ ]
FLAGS = flags.FLAGS
-flags.DEFINE_string('console_public_hostname', '',
- 'Publicly visible name for this console host')
-flags.DEFINE_string('console_driver', 'nova.console.vmrc.VMRCConsole',
- 'Driver to use for the console')
+FLAGS.add_options(vmrc_manager_opts)
class ConsoleVMRCManager(manager.Manager):
diff --git a/nova/console/xvp.py b/nova/console/xvp.py
index 17942321c..2b8dcc1e0 100644
--- a/nova/console/xvp.py
+++ b/nova/console/xvp.py
@@ -22,6 +22,7 @@ import signal
from Cheetah import Template
+from nova.common import cfg
from nova import context
from nova import db
from nova import exception
@@ -30,22 +31,26 @@ from nova import log as logging
from nova import utils
+xvp_opts = [
+ cfg.StrOpt('console_xvp_conf_template',
+ default=utils.abspath('console/xvp.conf.template'),
+ help='XVP conf template'),
+ cfg.StrOpt('console_xvp_conf',
+ default='/etc/xvp.conf',
+ help='generated XVP conf file'),
+ cfg.StrOpt('console_xvp_pid',
+ default='/var/run/xvp.pid',
+ help='XVP master process pid file'),
+ cfg.StrOpt('console_xvp_log',
+ default='/var/log/xvp.log',
+ help='XVP log file'),
+ cfg.IntOpt('console_xvp_multiplex_port',
+ default=5900,
+ help='port for XVP to multiplex VNC connections on'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('console_xvp_conf_template',
- utils.abspath('console/xvp.conf.template'),
- 'XVP conf template')
-flags.DEFINE_string('console_xvp_conf',
- '/etc/xvp.conf',
- 'generated XVP conf file')
-flags.DEFINE_string('console_xvp_pid',
- '/var/run/xvp.pid',
- 'XVP master process pid file')
-flags.DEFINE_string('console_xvp_log',
- '/var/log/xvp.log',
- 'XVP log file')
-flags.DEFINE_integer('console_xvp_multiplex_port',
- 5900,
- 'port for XVP to multiplex VNC connections on')
+FLAGS.add_options(xvp_opts)
class XVPConsoleProxy(object):