Fix parameters passed to exception

Do not pass reason parameter to ShareNotFound/ManilaException/
InvalidParameterValue/ShareGroupTypeNotFound/InvalidVolume, for
reason is not in the message format.

Change-Id: I4af25be0d5095c704b40fafbde3fafa298103596
This commit is contained in:
zhufl 2019-03-19 17:40:40 +08:00
parent b2787fded5
commit e8adec1b96
4 changed files with 11 additions and 11 deletions

View File

@ -447,7 +447,7 @@ class CIFSHelperIPAccess(CIFSHelperBase):
except Exception:
msg = _("Could not create CIFS export %s.") % share_name
LOG.exception(msg)
raise exception.ManilaException(reason=msg)
raise exception.ManilaException(msg)
else:
# Share exists
if recreate:
@ -458,7 +458,7 @@ class CIFSHelperIPAccess(CIFSHelperBase):
except Exception:
msg = _("Could not create CIFS export %s.") % share_name
LOG.exception(msg)
raise exception.ManilaException(reason=msg)
raise exception.ManilaException(msg)
else:
msg = _('Share section %s already defined.') % share_name
raise exception.ShareBackendException(msg=msg)

View File

@ -881,7 +881,7 @@ class QnapShareDriver(driver.ShareDriver):
if existing_share is None:
msg = _("The share id %s was not found on backend.") % volID
LOG.error(msg)
raise exception.ShareNotFound(reason=msg)
raise exception.ShareNotFound(msg)
snapshot_id = snapshot.get('provider_location')
snapshot_id_info = snapshot_id.split('@')
@ -893,7 +893,7 @@ class QnapShareDriver(driver.ShareDriver):
msg = _("Incorrect provider_location format. It should have the "
"following format: share_name@snapshot_name.")
LOG.error(msg)
raise exception.InvalidParameterValue(reason=msg)
raise exception.InvalidParameterValue(msg)
if share_name != existing_share.find('vol_label').text:
msg = (_("The assigned share %(share_name)s was not matched "
@ -901,7 +901,7 @@ class QnapShareDriver(driver.ShareDriver):
{'share_name': share_name,
'vol_label': existing_share.find('vol_label').text})
LOG.error(msg)
raise exception.ShareNotFound(reason=msg)
raise exception.ShareNotFound(msg)
check_snapshot = self.api_executor.get_snapshot_info(
volID=volID, snapshot_name=snapshot_name)

View File

@ -120,7 +120,7 @@ def get_by_name_or_id(context, share_group_type=None):
share_group_type_ref = get_default(context)
if not share_group_type_ref:
msg = _("Default share group type not found.")
raise exception.ShareGroupTypeNotFound(reason=msg)
raise exception.ShareGroupTypeNotFound(msg)
return share_group_type_ref
if uuidutils.is_uuid_like(share_group_type):

View File

@ -201,24 +201,24 @@ class API(base.Base):
"""Raise exception if volume in use."""
if volume['status'] != "in-use":
msg = _("status must be 'in-use'")
raise exception.InvalidVolume(reason=msg)
raise exception.InvalidVolume(msg)
def check_attach(self, context, volume, instance=None):
if volume['status'] != "available":
msg = _("status must be 'available'")
raise exception.InvalidVolume(reason=msg)
raise exception.InvalidVolume(msg)
if volume['attach_status'] == "attached":
msg = _("already attached")
raise exception.InvalidVolume(reason=msg)
raise exception.InvalidVolume(msg)
if instance and not CONF[CINDER_GROUP].cross_az_attach:
if instance['availability_zone'] != volume['availability_zone']:
msg = _("Instance and volume not in same availability_zone")
raise exception.InvalidVolume(reason=msg)
raise exception.InvalidVolume(msg)
def check_detach(self, context, volume):
if volume['status'] == "available":
msg = _("already detached")
raise exception.InvalidVolume(reason=msg)
raise exception.InvalidVolume(msg)
@translate_volume_exception
def reserve_volume(self, context, volume_id):