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
This commit is contained in:
rajinir 2016-03-24 14:54:44 -05:00
parent 0a9943b52a
commit bc73049053
2 changed files with 37 additions and 6 deletions

View File

@ -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:
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
model_update = self.driver.create_cloned_volume(volume, src_vref)
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'}

View File

@ -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 '