Merge "Volume extend error does not catch exception"
This commit is contained in:
commit
acd2059084
@ -315,7 +315,11 @@ class VolumeActionsController(wsgi.Controller):
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
size = int(body['os-extend']['new_size'])
|
||||
self.volume_api.extend(context, volume, size)
|
||||
try:
|
||||
self.volume_api.extend(context, volume, size)
|
||||
except exception.InvalidVolume as error:
|
||||
raise webob.exc.HTTPBadRequest(explanation=error.msg)
|
||||
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
@wsgi.action('os-update_readonly_flag')
|
||||
|
@ -343,6 +343,22 @@ class VolumeActionsTest(test.TestCase):
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
self.assertEqual(202, res.status_int)
|
||||
|
||||
def test_extend_volume_invalid_status(self):
|
||||
def fake_extend_volume(*args, **kwargs):
|
||||
msg = "Volume status must be available"
|
||||
raise exception.InvalidVolume(reason=msg)
|
||||
self.stubs.Set(volume.API, 'extend',
|
||||
fake_extend_volume)
|
||||
|
||||
body = {'os-extend': {'new_size': 5}}
|
||||
req = webob.Request.blank('/v2/fake/volumes/1/action')
|
||||
req.method = "POST"
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
self.assertEqual(400, res.status_int)
|
||||
|
||||
def test_update_readonly_flag(self):
|
||||
def fake_update_readonly_flag(*args, **kwargs):
|
||||
return {}
|
||||
|
Loading…
Reference in New Issue
Block a user