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
This commit is contained in:
Vipin Balachandran 2015-07-01 12:20:37 +05:30
parent 348b06adad
commit 525e27331d
2 changed files with 3 additions and 3 deletions

View 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)

View 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']