Updating instance_fcp_map correctly when boot-from-volume fails
When boot-from-volume fails, its instance_fcp_map should be updated correctly. Unfortunately, current code is wrong and will lead to an error raised. Change-Id: I7aa65d551b435e0600a40e652478a1fb775d5ca1
This commit is contained in:
parent
680bec4226
commit
551d81809b
|
@ -3091,6 +3091,32 @@ class SVCDriverTestCase(ZVMTestCase):
|
||||||
|
|
||||||
self.driver._fcp_pool = {}
|
self.driver._fcp_pool = {}
|
||||||
|
|
||||||
|
def test_update_instance_fcp_map_force_remove(self):
|
||||||
|
fcp1 = self.driver.FCP([])
|
||||||
|
self.driver._fcp_pool = {'0001': fcp1}
|
||||||
|
fcp_list = ['0001']
|
||||||
|
self.driver._instance_fcp_map = {'inst1': {'fcp_list': ['0001'],
|
||||||
|
'count': 2}}
|
||||||
|
fcp1.set_in_use()
|
||||||
|
|
||||||
|
self.driver._update_instance_fcp_map('inst1', fcp_list,
|
||||||
|
self.driver._FORCE_REMOVE)
|
||||||
|
self.assertEqual({}, self.driver._instance_fcp_map)
|
||||||
|
self.assertFalse(fcp1.is_in_use())
|
||||||
|
self.assertFalse(fcp1.is_reserved())
|
||||||
|
|
||||||
|
self.driver._instance_fcp_map = {'inst1': {'fcp_list': ['0001'],
|
||||||
|
'count': 0}}
|
||||||
|
fcp1.set_in_use()
|
||||||
|
|
||||||
|
self.driver._update_instance_fcp_map('inst1', fcp_list,
|
||||||
|
self.driver._FORCE_REMOVE)
|
||||||
|
self.assertEqual({}, self.driver._instance_fcp_map)
|
||||||
|
self.assertFalse(fcp1.is_in_use())
|
||||||
|
self.assertFalse(fcp1.is_reserved())
|
||||||
|
|
||||||
|
self.driver._fcp_pool = {}
|
||||||
|
|
||||||
def test_update_instance_fcp_map_unknown_action(self):
|
def test_update_instance_fcp_map_unknown_action(self):
|
||||||
self.assertRaises(exception.ZVMVolumeError,
|
self.assertRaises(exception.ZVMVolumeError,
|
||||||
self.driver._update_instance_fcp_map,
|
self.driver._update_instance_fcp_map,
|
||||||
|
|
|
@ -326,6 +326,7 @@ class SVCDriver(DriverAPI):
|
||||||
_INCREASE = 1
|
_INCREASE = 1
|
||||||
_DECREASE = 2
|
_DECREASE = 2
|
||||||
_REMOVE = 3
|
_REMOVE = 3
|
||||||
|
_FORCE_REMOVE = 4
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._xcat_url = zvmutils.get_xcat_url()
|
self._xcat_url = zvmutils.get_xcat_url()
|
||||||
|
@ -552,6 +553,13 @@ class SVCDriver(DriverAPI):
|
||||||
'fcp_list': fcp_list}
|
'fcp_list': fcp_list}
|
||||||
raise exception.ZVMVolumeError(msg=errmsg)
|
raise exception.ZVMVolumeError(msg=errmsg)
|
||||||
|
|
||||||
|
elif action == self._FORCE_REMOVE:
|
||||||
|
if instance_name in self._instance_fcp_map:
|
||||||
|
for fcp_no in fcp_list:
|
||||||
|
fcp = self._fcp_pool.get(fcp_no)
|
||||||
|
fcp.release_device()
|
||||||
|
self._instance_fcp_map.pop(instance_name)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
errmsg = _("Unrecognized option: %s") % action
|
errmsg = _("Unrecognized option: %s") % action
|
||||||
raise exception.ZVMVolumeError(msg=errmsg)
|
raise exception.ZVMVolumeError(msg=errmsg)
|
||||||
|
@ -899,8 +907,8 @@ class SVCDriver(DriverAPI):
|
||||||
self._attach_device(instance['name'], fcp)
|
self._attach_device(instance['name'], fcp)
|
||||||
|
|
||||||
def volume_boot_cleanup(self, instance, fcp):
|
def volume_boot_cleanup(self, instance, fcp):
|
||||||
self._update_instance_fcp_map_if_unlocked(instance['name'],
|
self._update_instance_fcp_map_if_unlocked(instance['name'], [fcp],
|
||||||
[fcp], self._DECREASE)
|
self._FORCE_REMOVE)
|
||||||
self._detach_device(instance['name'], fcp)
|
self._detach_device(instance['name'], fcp)
|
||||||
|
|
||||||
def _expand_fcp_list(self, fcp_list):
|
def _expand_fcp_list(self, fcp_list):
|
||||||
|
|
Loading…
Reference in New Issue