Merge "Handle VolumeBDMIsMultiAttach in os-assisted-volume-snapshots"

This commit is contained in:
Jenkins
2017-03-01 14:46:12 +00:00
committed by Gerrit Code Review
2 changed files with 16 additions and 0 deletions

View File

@@ -54,6 +54,7 @@ class AssistedVolumeSnapshotsController(wsgi.Controller):
return self.compute_api.volume_snapshot_create(context, volume_id,
create_info)
except (exception.VolumeBDMNotFound,
exception.VolumeBDMIsMultiAttach,
exception.InvalidVolume) as error:
raise exc.HTTPBadRequest(explanation=error.format_message())

View File

@@ -781,6 +781,21 @@ class AssistedSnapshotCreateTestCaseV21(test.NoDBTestCase):
self.assertRaises(self.bad_request, self.controller.create,
req, body=body)
@mock.patch('nova.objects.BlockDeviceMapping.get_by_volume',
side_effect=exception.VolumeBDMIsMultiAttach(volume_id='1'))
def test_assisted_create_multiattach_fails(self, bdm_get_by_volume):
# unset the stub on volume_snapshot_create from setUp
self.mox.UnsetStubs()
req = fakes.HTTPRequest.blank('/v2/fake/os-assisted-volume-snapshots')
body = {'snapshot':
{'volume_id': '1',
'create_info': {'type': 'qcow2',
'new_file': 'new_file',
'snapshot_id': 'snapshot_id'}}}
req.method = 'POST'
self.assertRaises(
webob.exc.HTTPBadRequest, self.controller.create, req, body=body)
class AssistedSnapshotDeleteTestCaseV21(test.NoDBTestCase):
assisted_snaps = assisted_snaps_v21