Skip to content

Commit 9cdecc8

Browse files
committed
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 <[email protected]> Closes-Bug: #1930448
1 parent eca7606 commit 9cdecc8

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

nova/api/openstack/compute/servers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,7 @@ def create(self, req, body):
731731
exception.FlavorNotFound,
732732
exception.InvalidMetadata,
733733
exception.InvalidVolume,
734+
exception.VolumeNotFound,
734735
exception.MismatchVolumeAZException,
735736
exception.MultiplePortsNotApplicable,
736737
exception.InvalidFixedIpAndMaxCountRequest,

nova/tests/unit/api/openstack/compute/test_servers.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6957,6 +6957,14 @@ def test_create_instance_with_invalid_volume_error(self, create_mock):
69576957
self.assertRaises(webob.exc.HTTPBadRequest,
69586958
self._test_create_extra, {})
69596959

6960+
@mock.patch.object(
6961+
compute_api.API, 'create',
6962+
side_effect=exception.VolumeNotFound(volume_id='foo'))
6963+
def test_create_instance_with_volume_not_found_error(self, create_mock):
6964+
# Tests that InvalidVolume is translated to a 400 error.
6965+
self.assertRaises(
6966+
webob.exc.HTTPBadRequest, self._test_create_extra, {})
6967+
69606968

69616969
class ServersViewBuilderTest(test.TestCase):
69626970
project_id = fakes.FAKE_PROJECT_ID

0 commit comments

Comments
 (0)