From bc73049053e7b94081c8e40e4f53a2255c9a1b97 Mon Sep 17 00:00:00 2001 From: rajinir Date: Thu, 24 Mar 2016 14:54:44 -0500 Subject: [PATCH] Dell Eqlx: Cloning volume does not honor new size If the volume being created was larger than the cloned volume the new volume was not being resized. Change-Id: Id90a6d96a2c86b063d2c9f08877c7999ac069b06 Closes-Bug: 1554744 --- cinder/tests/unit/test_eqlx.py | 33 +++++++++++++++++++++++++++------ cinder/volume/drivers/eqlx.py | 10 ++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/cinder/tests/unit/test_eqlx.py b/cinder/tests/unit/test_eqlx.py index f4e184b60..1125ee582 100644 --- a/cinder/tests/unit/test_eqlx.py +++ b/cinder/tests/unit/test_eqlx.py @@ -162,16 +162,37 @@ class DellEQLSanISCSIDriverTestCase(test.TestCase): self.assertEqual(self._model_update, model_update) def test_create_cloned_volume(self): - src_vref = {'name': 'fake_uuid'} - volume = {'name': self.volume_name} + src_vref = {'name': 'fake_uuid', 'size': '1'} + volume = {'name': self.volume_name, 'size': '1'} mock_attrs = {'args': ['volume', 'select', volume['name'], 'multihost-access', 'enable']} with mock.patch.object(self.driver, '_eql_execute') as mock_eql_execute: - mock_eql_execute.configure_mock(**mock_attrs) - mock_eql_execute.return_value = self.fake_iqn_return - model_update = self.driver.create_cloned_volume(volume, src_vref) - self.assertEqual(self._model_update, model_update) + with mock.patch.object(self.driver, + 'extend_volume') as mock_extend_volume: + mock_eql_execute.configure_mock(**mock_attrs) + mock_eql_execute.return_value = self.fake_iqn_return + mock_extend_volume.return_value = self.fake_iqn_return + model_update = self.driver.create_cloned_volume( + volume, src_vref) + self.assertEqual(self._model_update, model_update) + self.assertFalse(self.driver.extend_volume.called) + + def test_create_cloned_volume_extend(self): + src_vref = {'name': 'fake_uuid', 'size': '100'} + volume = {'name': self.volume_name, 'size': '200'} + mock_attrs = {'args': ['volume', 'select', volume['name'], + 'multihost-access', 'enable']} + with mock.patch.object(self.driver, + '_eql_execute') as mock_eql_execute: + with mock.patch.object(self.driver, + 'extend_volume') as mock_extend_volume: + mock_eql_execute.configure_mock(**mock_attrs) + mock_eql_execute.return_value = self.fake_iqn_return + mock_extend_volume.return_value = self.fake_iqn_return + cloned_vol = self.driver.create_cloned_volume(volume, src_vref) + self.assertEqual(self._model_update, cloned_vol) + self.assertTrue(self.driver.extend_volume.called) def test_delete_snapshot(self): snapshot = {'name': 'fakesnap', 'volume_name': 'fakevolume_name'} diff --git a/cinder/volume/drivers/eqlx.py b/cinder/volume/drivers/eqlx.py index aed59b613..9b5ce94dd 100644 --- a/cinder/volume/drivers/eqlx.py +++ b/cinder/volume/drivers/eqlx.py @@ -490,6 +490,11 @@ class DellEQLSanISCSIDriver(san.SanISCSIDriver): src_volume_name = src_vref['name'] out = self._eql_execute('volume', 'select', src_volume_name, 'clone', volume['name']) + + # Extend Volume if needed + if out and volume['size'] > src_vref['size']: + out = self.extend_volume(out, volume['size']) + self.add_multihost_access(volume) return self._get_volume_data(out) except Exception: @@ -583,6 +588,11 @@ class DellEQLSanISCSIDriver(san.SanISCSIDriver): try: self._eql_execute('volume', 'select', volume['name'], 'size', "%sG" % new_size) + LOG.info(_LI('Volume %(name)s resized from ' + '%(current_size)sGB to %(new_size)sGB.'), + {'name': volume['name'], + 'current_size': volume['size'], + 'new_size': new_size}) except Exception: with excutils.save_and_reraise_exception(): LOG.error(_LE('Failed to extend_volume %(name)s from '