Merge "Fix begin_detach logic"
This commit is contained in:
commit
8a67386c24
|
@ -2199,6 +2199,14 @@ class VolumeTestCase(BaseVolumeTestCase):
|
|||
volume = tests_utils.create_volume(self.context, **self.volume_params)
|
||||
self.assertRaises(exception.InvalidVolume, volume_api.begin_detaching,
|
||||
self.context, volume)
|
||||
volume['status'] = "in-use"
|
||||
volume['attach_status'] = "detached"
|
||||
# Should raise an error since not attached
|
||||
self.assertRaises(exception.InvalidVolume, volume_api.begin_detaching,
|
||||
self.context, volume)
|
||||
volume['attach_status'] = "attached"
|
||||
# Ensure when attached no exception raised
|
||||
volume_api.begin_detaching(self.context, volume)
|
||||
|
||||
def test_begin_roll_detaching_volume(self):
|
||||
"""Test begin_detaching and roll_detaching functions."""
|
||||
|
|
|
@ -392,10 +392,10 @@ class API(base.Base):
|
|||
if volume['migration_status']:
|
||||
return
|
||||
|
||||
if (volume['status'] != 'in-use' and
|
||||
if (volume['status'] != 'in-use' or
|
||||
volume['attach_status'] != 'attached'):
|
||||
msg = (_("Unable to detach volume. Volume status must be 'in-use' "
|
||||
"and attached_status must be 'attached' to detach. "
|
||||
"and attach_status must be 'attached' to detach. "
|
||||
"Currently: status: '%(status)s', "
|
||||
"attach_status: '%(attach_status)s'") %
|
||||
{'status': volume['status'],
|
||||
|
|
Loading…
Reference in New Issue