Fix UnBoundLocalError in update_consistencygroup

The existed codes use variables before assignement in
update_consistencygroup. This patch is to fix the problem.

Change-Id: If74d23b9413209ee8db3c58fc71d215abeb580b2
Related-Bug: 1645207
This commit is contained in:
lisali 2016-11-28 07:00:13 +00:00
parent 5b1648d32e
commit 57d257f149
2 changed files with 19 additions and 2 deletions

View File

@ -203,6 +203,23 @@ class ConsistencyGroupTestCase(base.BaseVolumeTestCase):
self.volume.db.volume_get.reset_mock()
self.volume.db.volume_get = volume_get_orig
def test_update_consistencygroup_volume_not_found(self):
group = tests_utils.create_consistencygroup(
self.context,
availability_zone=CONF.storage_availability_zone,
volume_type='type1,type2')
self.assertRaises(exception.VolumeNotFound,
self.volume.update_consistencygroup,
self.context,
group,
fake.VOLUME_ID)
self.assertRaises(exception.VolumeNotFound,
self.volume.update_consistencygroup,
self.context,
group,
None,
fake.VOLUME_ID)
@mock.patch.object(driver.VolumeDriver,
"create_consistencygroup",
return_value={'status': 'available'})

View File

@ -3199,7 +3199,7 @@ class VolumeManager(manager.CleanableManager,
LOG.error(_LE("Update consistency group "
"failed to add volume-%(volume_id)s: "
"VolumeNotFound."),
{'volume_id': add_vol_ref['id']},
{'volume_id': add_vol},
resource={'type': 'consistency_group',
'id': group.id})
raise
@ -3228,7 +3228,7 @@ class VolumeManager(manager.CleanableManager,
LOG.error(_LE("Update consistency group "
"failed to remove volume-%(volume_id)s: "
"VolumeNotFound."),
{'volume_id': remove_vol_ref['id']},
{'volume_id': remove_vol},
resource={'type': 'consistency_group',
'id': group.id})
raise