diff --git a/cinder/tests/unit/test_storwize_svc.py b/cinder/tests/unit/test_storwize_svc.py index 73c01670716..8bf592aab0e 100644 --- a/cinder/tests/unit/test_storwize_svc.py +++ b/cinder/tests/unit/test_storwize_svc.py @@ -223,6 +223,7 @@ class StorwizeSVCManagementSimulator(object): 'compressed', 'force', 'nohdr', + 'nofmtdisk' ] one_param_args = [ 'chapsecret', @@ -622,6 +623,7 @@ port_speed!N/A volume_info['easy_tier'] = 'off' if 'rsize' in kwargs: + volume_info['formatted'] = 'no' # Fake numbers volume_info['used_capacity'] = '786432' volume_info['real_capacity'] = '21474816' @@ -650,6 +652,10 @@ port_speed!N/A volume_info['autoexpand'] = '' volume_info['grainsize'] = '' volume_info['compressed_copy'] = 'no' + volume_info['formatted'] = 'yes' + if 'nofmtdisk' in kwargs: + if kwargs['nofmtdisk']: + volume_info['formatted'] = 'no' vol_cp = {'id': '0', 'status': 'online', @@ -778,7 +784,7 @@ port_speed!N/A rows.append(['IO_group_name', vol['IO_group_name']]) rows.append(['status', 'online']) rows.append(['capacity', cap]) - rows.append(['formatted', 'no']) + rows.append(['formatted', vol['formatted']]) rows.append(['mdisk_id', '']) rows.append(['mdisk_name', '']) rows.append(['FC_id', fcmap_info['fc_id']]) @@ -1840,6 +1846,12 @@ class StorwizeSVCDriverTestCase(test.TestCase): self.driver.check_for_setup_error) self._reset_flags() + self._set_flag('storwize_svc_vol_rsize', 2) + self._set_flag('storwize_svc_vol_nofmtdisk', True) + self.assertRaises(exception.InvalidInput, + self.driver.check_for_setup_error) + self._reset_flags() + self._set_flag('storwize_svc_connection_protocol', 'foo') self.assertRaises(exception.InvalidInput, self.driver.check_for_setup_error) @@ -1940,7 +1952,8 @@ class StorwizeSVCDriverTestCase(test.TestCase): 'iogrp': 0, 'qos': None, 'replication': False, - 'stretched_cluster': None} + 'stretched_cluster': None, + 'nofmtdisk': False} return opt @mock.patch.object(helpers.StorwizeHelpers, 'add_vdisk_qos') @@ -2186,12 +2199,21 @@ class StorwizeSVCDriverTestCase(test.TestCase): # easytier False 2 # iogrp 0 1 # iogrp 1 2 + # nofmtdisk False 1 + # nofmtdisk True 1 opts_list = [] chck_list = [] opts_list.append({'rsize': -1, 'easytier': True, 'iogrp': 0}) chck_list.append({'free_capacity': '0', 'easy_tier': 'on', 'IO_group_id': '0'}) + + opts_list.append({'rsize': -1, 'nofmtdisk': False}) + chck_list.append({'formatted': 'yes'}) + + opts_list.append({'rsize': -1, 'nofmtdisk': True}) + chck_list.append({'formatted': 'no'}) + test_iogrp = 1 if self.USESIM else 0 opts_list.append({'rsize': 2, 'compression': False, 'warning': 0, 'autoexpand': True, 'grainsize': 32, diff --git a/cinder/volume/drivers/ibm/storwize_svc/__init__.py b/cinder/volume/drivers/ibm/storwize_svc/__init__.py index cf400ec4288..e33c62aef12 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/__init__.py +++ b/cinder/volume/drivers/ibm/storwize_svc/__init__.py @@ -124,6 +124,10 @@ storwize_svc_opts = [ help='If operating in stretched cluster mode, specify the ' 'name of the pool in which mirrored copies are stored.' 'Example: "pool2"'), + cfg.BoolOpt('storwize_svc_vol_nofmtdisk', + default=False, + help='Specifies that the volume not be formatted during ' + 'creation.'), ] CONF = cfg.CONF diff --git a/cinder/volume/drivers/ibm/storwize_svc/helpers.py b/cinder/volume/drivers/ibm/storwize_svc/helpers.py index 79326ccfe7c..deef1fbf60d 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/helpers.py +++ b/cinder/volume/drivers/ibm/storwize_svc/helpers.py @@ -399,7 +399,8 @@ class StorwizeHelpers(object): 'iogrp': config.storwize_svc_vol_iogrp, 'qos': None, 'stretched_cluster': cluster_partner, - 'replication': False} + 'replication': False, + 'nofmtdisk': config.storwize_svc_vol_nofmtdisk} return opt @staticmethod @@ -439,6 +440,11 @@ class StorwizeHelpers(object): % {'iogrp': opts['iogrp'], 'avail': avail_grps}) + if opts['nofmtdisk'] and opts['rsize'] != -1: + raise exception.InvalidInput( + reason=_('If nofmtdisk is set to True, rsize must ' + 'also be set to -1.')) + def _get_opts_from_specs(self, opts, specs): qos = {} for k, value in specs.items(): @@ -594,9 +600,10 @@ class StorwizeHelpers(object): @staticmethod def _get_vdisk_create_params(opts): easytier = 'on' if opts['easytier'] else 'off' - if opts['rsize'] == -1: params = [] + if opts['nofmtdisk']: + params.append('-nofmtdisk') else: params = ['-rsize', '%s%%' % str(opts['rsize']), '-autoexpand', '-warning',