Merge "FlashSystems: permit snapshot/clone volumes larger than source"
This commit is contained in:
commit
b883221c98
@ -1040,12 +1040,15 @@ class FlashSystemDriverTestCase(test.TestCase):
|
|||||||
vol2 = self._generate_vol_info(None)
|
vol2 = self._generate_vol_info(None)
|
||||||
self.driver.create_cloned_volume(vol2, vol1)
|
self.driver.create_cloned_volume(vol2, vol1)
|
||||||
|
|
||||||
# case 2: when size does not match
|
# case 2: destination larger than source
|
||||||
vol1 = self._generate_vol_info(None, vol_size=10)
|
vol1 = self._generate_vol_info(None, vol_size=10)
|
||||||
vol2 = self._generate_vol_info(None, vol_size=20)
|
vol2 = self._generate_vol_info(None, vol_size=20)
|
||||||
|
self.driver.create_cloned_volume(vol2, vol1)
|
||||||
|
|
||||||
|
# case 3: destination smaller than source
|
||||||
self.assertRaises(exception.VolumeDriverException,
|
self.assertRaises(exception.VolumeDriverException,
|
||||||
self.driver.create_cloned_volume,
|
self.driver.create_cloned_volume,
|
||||||
vol2, vol1)
|
vol1, vol2)
|
||||||
|
|
||||||
def test_flashsystem_get_volume_stats(self):
|
def test_flashsystem_get_volume_stats(self):
|
||||||
# case 1: good path
|
# case 1: good path
|
||||||
|
@ -266,14 +266,17 @@ class FlashSystemDriver(san.SanDriver,
|
|||||||
{'src': src_vdisk_name, 'dest': dest_vdisk_name})
|
{'src': src_vdisk_name, 'dest': dest_vdisk_name})
|
||||||
|
|
||||||
def _create_and_copy_vdisk_data(self, src_vdisk_name, src_vdisk_id,
|
def _create_and_copy_vdisk_data(self, src_vdisk_name, src_vdisk_id,
|
||||||
dest_vdisk_name, dest_vdisk_id):
|
dest_vdisk_name, dest_vdisk_id,
|
||||||
|
dest_vdisk_size=None):
|
||||||
|
if dest_vdisk_size is None:
|
||||||
vdisk_attr = self._get_vdisk_attributes(src_vdisk_name)
|
vdisk_attr = self._get_vdisk_attributes(src_vdisk_name)
|
||||||
self._driver_assert(
|
self._driver_assert(
|
||||||
vdisk_attr is not None,
|
vdisk_attr is not None,
|
||||||
(_('_create_and_copy_vdisk_data: Failed to get attributes for '
|
(_('_create_and_copy_vdisk_data: Failed to get attributes for '
|
||||||
'vdisk %s.') % src_vdisk_name))
|
'vdisk %s.') % src_vdisk_name))
|
||||||
|
dest_vdisk_size = vdisk_attr['capacity']
|
||||||
|
|
||||||
self._create_vdisk(dest_vdisk_name, vdisk_attr['capacity'], 'b', None)
|
self._create_vdisk(dest_vdisk_name, dest_vdisk_size, 'b', None)
|
||||||
|
|
||||||
# create a timer to lock vdisk that will be used to data copy
|
# create a timer to lock vdisk that will be used to data copy
|
||||||
timer = loopingcall.FixedIntervalLoopingCall(
|
timer = loopingcall.FixedIntervalLoopingCall(
|
||||||
@ -299,7 +302,7 @@ class FlashSystemDriver(san.SanDriver,
|
|||||||
ssh_cmd = ['svctask', 'mkvdisk', '-name', name, '-mdiskgrp',
|
ssh_cmd = ['svctask', 'mkvdisk', '-name', name, '-mdiskgrp',
|
||||||
FLASHSYSTEM_VOLPOOL_NAME, '-iogrp',
|
FLASHSYSTEM_VOLPOOL_NAME, '-iogrp',
|
||||||
six.text_type(FLASHSYSTEM_VOL_IOGRP),
|
six.text_type(FLASHSYSTEM_VOL_IOGRP),
|
||||||
'-size', size, '-unit', unit]
|
'-size', six.text_type(size), '-unit', unit]
|
||||||
out, err = self._ssh(ssh_cmd)
|
out, err = self._ssh(ssh_cmd)
|
||||||
self._assert_ssh_return(out.strip(), '_create_vdisk',
|
self._assert_ssh_return(out.strip(), '_create_vdisk',
|
||||||
ssh_cmd, out, err)
|
ssh_cmd, out, err)
|
||||||
@ -1129,9 +1132,9 @@ class FlashSystemDriver(san.SanDriver,
|
|||||||
'enter: create_volume_from_snapshot: create %(vol)s from '
|
'enter: create_volume_from_snapshot: create %(vol)s from '
|
||||||
'%(snap)s.', {'vol': volume['name'], 'snap': snapshot['name']})
|
'%(snap)s.', {'vol': volume['name'], 'snap': snapshot['name']})
|
||||||
|
|
||||||
if volume['size'] != snapshot['volume_size']:
|
if volume['size'] < snapshot['volume_size']:
|
||||||
msg = _('create_volume_from_snapshot: Volume size is different '
|
msg = _('create_volume_from_snapshot: Volume is smaller than '
|
||||||
'from snapshot based volume.')
|
'snapshot.')
|
||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
raise exception.VolumeDriverException(message=msg)
|
raise exception.VolumeDriverException(message=msg)
|
||||||
|
|
||||||
@ -1142,10 +1145,13 @@ class FlashSystemDriver(san.SanDriver,
|
|||||||
'The invalid status is: %s.') % status)
|
'The invalid status is: %s.') % status)
|
||||||
raise exception.InvalidSnapshot(msg)
|
raise exception.InvalidSnapshot(msg)
|
||||||
|
|
||||||
self._create_and_copy_vdisk_data(snapshot['name'],
|
self._create_and_copy_vdisk_data(
|
||||||
|
snapshot['name'],
|
||||||
snapshot['id'],
|
snapshot['id'],
|
||||||
volume['name'],
|
volume['name'],
|
||||||
volume['id'])
|
volume['id'],
|
||||||
|
dest_vdisk_size=volume['size'] * units.Gi
|
||||||
|
)
|
||||||
|
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
'leave: create_volume_from_snapshot: create %(vol)s from '
|
'leave: create_volume_from_snapshot: create %(vol)s from '
|
||||||
@ -1157,16 +1163,19 @@ class FlashSystemDriver(san.SanDriver,
|
|||||||
LOG.debug('enter: create_cloned_volume: create %(vol)s from %(src)s.',
|
LOG.debug('enter: create_cloned_volume: create %(vol)s from %(src)s.',
|
||||||
{'src': src_volume['name'], 'vol': volume['name']})
|
{'src': src_volume['name'], 'vol': volume['name']})
|
||||||
|
|
||||||
if src_volume['size'] != volume['size']:
|
if src_volume['size'] > volume['size']:
|
||||||
msg = _('create_cloned_volume: Source and destination '
|
msg = _('create_cloned_volume: Source volume larger than '
|
||||||
'size differ.')
|
'destination volume')
|
||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
raise exception.VolumeDriverException(message=msg)
|
raise exception.VolumeDriverException(message=msg)
|
||||||
|
|
||||||
self._create_and_copy_vdisk_data(src_volume['name'],
|
self._create_and_copy_vdisk_data(
|
||||||
|
src_volume['name'],
|
||||||
src_volume['id'],
|
src_volume['id'],
|
||||||
volume['name'],
|
volume['name'],
|
||||||
volume['id'])
|
volume['id'],
|
||||||
|
dest_vdisk_size=volume['size'] * units.Gi
|
||||||
|
)
|
||||||
|
|
||||||
LOG.debug('leave: create_cloned_volume: create %(vol)s from %(src)s.',
|
LOG.debug('leave: create_cloned_volume: create %(vol)s from %(src)s.',
|
||||||
{'src': src_volume['name'], 'vol': volume['name']})
|
{'src': src_volume['name'], 'vol': volume['name']})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user