Fix Manila API error message

Some Manila error messages were wrongly returning the string marker
"%s" instead of the string content. This patch fixes them.

Closes-Bug: #2007060
Change-Id: Ib68f71e19f2ec1190cc431f029d996193008d557
This commit is contained in:
Felipe Rodrigues 2023-02-12 23:49:00 -03:00
parent f6f93ff951
commit a65dffc0c7
10 changed files with 30 additions and 24 deletions

View File

@ -744,10 +744,10 @@ class Resource(wsgi.Application):
request.set_api_version_request()
except exception.InvalidAPIVersionString as e:
return Fault(webob.exc.HTTPBadRequest(
explanation=e.message))
explanation=e.msg))
except exception.InvalidGlobalAPIVersion as e:
return Fault(webob.exc.HTTPNotAcceptable(
explanation=e.message))
explanation=e.msg))
# Identify the action, its arguments, and the requested
# content type

View File

@ -50,7 +50,7 @@ class ShareTypeExtraSpecsController(wsgi.Controller):
try:
share_types.get_valid_required_extra_specs(extra_specs)
except exception.InvalidExtraSpec as e:
raise webob.exc.HTTPBadRequest(explanation=e.message)
raise webob.exc.HTTPBadRequest(explanation=e.msg)
def is_valid_string(v):
return isinstance(v, str) and len(v) in range(1, 256)
@ -96,7 +96,7 @@ class ShareTypeExtraSpecsController(wsgi.Controller):
try:
self._verify_extra_specs(specs, False)
except exception.InvalidExtraSpec as e:
raise webob.exc.HTTPBadRequest(e.message)
raise webob.exc.HTTPBadRequest(e.msg)
self._check_key_names(specs.keys())
specs = share_types.sanitize_extra_specs(specs)

View File

