From 68fd502c4d123dc57c5fdd20915446d9f4db588d Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: Fri, 19 Feb 2016 09:13:54 +0100 Subject: [PATCH] Improve exception msg when attaching/detaching volumes When something goes wrong in the generic drivers attach/detach volume handing, be more verbose and also show the volume-id in the exception. Change-Id: I03176801bf6f0d76a2d82b94ba6c1d5ee8f6193e --- manila/share/drivers/generic.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/manila/share/drivers/generic.py b/manila/share/drivers/generic.py index e4a7639a91..50344533a3 100644 --- a/manila/share/drivers/generic.py +++ b/manila/share/drivers/generic.py @@ -406,9 +406,13 @@ class GenericShareDriver(driver.ExecuteMixin, driver.ShareDriver): _('Failed to attach volume %s') % volume['id']) time.sleep(1) else: + err_msg = { + 'volume_id': volume['id'], + 'max_time': self.configuration.max_time_to_attach + } raise exception.ManilaException( - _('Volume have not been attached in %ss. Giving up') % - self.configuration.max_time_to_attach) + _('Volume %(volume_id)s has not been attached in ' + '%(max_time)ss. Giving up.') % err_msg) return do_attach(volume) def _get_volume_name(self, share_id): @@ -499,9 +503,13 @@ class GenericShareDriver(driver.ExecuteMixin, driver.ShareDriver): break time.sleep(1) else: + err_msg = { + 'volume_id': volume['id'], + 'max_time': self.configuration.max_time_to_attach + } raise exception.ManilaException( - _('Volume have not been detached in %ss. Giving up') - % self.configuration.max_time_to_attach) + _('Volume %(volume_id)s has not been detached in ' + '%(max_time)ss. Giving up.') % err_msg) do_detach() def _allocate_container(self, context, share, snapshot=None):