From: zhangyanzi Date: Mon, 25 Nov 2013 11:13:52 +0000 (+0800) Subject: Remove the redundant judgment for 'restore' X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=9d571d39d7370efd290c6139e74c4884c5f7edbe;p=openstack-build%2Fcinder-build.git Remove the redundant judgment for 'restore' In the function 'restore', there is redundant judgment for the body, it should be removed. Change-Id: Icfc5ae20141fad9d72de227cf5c06ca8504bd22c Closes-Bug: 1254671 --- diff --git a/cinder/api/contrib/backups.py b/cinder/api/contrib/backups.py index e284baa29..07c7e3a03 100644 --- a/cinder/api/contrib/backups.py +++ b/cinder/api/contrib/backups.py @@ -224,15 +224,11 @@ class BackupsController(wsgi.Controller): LOG.debug(_('Restoring backup %(backup_id)s (%(body)s)'), {'backup_id': id, 'body': body}) if not self.is_valid_body(body, 'restore'): - raise exc.HTTPBadRequest() - - context = req.environ['cinder.context'] - - try: - restore = body['restore'] - except KeyError: msg = _("Incorrect request body format") raise exc.HTTPBadRequest(explanation=msg) + + context = req.environ['cinder.context'] + restore = body['restore'] volume_id = restore.get('volume_id', None) LOG.audit(_("Restoring backup %(backup_id)s to volume %(volume_id)s"), diff --git a/cinder/tests/api/contrib/test_backups.py b/cinder/tests/api/contrib/test_backups.py index 0ff300e75..a0474f337 100644 --- a/cinder/tests/api/contrib/test_backups.py +++ b/cinder/tests/api/contrib/test_backups.py @@ -685,8 +685,7 @@ class BackupsAPITestCase(test.TestCase): self.assertEqual(res.status_int, 400) self.assertEqual(res_dict['badRequest']['code'], 400) self.assertEqual(res_dict['badRequest']['message'], - 'The server could not comply with the request since' - ' it is either malformed or otherwise incorrect.') + 'Incorrect request body format') db.backup_destroy(context.get_admin_context(), backup_id) @@ -707,8 +706,7 @@ class BackupsAPITestCase(test.TestCase): self.assertEqual(res.status_int, 400) self.assertEqual(res_dict['badRequest']['code'], 400) self.assertEqual(res_dict['badRequest']['message'], - 'The server could not comply with the request since' - ' it is either malformed or otherwise incorrect.') + 'Incorrect request body format') def test_restore_backup_volume_id_unspecified(self):