]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Use min and max on IntOpt option types
authorEric Brown <browne@vmware.com>
Sat, 15 Aug 2015 18:36:33 +0000 (11:36 -0700)
committerEric Brown <browne@vmware.com>
Sun, 16 Aug 2015 22:48:24 +0000 (15:48 -0700)
Latest version of oslo.config support the ability to set valid
range on IntOpt option values.  This path makes use of that feature
for a number of options with well known minimum and maximum values.

Change-Id: Ie4b081bdaa373c9dedf7dd0c9884553ffb42b61c

13 files changed:
cinder/common/config.py
cinder/service.py
cinder/tests/unit/test_storwize_svc.py
cinder/volume/driver.py
cinder/volume/drivers/dell/dell_storagecenter_common.py
cinder/volume/drivers/ibm/storwize_svc/__init__.py
cinder/volume/drivers/ibm/storwize_svc/helpers.py
cinder/volume/drivers/prophetstor/options.py
cinder/volume/drivers/remotefs.py
cinder/volume/drivers/san/san.py
cinder/volume/drivers/solidfire.py
cinder/zonemanager/drivers/brocade/brcd_fabric_opts.py
cinder/zonemanager/drivers/cisco/cisco_fabric_opts.py

index 161d6368bc1a93b62bdbc6f57346ff712007f9ec..594fefb078c341632d9d64ff2104e485f0c093d3 100644 (file)
@@ -61,6 +61,7 @@ global_opts = [
                help='Default glance host name or IP'),
     cfg.IntOpt('glance_port',
                default=9292,
+               min=1, max=65535,
                help='Default glance port'),
     cfg.ListOpt('glance_api_servers',
                 default=['$glance_host:$glance_port'],
index 01f929edee903460ef11b5be18666a84757a0a36..54eadb66ce4604cf717e74a71461ec4ed1de3c19 100644 (file)
@@ -64,6 +64,7 @@ service_opts = [
                help='IP address on which OpenStack Volume API listens'),
     cfg.IntOpt('osapi_volume_listen_port',
                default=8776,
+               min=1, max=65535,
                help='Port on which OpenStack Volume API listens'),
     cfg.IntOpt('osapi_volume_workers',
                help='Number of workers for OpenStack Volume API service. '
index b812bcd287f0a69fda71dfc1e067ce46aef9ec0d..fd25fdaa2b958c05970025b8d0ed6286a2a00bd4 100644 (file)
@@ -1787,26 +1787,11 @@ class StorwizeSVCDriverTestCase(test.TestCase):
                           self.driver.check_for_setup_error)
         self._reset_flags()
 
-        self._set_flag('storwize_svc_vol_rsize', 101)
-        self.assertRaises(exception.InvalidInput,
-                          self.driver.check_for_setup_error)
-        self._reset_flags()
-
-        self._set_flag('storwize_svc_vol_warning', 101)
-        self.assertRaises(exception.InvalidInput,
-                          self.driver.check_for_setup_error)
-        self._reset_flags()
-
         self._set_flag('storwize_svc_vol_grainsize', 42)
         self.assertRaises(exception.InvalidInput,
                           self.driver.check_for_setup_error)
         self._reset_flags()
 
-        self._set_flag('storwize_svc_flashcopy_timeout', 601)
-        self.assertRaises(exception.InvalidInput,
-                          self.driver.check_for_setup_error)
-        self._reset_flags()
-
         self._set_flag('storwize_svc_vol_compression', True)
         self._set_flag('storwize_svc_vol_rsize', -1)
         self.assertRaises(exception.InvalidInput,
index 9d9a91663c72c0d5bcec45111a0092fb43101f99..ba2fe05639061e8d2384b9dfd6bc6e01c24d9855 100644 (file)
@@ -47,6 +47,7 @@ volume_opts = [
                help='Number of times to attempt to run flakey shell commands'),
     cfg.IntOpt('reserved_percentage',
                default=0,
+               min=0, max=100,
                help='The percentage of backend capacity is reserved'),
     cfg.IntOpt('iscsi_num_targets',
                default=None,
@@ -63,6 +64,7 @@ volume_opts = [
                 help='The list of secondary IP addresses of the iSCSI daemon'),
     cfg.IntOpt('iscsi_port',
                default=3260,
+               min=1, max=65535,
                help='The port that the iSCSI daemon is listening on'),
     cfg.IntOpt('num_volume_device_scan_tries',
                default=3,
@@ -240,6 +242,7 @@ iser_opts = [
                help='The IP address that the iSER daemon is listening on'),
     cfg.IntOpt('iser_port',
                default=3260,
+               min=1, max=65535,
                help='The port that the iSER daemon is listening on'),
     cfg.StrOpt('iser_helper',
                default='tgtadm',
index c8741cab53193afa7d5a70ef3833ca3caec2c633..c937ff5d2be08db8670b8a4f75b126f35c461811 100644 (file)
@@ -31,6 +31,7 @@ common_opts = [
                help='Storage Center System Serial Number'),
     cfg.IntOpt('dell_sc_api_port',
                default=3033,
+               min=1, max=65535,
                help='Dell API port'),
     cfg.StrOpt('dell_sc_server_folder',
                default='openstack',
index a1a8620fae7c7679d9d30e63608e502d3c92e133..805af3f6c5ff593547cc4777151a9350fd3b9820 100644 (file)
@@ -63,10 +63,12 @@ storwize_svc_opts = [
                help='Storage system storage pool for volumes'),
     cfg.IntOpt('storwize_svc_vol_rsize',
                default=2,
+               min=-1, max=100,
                help='Storage system space-efficiency parameter for volumes '
                     '(percentage)'),
     cfg.IntOpt('storwize_svc_vol_warning',
                default=0,
+               min=-1, max=100,
                help='Storage system threshold for volume capacity warnings '
                     '(percentage)'),
     cfg.BoolOpt('storwize_svc_vol_autoexpand',
@@ -88,8 +90,9 @@ storwize_svc_opts = [
                help='The I/O group in which to allocate volumes'),
     cfg.IntOpt('storwize_svc_flashcopy_timeout',
                default=120,
+               min=1, max=600,
                help='Maximum number of seconds to wait for FlashCopy to be '
-                    'prepared. Maximum value is 600 seconds (10 minutes)'),
+                    'prepared.'),
     cfg.StrOpt('storwize_svc_connection_protocol',
                default='iSCSI',
                help='Connection protocol (iSCSI/FC)'),
@@ -289,15 +292,6 @@ class StorwizeSVCDriver(san.SanDriver,
                          'authentication: set either san_password or '
                          'san_private_key option.'))
 
-        # Check that flashcopy_timeout is not more than 10 minutes
-        flashcopy_timeout = self.configuration.storwize_svc_flashcopy_timeout
-        if not (flashcopy_timeout > 0 and flashcopy_timeout <= 600):
-            raise exception.InvalidInput(
-                reason=_('Illegal value %d specified for '
-                         'storwize_svc_flashcopy_timeout: '
-                         'valid values are between 0 and 600.')
-                % flashcopy_timeout)
-
         opts = self._helpers.build_default_opts(self.configuration)
         self._helpers.check_vdisk_opts(self._state, opts)
 
index 109790d0c086031559f09e740db7251400562a99..762229457db0da4d2510a960021798f32381ecf1 100644 (file)
@@ -403,19 +403,6 @@ class StorwizeHelpers(object):
 
     @staticmethod
     def check_vdisk_opts(state, opts):
-        # Check that rsize is either -1 or between 0 and 100
-        if not (opts['rsize'] >= -1 and opts['rsize'] <= 100):
-            raise exception.InvalidInput(
-                reason=_('Illegal value specified for storwize_svc_vol_rsize: '
-                         'set to either a percentage (0-100) or -1.'))
-
-        # Check that warning is either -1 or between 0 and 100
-        if not (opts['warning'] >= -1 and opts['warning'] <= 100):
-            raise exception.InvalidInput(
-                reason=_('Illegal value specified for '
-                         'storwize_svc_vol_warning: '
-                         'set to a percentage (0-100).'))
-
         # Check that grainsize is 32/64/128/256
         if opts['grainsize'] not in [32, 64, 128, 256]:
             raise exception.InvalidInput(
index c9cc3e99260ac4980b821e88f6ead41bef8f0376..ff9768f7fe2eba308f1c4b4651444cb67a55edff 100644 (file)
@@ -23,6 +23,7 @@ DPL_OPTS = [
                help='DPL pool uuid in which DPL volumes are stored.'),
     cfg.IntOpt('dpl_port',
                default=8357,
+               min=1, max=65535,
                help='DPL port number.'),
 ]
 
index c3da55d6263034c9d541724d7a76d83bbcb66904..a357ded8dbc70e7c6800ac633c10a01ce150c656 100644 (file)
@@ -51,6 +51,7 @@ nas_opts = [
                secret=True),
     cfg.IntOpt('nas_ssh_port',
                default=22,
+               min=1, max=65535,
                help='SSH port to use to connect to NAS system.'),
     cfg.StrOpt('nas_private_key',
                default='',
index 6707a0f5416e67a4850272b260842d526f312217..6c6df1cc45c00af0775acbef714b681bfcac3eb2 100644 (file)
@@ -57,6 +57,7 @@ san_opts = [
                help='Cluster name to use for creating volumes'),
     cfg.IntOpt('san_ssh_port',
                default=22,
+               min=1, max=65535,
                help='SSH port to use with SAN'),
     cfg.BoolOpt('san_is_local',
                 default=False,
index 26d68070a3a09289917d583d63f7d86a3e3d050a..c209c088b620ef11e354f92d9becaacf4566fb36 100644 (file)
@@ -70,6 +70,7 @@ sf_opts = [
 
     cfg.IntOpt('sf_api_port',
                default=443,
+               min=1, max=65535,
                help='SolidFire API port. Useful if the device api is behind '
                     'a proxy on a different port.')]
 
index d9792d5dbd4d9a5a386a3b4ab48fc991ec33988a..6c1276ab0255be448dd2f55d38bfed07dbc8dc99 100644 (file)
@@ -33,6 +33,7 @@ brcd_zone_opts = [
                secret=True),
     cfg.IntOpt('fc_fabric_port',
                default=22,
+               min=1, max=65535,
                help='Connecting port'),
     cfg.StrOpt('zoning_policy',
                default='initiator-target',
index ae777ed68502c571e53f73857acc5c0b9d5110af..c105b314158fdaa828bc4123361ed06c1021a907 100644 (file)
@@ -30,6 +30,7 @@ cisco_zone_opts = [
                secret=True),
     cfg.IntOpt('cisco_fc_fabric_port',
                default=22,
+               min=1, max=65535,
                help='Connecting port'),
     cfg.StrOpt('cisco_zoning_policy',
                default='initiator-target',