Merge "Fix Manila API error message"

This commit is contained in:
Zuul 2023-02-23 06:59:10 +00:00 committed by Gerrit Code Review
commit 793c5c362e
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

@ -57,7 +57,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)
@ -200,11 +200,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)
@ -231,7 +231,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)
@ -296,7 +296,7 @@ class ShareReplicationController(wsgi.Controller, wsgi.AdminActionsMixin):
context, replica,
quiesce_wait_time=quiesce_wait_time)
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)
@ -380,7 +380,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>`_