api: Handle invalid volume UUIDs during spawn
If a user requests an invalid volume UUID when creating an instance, a 'VolumeNotFound' exception will be raised. This is not currently handled. Correct this. Change-Id: I6137dc1b6b51321fee1c080bf4b85197b19bf223 Signed-off-by: Stephen Finucane <stephenfin@redhat.com> Closes-Bug: #1930448
This commit is contained in:
parent
eca7606251
commit
9cdecc81fb
|
@ -731,6 +731,7 @@ class ServersController(wsgi.Controller):
|
|||
exception.FlavorNotFound,
|
||||
exception.InvalidMetadata,
|
||||
exception.InvalidVolume,
|
||||
exception.VolumeNotFound,
|
||||
exception.MismatchVolumeAZException,
|
||||
exception.MultiplePortsNotApplicable,
|
||||
exception.InvalidFixedIpAndMaxCountRequest,
|
||||
|
|
|
@ -6957,6 +6957,14 @@ class ServersControllerCreateTestWithMock(test.TestCase):
|
|||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self._test_create_extra, {})
|
||||
|
||||
@mock.patch.object(
|
||||
compute_api.API, 'create',
|
||||
side_effect=exception.VolumeNotFound(volume_id='foo'))
|
||||
def test_create_instance_with_volume_not_found_error(self, create_mock):
|
||||
# Tests that InvalidVolume is translated to a 400 error.
|
||||
self.assertRaises(
|
||||
webob.exc.HTTPBadRequest, self._test_create_extra, {})
|
||||
|
||||
|
||||
class ServersViewBuilderTest(test.TestCase):
|
||||
project_id = fakes.FAKE_PROJECT_ID
|
||||
|
|
Loading…
Reference in New Issue