From: Eric Brown Date: Tue, 24 Feb 2015 07:02:50 +0000 (-0800) Subject: Use oslo_config choices support X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=132fbcd38ebae52bdd20da54905131b75581520f;p=openstack-build%2Fcinder-build.git Use oslo_config choices support The oslo_config library added support for a choices keyword argument in version 1.2.0a3. This commit leverages the use of choices for StrOpts in Cinder's configuration. References: http://docs.openstack.org/developer/oslo.config/#a3 https://bugs.launchpad.net/oslo-incubator/+bug/1123043 Change-Id: Id94904d9b15bc1c52f47aafe7e59ec738d93f966 --- diff --git a/cinder/common/config.py b/cinder/common/config.py index 5631a3726..e5cd31578 100644 --- a/cinder/common/config.py +++ b/cinder/common/config.py @@ -166,6 +166,7 @@ global_opts = [ help='The full class name of the volume backup API class'), cfg.StrOpt('auth_strategy', default='noauth', + choices=['noauth', 'keystone', 'deprecated'], help='The strategy to use for auth. Supports noauth, keystone, ' 'and deprecated.'), cfg.ListOpt('enabled_backends', diff --git a/cinder/volume/driver.py b/cinder/volume/driver.py index cea0eea83..a46a95a83 100644 --- a/cinder/volume/driver.py +++ b/cinder/volume/driver.py @@ -77,8 +77,8 @@ volume_opts = [ 'running. Otherwise, it will fallback to single path.'), cfg.StrOpt('volume_clear', default='zero', - help='Method used to wipe old volumes (valid options are: ' - 'none, zero, shred)'), + choices=['none', 'zero', 'shred'], + help='Method used to wipe old volumes'), cfg.IntOpt('volume_clear_size', default=0, help='Size in MiB to wipe at start of old volumes. 0 => all'), @@ -89,6 +89,7 @@ volume_opts = [ 'for example "-c3" for idle only priority.'), cfg.StrOpt('iscsi_helper', default='tgtadm', + choices=['tgtadm', 'lioadm', 'iseradm', 'iscsictl', 'fake'], help='iSCSI target user-land tool to use. tgtadm is default, ' 'use lioadm for LIO iSCSI support, iseradm for the ISER ' 'protocol, iscsictl for Chelsio iSCSI Target or fake for ' @@ -109,6 +110,7 @@ volume_opts = [ 'It will be removed in the next release.'), cfg.StrOpt('iscsi_iotype', default='fileio', + choices=['blockio', 'fileio', 'auto'], help=('Sets the behavior of the iSCSI target ' 'to either perform blockio or fileio ' 'optionally, auto can be set and Cinder ' @@ -127,12 +129,14 @@ volume_opts = [ '0 => unlimited'), cfg.StrOpt('iscsi_write_cache', default='on', + choices=['on', 'off'], help='Sets the behavior of the iSCSI target to either ' 'perform write-back(on) or write-through(off). ' 'This parameter is valid if iscsi_helper is set ' 'to tgtadm or iseradm.'), cfg.StrOpt('iscsi_protocol', default='iscsi', + choices=['iscsi', 'iser'], help='Determines the iSCSI protocol for new iSCSI volumes, ' 'created with tgtadm or lioadm target helpers. In ' 'order to enable RDMA, this parameter should be set ' diff --git a/cinder/volume/drivers/ibm/gpfs.py b/cinder/volume/drivers/ibm/gpfs.py index b4e6941df..f52d55b58 100644 --- a/cinder/volume/drivers/ibm/gpfs.py +++ b/cinder/volume/drivers/ibm/gpfs.py @@ -50,7 +50,8 @@ gpfs_opts = [ help='Specifies the path of the Image service repository in ' 'GPFS. Leave undefined if not storing images in GPFS.'), cfg.StrOpt('gpfs_images_share_mode', - default=None, + default='copy_on_write', + choices=['copy', 'copy_on_write'], help='Specifies the type of image copy to be used. Set this ' 'when the Image service repository also uses GPFS so ' 'that image files can be transferred efficiently from ' diff --git a/cinder/volume/drivers/ibm/ibmnas.py b/cinder/volume/drivers/ibm/ibmnas.py index fdd93e8b3..9eb3269b9 100644 --- a/cinder/volume/drivers/ibm/ibmnas.py +++ b/cinder/volume/drivers/ibm/ibmnas.py @@ -52,6 +52,7 @@ LOG = logging.getLogger(__name__) platform_opts = [ cfg.StrOpt('ibmnas_platform_type', default='v7ku', + choices=['v7ku', 'sonas', 'gpfs-nas'], help=('IBMNAS platform type to be used as backend storage; ' 'valid values are - ' 'v7ku : for using IBM Storwize V7000 Unified, ' diff --git a/cinder/volume/drivers/ibm/xiv_ds8k.py b/cinder/volume/drivers/ibm/xiv_ds8k.py index 9f6977732..56747d324 100644 --- a/cinder/volume/drivers/ibm/xiv_ds8k.py +++ b/cinder/volume/drivers/ibm/xiv_ds8k.py @@ -37,11 +37,12 @@ xiv_ds8k_opts = [ cfg.StrOpt( 'xiv_ds8k_connection_type', default='iscsi', - help='Connection type to the IBM Storage Array' - ' (fibre_channel|iscsi)'), + choices=['fibre_channel', 'iscsi'], + help='Connection type to the IBM Storage Array'), cfg.StrOpt( 'xiv_chap', default='disabled', + choices=['disabled', 'enabled'], help='CHAP authentication mode, effective only for iscsi' ' (disabled|enabled)'), ] diff --git a/cinder/volume/drivers/lvm.py b/cinder/volume/drivers/lvm.py index e7098916e..8a5d8b270 100644 --- a/cinder/volume/drivers/lvm.py +++ b/cinder/volume/drivers/lvm.py @@ -51,7 +51,8 @@ volume_opts = [ 'this requires lvm_mirrors + 2 PVs with available space'), cfg.StrOpt('lvm_type', default='default', - help='Type of LVM volumes to deploy; (default or thin)'), + choices=['default', 'thin'], + help='Type of LVM volumes to deploy'), cfg.StrOpt('lvm_conf_file', default='/etc/cinder/lvm.conf', help='LVM conf file to use for the LVM driver in Cinder; ' diff --git a/cinder/volume/drivers/netapp/options.py b/cinder/volume/drivers/netapp/options.py index d8343849b..2da37dafb 100644 --- a/cinder/volume/drivers/netapp/options.py +++ b/cinder/volume/drivers/netapp/options.py @@ -29,15 +29,16 @@ from oslo_config import cfg netapp_proxy_opts = [ cfg.StrOpt('netapp_storage_family', default='ontap_cluster', + choices=['ontap_7mode', 'ontap_cluster', 'eseries'], help=('The storage family type used on the storage system; ' 'valid values are ontap_7mode for using Data ONTAP ' 'operating in 7-Mode, ontap_cluster for using ' 'clustered Data ONTAP, or eseries for using E-Series.')), cfg.StrOpt('netapp_storage_protocol', - default=None, + default='iscsi', + choices=['iscsi', 'fc', 'nfs'], help=('The storage protocol to be used on the data path with ' - 'the storage system; valid values are iscsi, fc, or ' - 'nfs.')), ] + 'the storage system.')), ] netapp_connection_opts = [ cfg.StrOpt('netapp_server_hostname', @@ -54,9 +55,9 @@ netapp_connection_opts = [ netapp_transport_opts = [ cfg.StrOpt('netapp_transport_type', default='http', + choices=['http', 'https'], help=('The transport protocol used when communicating with ' - 'the storage system or proxy server. Valid values are ' - 'http or https.')), ] + 'the storage system or proxy server.')), ] netapp_basicauth_opts = [ cfg.StrOpt('netapp_login', diff --git a/cinder/volume/drivers/nexenta/options.py b/cinder/volume/drivers/nexenta/options.py index 34ab993e1..9f72bb041 100644 --- a/cinder/volume/drivers/nexenta/options.py +++ b/cinder/volume/drivers/nexenta/options.py @@ -33,6 +33,7 @@ NEXENTA_CONNECTION_OPTIONS = [ help='HTTP port to connect to Nexenta REST API server'), cfg.StrOpt('nexenta_rest_protocol', default='auto', + choices=['http', 'https', 'auto'], help='Use http or https for REST connection (default auto)'), cfg.StrOpt('nexenta_user', default='admin', @@ -73,6 +74,7 @@ NEXENTA_NFS_OPTIONS = [ 'which takes a long time.'), cfg.StrOpt('nexenta_volume_compression', default='on', + choices=['on', 'off'], help='Default compression value for new ZFS folders.'), cfg.BoolOpt('nexenta_nms_cache_volroot', default=True, diff --git a/cinder/volume/drivers/smbfs.py b/cinder/volume/drivers/smbfs.py index 4509fb541..4c4a3ea2a 100644 --- a/cinder/volume/drivers/smbfs.py +++ b/cinder/volume/drivers/smbfs.py @@ -39,9 +39,9 @@ volume_opts = [ help='File with the list of available smbfs shares.'), cfg.StrOpt('smbfs_default_volume_format', default='qcow2', + choices=['raw', 'qcow2', 'vhd', 'vhdx'], help=('Default format that will be used when creating volumes ' - 'if no volume format is specified. Can be set to: ' - 'raw, qcow2, vhd or vhdx.')), + 'if no volume format is specified.')), cfg.BoolOpt('smbfs_sparsed_volumes', default=True, help=('Create volumes as sparsed files which take no space ' diff --git a/cinder/volume/drivers/zfssa/zfssaiscsi.py b/cinder/volume/drivers/zfssa/zfssaiscsi.py index 92a6913de..34c073e6a 100644 --- a/cinder/volume/drivers/zfssa/zfssaiscsi.py +++ b/cinder/volume/drivers/zfssa/zfssaiscsi.py @@ -37,13 +37,17 @@ ZFSSA_OPTS = [ cfg.StrOpt('zfssa_project', help='Project name.'), cfg.StrOpt('zfssa_lun_volblocksize', default='8k', - help='Block size: 512, 1k, 2k, 4k, 8k, 16k, 32k, 64k, 128k.'), + choices=['512', '1k', '2k', '4k', '8k', '16k', '32k', '64k', + '128k'], + help='Block size.'), cfg.BoolOpt('zfssa_lun_sparse', default=False, help='Flag to enable sparse (thin-provisioned): True, False.'), - cfg.StrOpt('zfssa_lun_compression', default='', - help='Data compression-off, lzjb, gzip-2, gzip, gzip-9.'), - cfg.StrOpt('zfssa_lun_logbias', default='', - help='Synchronous write bias-latency, throughput.'), + cfg.StrOpt('zfssa_lun_compression', default='off', + choices=['off', 'lzjb', 'gzip-2', 'gzip', 'gzip-9'], + help='Data compression.'), + cfg.StrOpt('zfssa_lun_logbias', default='latency', + choices=['latency', 'throughput'], + help='Synchronous write bias.'), cfg.StrOpt('zfssa_initiator_group', default='', help='iSCSI initiator group.'), cfg.StrOpt('zfssa_initiator', default='', diff --git a/cinder/volume/drivers/zfssa/zfssanfs.py b/cinder/volume/drivers/zfssa/zfssanfs.py index 7dba43401..c9a393258 100644 --- a/cinder/volume/drivers/zfssa/zfssanfs.py +++ b/cinder/volume/drivers/zfssa/zfssanfs.py @@ -44,8 +44,10 @@ ZFSSA_OPTS = [ cfg.StrOpt('zfssa_nfs_share', default='nfs_share', help='Share name.'), cfg.StrOpt('zfssa_nfs_share_compression', default='off', - help='Data compression-off, lzjb, gzip-2, gzip, gzip-9.'), + choices=['off', 'lzjb', 'gzip-2', 'gzip', 'gzip-9'], + help='Data compression.'), cfg.StrOpt('zfssa_nfs_share_logbias', default='latency', + choices=['latency', 'throughput'], help='Synchronous write bias-latency, throughput.'), cfg.IntOpt('zfssa_rest_timeout', help='REST connection timeout. (seconds)')