@ -90,9 +90,9 @@ class ShareMixin(object):
except exception.NotFound:
raise exc.HTTPNotFound()
except exception.InvalidShare as e:
raise exc.HTTPForbidden(explanation=e.message)
raise exc.HTTPForbidden(explanation=e.msg)
except exception.Conflict as e:
raise exc.HTTPConflict(explanation=e.message)
raise exc.HTTPConflict(explanation=e.msg)
return webob.Response(status_int=http_client.ACCEPTED)
@ -282,14 +282,14 @@ class ShareMixin(object):
availability_zone_id = availability_zone_db.id
availability_zone = availability_zone_db.name
except exception.AvailabilityZoneNotFound as e:
raise exc.HTTPNotFound(explanation=e.message)
raise exc.HTTPNotFound(explanation=e.msg)
share_group_id = share.get('share_group_id')
if share_group_id:
try:
share_group = db.share_group_get(context, share_group_id)
except exception.ShareGroupNotFound as e:
raise exc.HTTPNotFound(explanation=e.message)
raise exc.HTTPNotFound(explanation=e.msg)
sg_az_id = share_group['availability_zone_id']
if availability_zone and availability_zone_id != sg_az_id:
msg = _("Share cannot have AZ ('%(s_az)s') different than "

View File

@ -77,7 +77,7 @@ class ShareGroupSnapshotController(wsgi.Controller, wsgi.AdminActionsMixin):
self.share_group_api.delete_share_group_snapshot(
context, sg_snapshot)
except exception.InvalidShareGroupSnapshot as e:
raise exc.HTTPConflict(explanation=e.message)
raise exc.HTTPConflict(explanation=e.msg)
return webob.Response(status_int=http_client.ACCEPTED)
@wsgi.Controller.api_version('2.31', '2.54', experimental=True)
@ -195,9 +195,9 @@ class ShareGroupSnapshotController(wsgi.Controller, wsgi.AdminActionsMixin):
new_snapshot = self.share_group_api.create_share_group_snapshot(
context, **kwargs)
except exception.ShareGroupNotFound as e:
raise exc.HTTPBadRequest(explanation=e.message)
raise exc.HTTPBadRequest(explanation=e.msg)
except exception.InvalidShareGroup as e:
raise exc.HTTPConflict(explanation=e.message)
raise exc.HTTPConflict(explanation=e.msg)
return self._view_builder.detail(req, dict(new_snapshot.items()))

View File

@ -78,7 +78,7 @@ class ShareGroupController(wsgi.Controller, wsgi.AdminActionsMixin):
try:
self.share_group_api.delete(context, share_group)
except exception.InvalidShareGroup as e:
raise exc.HTTPConflict(explanation=e.message)
raise exc.HTTPConflict(explanation=e.msg)
return webob.Response(status_int=http_client.ACCEPTED)
@wsgi.Controller.api_version('2.31', '2.54', experimental=True)
@ -241,7 +241,7 @@ class ShareGroupController(wsgi.Controller, wsgi.AdminActionsMixin):
kwargs['availability_zone_id'] = az.id
kwargs['availability_zone'] = az.name
except exception.AvailabilityZoneNotFound as e:
raise exc.HTTPNotFound(explanation=e.message)
raise exc.HTTPNotFound(explanation=e.msg)
if 'source_share_group_snapshot_id' in share_group:
source_share_group_snapshot_id = share_group.get(
@ -277,7 +277,7 @@ class ShareGroupController(wsgi.Controller, wsgi.AdminActionsMixin):
try:
new_share_group = self.share_group_api.create(context, **kwargs)
except exception.InvalidShareGroupSnapshot as e:
raise exc.HTTPConflict(explanation=e.message)
raise exc.HTTPConflict(explanation=e.msg)
except (exception.ShareGroupSnapshotNotFound,
exception.InvalidInput) as e:
raise exc.HTTPBadRequest(explanation=str(e))

View File

@ -65,7 +65,7 @@ class ShareInstanceExportLocationController(wsgi.Controller):
context, export_location_uuid)
return self._view_builder.detail(req, export_location)
except exception.ExportLocationNotFound as e:
raise exc.HTTPNotFound(explanation=e.message)
raise exc.HTTPNotFound(explanation=e.msg)
def create_resource():

View File

@ -85,7 +85,7 @@ class ShareReplicaExportLocationController(wsgi.Controller):
return self._view_builder.detail(req, export_location,
replica=True)
except exception.ExportLocationNotFound as e:
raise exc.HTTPNotFound(explanation=e.message)
raise exc.HTTPNotFound(explanation=e.msg)
def create_resource():

View File

@ -56,7 +56,7 @@ class ShareReplicationController(wsgi.Controller, wsgi.AdminActionsMixin):
try:
self.share_api.delete_share_replica(context, resource, force=True)
except exception.ReplicationException as e:
raise exc.HTTPBadRequest(explanation=e.message)
raise exc.HTTPBadRequest(explanation=e.msg)
@wsgi.Controller.api_version(
MIN_SUPPORTED_API_VERSION, PRE_GRADUATION_VERSION, experimental=True)
@ -199,11 +199,11 @@ class ShareReplicationController(wsgi.Controller, wsgi.AdminActionsMixin):
share_network_id=share_network_id,
scheduler_hints=scheduler_hints)
except exception.AvailabilityZoneNotFound as e:
raise exc.HTTPBadRequest(explanation=e.message)
raise exc.HTTPBadRequest(explanation=e.msg)
except exception.ReplicationException as e:
raise exc.HTTPBadRequest(explanation=e.message)
raise exc.HTTPBadRequest(explanation=e.msg)
except exception.ShareBusyException as e:
raise exc.HTTPBadRequest(explanation=e.message)
raise exc.HTTPBadRequest(explanation=e.msg)
return self._view_builder.detail(req, new_replica)
@ -230,7 +230,7 @@ class ShareReplicationController(wsgi.Controller, wsgi.AdminActionsMixin):
try:
self.share_api.delete_share_replica(context, replica)
except exception.ReplicationException as e:
raise exc.HTTPBadRequest(explanation=e.message)
raise exc.HTTPBadRequest(explanation=e.msg)
return webob.Response(status_int=http_client.ACCEPTED)
@ -271,7 +271,7 @@ class ShareReplicationController(wsgi.Controller, wsgi.AdminActionsMixin):
try:
replica = self.share_api.promote_share_replica(context, replica)
except exception.ReplicationException as e:
raise exc.HTTPBadRequest(explanation=e.message)
raise exc.HTTPBadRequest(explanation=e.msg)
except exception.AdminRequired as e:
raise exc.HTTPForbidden(explanation=e.message)
@ -355,7 +355,7 @@ class ShareReplicationController(wsgi.Controller, wsgi.AdminActionsMixin):
try:
self.share_api.update_share_replica(context, replica)
except exception.InvalidHost as e:
raise exc.HTTPBadRequest(explanation=e.message)
raise exc.HTTPBadRequest(explanation=e.msg)
def create_resource():

View File

@ -207,7 +207,7 @@ class ShareTypesController(wsgi.Controller):
context, 'share_type.create', share_type)
except exception.InvalidExtraSpec as e:
raise webob.exc.HTTPBadRequest(explanation=e.message)
raise webob.exc.HTTPBadRequest(explanation=e.msg)
except exception.ShareTypeExists as err:
notifier_err = dict(share_types=share_type,
error_message=err.message)

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixed several Manila API error messages with their contents. For more
details, please refer to
`launchpad bug #2007060 <https://bugs.launchpad.net/manila/+bug/2007060>`_