from lxml import etree
from oslo.config import cfg
+import six
import six.moves.urllib.parse as urlparse
import webob
self.stubs.Set(volume_api.API, 'get', stubs.stub_volume_get)
req = fakes.HTTPRequest.blank('/v2/volumes/1')
- self.assertRaises(webob.exc.HTTPBadRequest,
- self.controller.delete,
- req, 1)
+ exp = self.assertRaises(webob.exc.HTTPBadRequest,
+ self.controller.delete,
+ req, 1)
+ expect_msg = "Volume cannot be deleted while in attached state"
+ self.assertEqual(expect_msg, six.text_type(exp))
def test_volume_delete_no_volume(self):
self.stubs.Set(volume_api.API, "get", stubs.stub_volume_get_notfound)
volume_utils.notify_about_volume_usage(context,
volume, "delete.end")
return
+ if volume['attach_status'] == "attached":
+ # Volume is still attached, need to detach first
+ raise exception.VolumeAttached(volume_id=volume_id)
+
if not force and volume['status'] not in ["available", "error",
"error_restoring",
"error_extending"]:
"but current status is: %s") % volume['status']
raise exception.InvalidVolume(reason=msg)
- if volume['attach_status'] == "attached":
- # Volume is still attached, need to detach first
- raise exception.VolumeAttached(volume_id=volume_id)
-
if volume['migration_status'] is not None:
# Volume is migrating, wait until done
msg = _("Volume cannot be deleted while migrating")