From: KIYOHIRO ADACHI Date: Fri, 27 Dec 2013 03:16:37 +0000 (+0900) Subject: Add keyword argument missing at some exc.HTTPError subclass X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=57fd92a3943aa4856de6ceb18a7b704ed7fae7c6;p=openstack-build%2Fcinder-build.git Add keyword argument missing at some exc.HTTPError subclass Some exc.HTTPError subclass needs keyword argument ``explanation``. If there is no ``explanation=``, the message of the argument is recognized as ``detail``. Change-Id: Idfc07b2bd71da31e44212d3296921e18d2024a63 Closes-Bug: #1264424 --- diff --git a/cinder/api/contrib/admin_actions.py b/cinder/api/contrib/admin_actions.py index 15ad489c0..64e833d9c 100644 --- a/cinder/api/contrib/admin_actions.py +++ b/cinder/api/contrib/admin_actions.py @@ -61,9 +61,10 @@ class AdminController(wsgi.Controller): try: update['status'] = body['status'].lower() except (TypeError, KeyError): - raise exc.HTTPBadRequest("Must specify 'status'") + raise exc.HTTPBadRequest(explanation=_("Must specify 'status'")) if update['status'] not in self.valid_status: - raise exc.HTTPBadRequest("Must specify a valid status") + raise exc.HTTPBadRequest( + explanation=_("Must specify a valid status")) return update def authorize(self, context, action_name): @@ -89,7 +90,7 @@ class AdminController(wsgi.Controller): try: self._update(context, id, update) except exception.NotFound as e: - raise exc.HTTPNotFound(e) + raise exc.HTTPNotFound(explanation=e.msg) notifier.info(context, self.collection + '.reset_status.end', notifier_info) @@ -152,20 +153,22 @@ class VolumeAdminController(AdminController): valid = True update['attach_status'] = attach_status.lower() if update['attach_status'] not in self.valid_attach_status: - raise exc.HTTPBadRequest("Must specify a valid attach status") + raise exc.HTTPBadRequest( + explanation=_("Must specify a valid attach status")) if migration_status: valid = True update['migration_status'] = migration_status.lower() if update['migration_status'] not in self.valid_migration_status: - raise exc.HTTPBadRequest("Must specify a valid migration " - "status") + raise exc.HTTPBadRequest( + explanation=_("Must specify a valid migration status")) if update['migration_status'] == 'none': update['migration_status'] = None if not valid: - raise exc.HTTPBadRequest("Must specify 'status', 'attach_status' " - "or 'migration_status' for update.") + raise exc.HTTPBadRequest( + explanation=_("Must specify 'status', 'attach_status' " + "or 'migration_status' for update.")) return update @wsgi.action('os-force_detach') @@ -195,16 +198,18 @@ class VolumeAdminController(AdminController): try: host = params['host'] except KeyError: - raise exc.HTTPBadRequest("Must specify 'host'") + raise exc.HTTPBadRequest(explanation=_("Must specify 'host'")) force_host_copy = params.get('force_host_copy', False) if isinstance(force_host_copy, basestring): try: force_host_copy = strutils.bool_from_string(force_host_copy, strict=True) except ValueError: - raise exc.HTTPBadRequest("Bad value for 'force_host_copy'") + raise exc.HTTPBadRequest( + explanation=_("Bad value for 'force_host_copy'")) elif not isinstance(force_host_copy, bool): - raise exc.HTTPBadRequest("'force_host_copy' not string or bool") + raise exc.HTTPBadRequest( + explanation=_("'force_host_copy' not string or bool")) self.volume_api.migrate_volume(context, volume, host, force_host_copy) return webob.Response(status_int=202) @@ -221,7 +226,8 @@ class VolumeAdminController(AdminController): try: new_volume_id = params['new_volume'] except KeyError: - raise exc.HTTPBadRequest("Must specify 'new_volume'") + raise exc.HTTPBadRequest( + explanation=_("Must specify 'new_volume'")) try: new_volume = self._get(context, new_volume_id) except exception.NotFound: diff --git a/cinder/api/contrib/services.py b/cinder/api/contrib/services.py index 8fde5b874..574ccdfdc 100644 --- a/cinder/api/contrib/services.py +++ b/cinder/api/contrib/services.py @@ -147,7 +147,7 @@ class ServiceController(wsgi.Controller): disabled = True status = "disabled" else: - raise webob.exc.HTTPNotFound("Unknown action") + raise webob.exc.HTTPNotFound(explanation=_("Unknown action")) try: host = body['host'] @@ -174,11 +174,11 @@ class ServiceController(wsgi.Controller): try: svc = db.service_get_by_args(context, host, binary_key) if not svc: - raise webob.exc.HTTPNotFound('Unknown service') + raise webob.exc.HTTPNotFound(explanation=_('Unknown service')) db.service_update(context, svc['id'], ret_val) except exception.ServiceNotFound: - raise webob.exc.HTTPNotFound("service not found") + raise webob.exc.HTTPNotFound(explanation=_("service not found")) ret_val.update({'host': host, 'service': service, 'binary': binary, 'status': status}) diff --git a/cinder/api/contrib/volume_actions.py b/cinder/api/contrib/volume_actions.py index 0f8a8b860..f2859904a 100644 --- a/cinder/api/contrib/volume_actions.py +++ b/cinder/api/contrib/volume_actions.py @@ -188,14 +188,15 @@ class VolumeActionsController(wsgi.Controller): try: connector = body['os-initialize_connection']['connector'] except KeyError: - raise webob.exc.HTTPBadRequest("Must specify 'connector'") + raise webob.exc.HTTPBadRequest( + explanation=_("Must specify 'connector'")) try: info = self.volume_api.initialize_connection(context, volume, connector) except exception.VolumeBackendAPIException as error: msg = _("Unable to fetch connection information from backend.") - raise webob.exc.HTTPInternalServerError(msg) + raise webob.exc.HTTPInternalServerError(explanation=msg) return {'connection_info': info} @@ -210,7 +211,8 @@ class VolumeActionsController(wsgi.Controller): try: connector = body['os-terminate_connection']['connector'] except KeyError: - raise webob.exc.HTTPBadRequest("Must specify 'connector'") + raise webob.exc.HTTPBadRequest( + explanation=_("Must specify 'connector'")) try: self.volume_api.terminate_connection(context, volume, connector) except exception.VolumeBackendAPIException as error: diff --git a/cinder/api/middleware/auth.py b/cinder/api/middleware/auth.py index 8572949cf..2c213b655 100644 --- a/cinder/api/middleware/auth.py +++ b/cinder/api/middleware/auth.py @@ -109,7 +109,7 @@ class CinderKeystoneContext(base_wsgi.Middleware): service_catalog = jsonutils.loads(catalog_header) except ValueError: raise webob.exc.HTTPInternalServerError( - _('Invalid service catalog json.')) + explanation=_('Invalid service catalog json.')) if CONF.use_forwarded_for: remote_address = req.headers.get('X-Forwarded-For', remote_address)