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
This commit is contained in:
Thomas Bechtold 2016-02-19 09:13:54 +01:00
parent f13e5ab039
commit 68fd502c4d
1 changed files with 12 additions and 4 deletions

View File

@ -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):