From 525e27331d08b484a8f673ff4ff5efc3e00d8ce9 Mon Sep 17 00:00:00 2001 From: Vipin Balachandran Date: Wed, 1 Jul 2015 12:20:37 +0530 Subject: [PATCH] Raise BadRequest for invalid replication status Raise HTTPBadRequest instead of HTTPNotFound while creating a volume from an existing source replica with invalid replication status 'disabled'. APIImpact Change-Id: If7ac01a9452dca0446088189b658340da538c427 Closes-Bug: #1471694 --- cinder/api/v2/volumes.py | 2 +- cinder/tests/unit/api/v2/test_volumes.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cinder/api/v2/volumes.py b/cinder/api/v2/volumes.py index fd2be7a54..37ebd6a5a 100644 --- a/cinder/api/v2/volumes.py +++ b/cinder/api/v2/volumes.py @@ -385,7 +385,7 @@ class VolumeController(wsgi.Controller): if src_vol['replication_status'] == 'disabled': explanation = _('source volume id:%s is not' ' replicated') % source_volid - raise exc.HTTPNotFound(explanation=explanation) + raise exc.HTTPBadRequest(explanation=explanation) kwargs['source_replica'] = src_vol except exception.VolumeNotFound as error: raise exc.HTTPNotFound(explanation=error.msg) diff --git a/cinder/tests/unit/api/v2/test_volumes.py b/cinder/tests/unit/api/v2/test_volumes.py index e7bdb03b5..360b16b7b 100644 --- a/cinder/tests/unit/api/v2/test_volumes.py +++ b/cinder/tests/unit/api/v2/test_volumes.py @@ -347,8 +347,8 @@ class VolumeApiTest(test.TestCase): vol = self._vol_in_request_body(source_replica=source_replica) body = {"volume": vol} req = fakes.HTTPRequest.blank('/v2/volumes') - # Raise 404 when replication status is disabled. - self.assertRaises(webob.exc.HTTPNotFound, self.controller.create, + # Raise 400 when replication status is disabled. + self.assertRaises(webob.exc.HTTPBadRequest, self.controller.create, req, body) context = req.environ['cinder.context'] -- 2.45.2