From e8adec1b96998246bb29283611e4e8f7556155e9 Mon Sep 17 00:00:00 2001 From: zhufl Date: Tue, 19 Mar 2019 17:40:40 +0800 Subject: [PATCH] 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 --- manila/share/drivers/helpers.py | 4 ++-- manila/share/drivers/qnap/qnap.py | 6 +++--- manila/share_group/share_group_types.py | 2 +- manila/volume/cinder.py | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manila/share/drivers/helpers.py b/manila/share/drivers/helpers.py index c35772f6ee..e8fb38b4f9 100644 --- a/manila/share/drivers/helpers.py +++ b/manila/share/drivers/helpers.py @@ -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) diff --git a/manila/share/drivers/qnap/qnap.py b/manila/share/drivers/qnap/qnap.py index fa316773fb..989d5b87d5 100644 --- a/manila/share/drivers/qnap/qnap.py +++ b/manila/share/drivers/qnap/qnap.py @@ -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) diff --git a/manila/share_group/share_group_types.py b/manila/share_group/share_group_types.py index 3db0de2123..0daa3ad296 100644 --- a/manila/share_group/share_group_types.py +++ b/manila/share_group/share_group_types.py @@ -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): diff --git a/manila/volume/cinder.py b/manila/volume/cinder.py index 4424317c5c..a9d2db63e3 100644 --- a/manila/volume/cinder.py +++ b/manila/volume/cinder.py @@ -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):