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."""
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'],