Merge "Updating instance_fcp_map correctly when boot-from-volume fails"
This commit is contained in:
commit
cee0d80f1b
|
@ -3028,6 +3028,32 @@ class SVCDriverTestCase(ZVMTestCase):
|
|||
|
||||
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):
|
||||
self.assertRaises(exception.ZVMVolumeError,
|
||||
self.driver._update_instance_fcp_map,
|
||||
|
|
|
@ -326,6 +326,7 @@ class SVCDriver(DriverAPI):
|
|||
_INCREASE = 1
|
||||
_DECREASE = 2
|
||||
_REMOVE = 3
|
||||
_FORCE_REMOVE = 4
|
||||
|
||||
def __init__(self):
|
||||
self._xcat_url = zvmutils.get_xcat_url()
|
||||
|
@ -552,6 +553,13 @@ class SVCDriver(DriverAPI):
|
|||
'fcp_list': fcp_list}
|
||||
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:
|
||||
errmsg = _("Unrecognized option: %s") % action
|
||||
raise exception.ZVMVolumeError(msg=errmsg)
|
||||
|
@ -899,8 +907,8 @@ class SVCDriver(DriverAPI):
|
|||
self._attach_device(instance['name'], fcp)
|
||||
|
||||
def volume_boot_cleanup(self, instance, fcp):
|
||||
self._update_instance_fcp_map_if_unlocked(instance['name'],
|
||||
[fcp], self._DECREASE)
|
||||
self._update_instance_fcp_map_if_unlocked(instance['name'], [fcp],
|
||||
self._FORCE_REMOVE)
|
||||
self._detach_device(instance['name'], fcp)
|
||||
|
||||
def _expand_fcp_list(self, fcp_list):
|
||||
|
|
Loading…
Reference in New Issue