]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Raise BadRequest for invalid replication status
authorVipin Balachandran <vbala@vmware.com>
Wed, 1 Jul 2015 06:50:37 +0000 (12:20 +0530)
committerVipin Balachandran <vbala@vmware.com>
Wed, 15 Jul 2015 09:51:57 +0000 (15:21 +0530)
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
cinder/tests/unit/api/v2/test_volumes.py

index fd2be7a540d44ea6a48110cbdcb8881b0a5a4690..37ebd6a5a53969fe0cdd4708bd19c04d5808ff07 100644 (file)
@@ -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)
index e7bdb03b5bfbe842f3a568f65da15a3a826f4652..360b16b7b564be05a4aa3697181fa151ada15ebd 100644 (file)
@@ -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']