lvm: unhandled exception when migrating volume
Catches the StopIteration exception if the destination volume group does not exist when attempting to migrate a volume. Change-Id: I0b5dd15e4c7198fe54abf1aa917a60554adcd568 Closes-Bug: #1277512
This commit is contained in:
parent
0e71f48123
commit
c311e94d3d
|
@ -2685,6 +2685,29 @@ class LVMISCSIVolumeDriverTestCase(DriverTestCase):
|
|||
self.assertEqual(moved, False)
|
||||
self.assertIsNone(model_update)
|
||||
|
||||
def test_lvm_volume_group_missing(self):
|
||||
hostname = socket.gethostname()
|
||||
capabilities = {'location_info': 'LVMVolumeDriver:%s:'
|
||||
'cinder-volumes-3:default:0' % hostname}
|
||||
host = {'capabilities': capabilities}
|
||||
vol = {'name': 'test', 'id': 1, 'size': 1, 'status': 'available'}
|
||||
|
||||
def get_all_volume_groups():
|
||||
return [{'name': 'cinder-volumes-2'}]
|
||||
|
||||
self.stubs.Set(volutils, 'get_all_volume_groups',
|
||||
get_all_volume_groups)
|
||||
|
||||
self.volume.driver.vg = FakeBrickLVM('cinder-volumes',
|
||||
False,
|
||||
None,
|
||||
'default')
|
||||
|
||||
moved, model_update = self.volume.driver.migrate_volume(self.context,
|
||||
vol, host)
|
||||
self.assertEqual(moved, False)
|
||||
self.assertIsNone(model_update)
|
||||
|
||||
def test_lvm_migrate_volume_proceed(self):
|
||||
hostname = socket.gethostname()
|
||||
capabilities = {'location_info': 'LVMVolumeDriver:%s:'
|
||||
|
|
|
@ -693,9 +693,9 @@ class LVMISCSIDriver(LVMVolumeDriver, driver.ISCSIDriver):
|
|||
|
||||
if dest_vg != self.vg.vg_name:
|
||||
vg_list = volutils.get_all_volume_groups()
|
||||
vg_dict = \
|
||||
try:
|
||||
(vg for vg in vg_list if vg['name'] == dest_vg).next()
|
||||
if vg_dict is None:
|
||||
except StopIteration:
|
||||
message = ("Destination Volume Group %s does not exist" %
|
||||
dest_vg)
|
||||
LOG.error(_('%s'), message)
|
||||
|
|
Loading…
Reference in New Issue