summaryrefslogtreecommitdiffstats
path: root/nova/volume
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/volume
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/volume')
-rw-r--r--nova/volume/driver.py47
-rw-r--r--nova/volume/iscsi.py9
-rw-r--r--nova/volume/manager.py27
-rw-r--r--nova/volume/san.py54
4 files changed, 89 insertions, 48 deletions
diff --git a/nova/volume/driver.py b/nova/volume/driver.py
index 475a5434c..0505b89b1 100644
--- a/nova/volume/driver.py
+++ b/nova/volume/driver.py
@@ -24,6 +24,7 @@ import os
import time
from xml.etree import ElementTree
+from nova.common import cfg
from nova import exception
from nova import flags
from nova import log as logging
@@ -33,24 +34,36 @@ from nova.volume import volume_types
LOG = logging.getLogger("nova.volume.driver")
+
+volume_opts = [
+ cfg.StrOpt('volume_group',
+ default='nova-volumes',
+ help='Name for the VG that will contain exported volumes'),
+ cfg.StrOpt('num_shell_tries',
+ default=3,
+ help='number of times to attempt to run flakey shell commands'),
+ cfg.StrOpt('num_iscsi_scan_tries',
+ default=3,
+ help='number of times to rescan iSCSI target to find volume'),
+ cfg.IntOpt('iscsi_num_targets',
+ default=100,
+ help='Number of iscsi target ids per host'),
+ cfg.StrOpt('iscsi_target_prefix',
+ default='iqn.2010-10.org.openstack:',
+ help='prefix for iscsi volumes'),
+ cfg.StrOpt('iscsi_ip_address',
+ default='$my_ip',
+ help='use this ip for iscsi'),
+ cfg.IntOpt('iscsi_port',
+ default=3260,
+ help='The port that the iSCSI daemon is listening on'),
+ cfg.StrOpt('rbd_pool',
+ default='rbd',
+ help='the rbd pool in which volumes are stored'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('volume_group', 'nova-volumes',
- 'Name for the VG that will contain exported volumes')
-flags.DEFINE_string('num_shell_tries', 3,
- 'number of times to attempt to run flakey shell commands')
-flags.DEFINE_string('num_iscsi_scan_tries', 3,
- 'number of times to rescan iSCSI target to find volume')
-flags.DEFINE_integer('iscsi_num_targets',
- 100,
- 'Number of iscsi target ids per host')
-flags.DEFINE_string('iscsi_target_prefix', 'iqn.2010-10.org.openstack:',
- 'prefix for iscsi volumes')
-flags.DEFINE_string('iscsi_ip_address', '$my_ip',
- 'use this ip for iscsi')
-flags.DEFINE_integer('iscsi_port', 3260,
- 'The port that the iSCSI daemon is listening on')
-flags.DEFINE_string('rbd_pool', 'rbd',
- 'the rbd pool in which volumes are stored')
+FLAGS.add_options(volume_opts)
class VolumeDriver(object):
diff --git a/nova/volume/iscsi.py b/nova/volume/iscsi.py
index d50dd5fd7..66c293f15 100644
--- a/nova/volume/iscsi.py
+++ b/nova/volume/iscsi.py
@@ -20,13 +20,18 @@ Helper code for the iSCSI volume driver.
"""
+from nova.common import cfg
from nova import flags
from nova import utils
+iscsi_helper_opt = \
+ cfg.StrOpt('iscsi_helper',
+ default='ietadm',
+ help='iscsi target user-land tool to use')
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('iscsi_helper', 'ietadm',
- 'iscsi target user-land tool to use')
+FLAGS.add_option(iscsi_helper_opt)
class TargetAdmin(object):
diff --git a/nova/volume/manager.py b/nova/volume/manager.py
index 63eb04664..f22fcc2ca 100644
--- a/nova/volume/manager.py
+++ b/nova/volume/manager.py
@@ -38,6 +38,7 @@ intact.
"""
+from nova.common import cfg
from nova import context
from nova import exception
from nova import flags
@@ -49,16 +50,24 @@ from nova.volume import volume_types
LOG = logging.getLogger('nova.volume.manager')
+
+volume_manager_opts = [
+ cfg.StrOpt('storage_availability_zone',
+ default='nova',
+ help='availability zone of this service'),
+ cfg.StrOpt('volume_driver',
+ default='nova.volume.driver.ISCSIDriver',
+ help='Driver to use for volume creation'),
+ cfg.BoolOpt('use_local_volumes',
+ default=True,
+ help='if True, will not discover local volumes'),
+ cfg.BoolOpt('volume_force_update_capabilities',
+ default=False,
+ help='if True will force update capabilities on each check'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('storage_availability_zone',
- 'nova',
- 'availability zone of this service')
-flags.DEFINE_string('volume_driver', 'nova.volume.driver.ISCSIDriver',
- 'Driver to use for volume creation')
-flags.DEFINE_boolean('use_local_volumes', True,
- 'if True, will not discover local volumes')
-flags.DEFINE_boolean('volume_force_update_capabilities', False,
- 'if True will force update capabilities on each check')
+FLAGS.add_options(volume_manager_opts)
class VolumeManager(manager.SchedulerDependentManager):
diff --git a/nova/volume/san.py b/nova/volume/san.py
index c87841feb..0c88e9d75 100644
--- a/nova/volume/san.py
+++ b/nova/volume/san.py
@@ -26,6 +26,7 @@ import paramiko
from xml.etree import ElementTree
+from nova.common import cfg
from nova import exception
from nova import flags
from nova import log as logging
@@ -34,27 +35,40 @@ from nova.utils import ssh_execute
from nova.volume.driver import ISCSIDriver
LOG = logging.getLogger("nova.volume.driver")
+
+san_opts = [
+ cfg.BoolOpt('san_thin_provision',
+ default='true',
+ help='Use thin provisioning for SAN volumes?'),
+ cfg.StrOpt('san_ip',
+ default='',
+ help='IP address of SAN controller'),
+ cfg.StrOpt('san_login',
+ default='admin',
+ help='Username for SAN controller'),
+ cfg.StrOpt('san_password',
+ default='',
+ help='Password for SAN controller'),
+ cfg.StrOpt('san_private_key',
+ default='',
+ help='Filename of private key to use for SSH authentication'),
+ cfg.StrOpt('san_clustername',
+ default='',
+ help='Cluster name to use for creating volumes'),
+ cfg.IntOpt('san_ssh_port',
+ default=22,
+ help='SSH port to use with SAN'),
+ cfg.BoolOpt('san_is_local',
+ default='false',
+ help='Execute commands locally instead of over SSH; '
+ 'use if the volume service is running on the SAN device'),
+ cfg.StrOpt('san_zfs_volume_base',
+ default='rpool/',
+ help='The ZFS path under which to create zvols for volumes.'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_boolean('san_thin_provision', 'true',
- 'Use thin provisioning for SAN volumes?')
-flags.DEFINE_string('san_ip', '',
- 'IP address of SAN controller')
-flags.DEFINE_string('san_login', 'admin',
- 'Username for SAN controller')
-flags.DEFINE_string('san_password', '',
- 'Password for SAN controller')
-flags.DEFINE_string('san_private_key', '',
- 'Filename of private key to use for SSH authentication')
-flags.DEFINE_string('san_clustername', '',
- 'Cluster name to use for creating volumes')
-flags.DEFINE_integer('san_ssh_port', 22,
- 'SSH port to use with SAN')
-flags.DEFINE_boolean('san_is_local', 'false',
- 'Execute commands locally instead of over SSH; '
- 'use if the volume service is running on the SAN device')
-flags.DEFINE_string('san_zfs_volume_base',
- 'rpool/',
- 'The ZFS path under which to create zvols for volumes.')
+FLAGS.add_options(san_opts)
class SanISCSIDriver(ISCSIDriver):