NEC driver: fix migrate/retype an in-use volume
NEC Storage does not support storage assisted migration and retype
against in-use volumes. In that cases, migrate_volume() and
retype() in NEC driver should return False to try host-assisted
migration or retype. However, the driver currently raises an
exception and the operation fails.
This patch fixes migrate_volume() and retype() to return False without
raising an exception.
Change-Id: I9ceadc200e40126cf121d74d3996e511ba3f66df
Closes-Bug: #1848689
(cherry picked from commit 8cc095d1d0
)
This commit is contained in:
parent
21106e0abc
commit
d08d32914d
|
@ -681,13 +681,6 @@ class VolumeCreateTest(volume_helper.MStorageDSVDriver, test.TestCase):
|
|||
vol.status = 'available'
|
||||
self._validate_migrate_volume(vol, self.xml)
|
||||
|
||||
vol.status = 'creating'
|
||||
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
|
||||
'Specified Logical Disk'
|
||||
' LX:287RbQoP7VdwR1WsPC2fZT'
|
||||
' is not available.'):
|
||||
self._validate_migrate_volume(vol, self.xml)
|
||||
|
||||
vol.id = "AAAAAAAA"
|
||||
vol.status = 'available'
|
||||
with self.assertRaisesRegex(exception.NotFound,
|
||||
|
@ -1404,10 +1397,17 @@ class Migrate_test(volume_helper.MStorageDSVDriver, test.TestCase):
|
|||
|
||||
def test_migrate_volume(self):
|
||||
vol = DummyVolume(constants.VOLUME2_ID)
|
||||
moved, model_update = self.migrate_volume(None, vol,
|
||||
self.host)
|
||||
vol.status = 'available'
|
||||
moved, __ = self.migrate_volume(None, vol,
|
||||
self.host)
|
||||
self.assertTrue(moved)
|
||||
|
||||
vol = DummyVolume(constants.VOLUME2_ID)
|
||||
vol.status = 'in-use'
|
||||
moved, __ = self.migrate_volume(None, vol,
|
||||
self.host)
|
||||
self.assertFalse(moved)
|
||||
|
||||
vol.id = "87d8d42f-7550-4f43-9a2b-fe722bf86941"
|
||||
with self.assertRaisesRegex(exception.NotFound,
|
||||
'Logical Disk `LX:48L3QCi4npuqxPX0Lyeu8H`'
|
||||
|
@ -1416,11 +1416,9 @@ class Migrate_test(volume_helper.MStorageDSVDriver, test.TestCase):
|
|||
|
||||
vol.id = '46045673-41e7-44a7-9333-02f07feab04b'
|
||||
vol.status = 'creating'
|
||||
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
|
||||
'Specified Logical Disk '
|
||||
'LX:287RbQoP7VdwR1WsPC2fZT is '
|
||||
'not available.'):
|
||||
self._validate_migrate_volume(vol, xml_out)
|
||||
moved, __ = self.migrate_volume(None, vol,
|
||||
self.host)
|
||||
self.assertFalse(moved)
|
||||
|
||||
vol.id = "92dbc7f4-dbc3-4a87-aef4-d5a2ada3a9af"
|
||||
vol.status = 'available'
|
||||
|
@ -1468,6 +1466,14 @@ class Migrate_test(volume_helper.MStorageDSVDriver, test.TestCase):
|
|||
retyped = self.retype(None, vol, new_type, diff, self.host)
|
||||
self.assertTrue(retyped)
|
||||
|
||||
vol.attach_status = 'attached'
|
||||
diff = {'encryption': {},
|
||||
'qos_specs': {},
|
||||
'extra_specs': {u'volume_backend_name': (u'Storage1',
|
||||
u'Storage2')}}
|
||||
retyped = self.retype(None, vol, new_type, diff, self.host)
|
||||
self.assertFalse(retyped)
|
||||
|
||||
def test_validate_retype_volume(self):
|
||||
vol = DummyVolume("87d8d42f-7550-4f43-9a2b-fe722bf86941")
|
||||
with self.assertRaisesRegex(exception.NotFound,
|
||||
|
|
|
@ -540,12 +540,6 @@ class MStorageDriver(volume_common.MStorageVolumeCommon):
|
|||
ldname = self._validate_ld_exist(
|
||||
lds, volume.id, self._properties['ld_name_format'])
|
||||
|
||||
# check volume status.
|
||||
if volume.status != 'available':
|
||||
msg = _('Specified Logical Disk %s is not available.') % ldname
|
||||
LOG.error(msg)
|
||||
raise exception.VolumeBackendAPIException(data=msg)
|
||||
|
||||
# check rpl attribute.
|
||||
ld = lds[ldname]
|
||||
if ld['Purpose'] != '---':
|
||||
|
@ -562,7 +556,10 @@ class MStorageDriver(volume_common.MStorageVolumeCommon):
|
|||
'dsthost': host})
|
||||
try:
|
||||
ret = self._migrate_volume(context, volume, host)
|
||||
LOG.info('Migrated Volume (%s)', msgparm)
|
||||
if ret != (False, None):
|
||||
LOG.info('Migrated Volume (%s)', msgparm)
|
||||
else:
|
||||
LOG.debug('Failed to Migrate Volume (%s)', msgparm)
|
||||
return ret
|
||||
except exception.CinderException as e:
|
||||
with excutils.save_and_reraise_exception():
|
||||
|
@ -586,6 +583,11 @@ class MStorageDriver(volume_common.MStorageVolumeCommon):
|
|||
|
||||
false_ret = (False, None)
|
||||
|
||||
# check volume status.
|
||||
if volume.status != 'available':
|
||||
LOG.debug('Specified volume %s is not available.', volume.id)
|
||||
return false_ret
|
||||
|
||||
if 'capabilities' not in host:
|
||||
LOG.debug('Host not in capabilities. Host = %s ', host)
|
||||
return false_ret
|
||||
|
@ -670,7 +672,10 @@ class MStorageDriver(volume_common.MStorageVolumeCommon):
|
|||
'dsthost': host})
|
||||
try:
|
||||
ret = self._retype(context, volume, new_type, diff, host)
|
||||
LOG.info('Retyped Volume (%s)', msgparm)
|
||||
if ret is not False:
|
||||
LOG.info('Retyped Volume (%s)', msgparm)
|
||||
else:
|
||||
LOG.debug('Failed to Retype Volume (%s)', msgparm)
|
||||
return ret
|
||||
except exception.CinderException as e:
|
||||
with excutils.save_and_reraise_exception():
|
||||
|
@ -696,6 +701,11 @@ class MStorageDriver(volume_common.MStorageVolumeCommon):
|
|||
'diff': diff,
|
||||
'host': host})
|
||||
|
||||
# check volume attach status.
|
||||
if volume.attach_status == 'attached':
|
||||
LOG.debug('Specified volume %s is attached.', volume.id)
|
||||
return False
|
||||
|
||||
if self._check_same_backend(diff):
|
||||
ldname = self._convert_id2name(volume)
|
||||
reset = (diff['qos_specs'].get('consumer')[0] == 'back-end')
|
||||
|
@ -775,7 +785,7 @@ class MStorageDriver(volume_common.MStorageVolumeCommon):
|
|||
|
||||
name_id = None
|
||||
provider_location = None
|
||||
if original_volume_status == 'available':
|
||||
if original_volume_status in ['available', 'in-use']:
|
||||
original_name = self._convert_id2name(volume)
|
||||
new_name = self._convert_id2name(new_volume)
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue