Fix bare exceptions in ganesha manager

Closes-Bug: #1779922
Change-Id: Ife18c61c4d195a73980a03287700df7ba9b52b9c
(cherry picked from commit 1f160196e4)
This commit is contained in:
Tom Barron 2018-07-03 14:50:59 -04:00
parent 0b65d8cbba
commit f9992b9059
1 changed files with 16 additions and 7 deletions

View File

@ -305,10 +305,13 @@ class GaneshaManager(object):
tmpf = self._write_tmp_conf_file(path, data)
try:
self.execute('mv', tmpf, path)
except exception.ProcessExecutionError:
except exception.ProcessExecutionError as e:
LOG.error('mv temp file ({0}) to {1} failed.'.format(tmpf, path))
self.execute('rm', tmpf)
raise
raise exception.GaneshaCommandFailure(
stdout=e.stdout, stderr=e.stderr, exit_code=e.exit_code,
cmd=e.cmd)
return path
def _mkindex(self):
@ -356,7 +359,9 @@ class GaneshaManager(object):
if e.exit_code == 1:
return False
else:
raise
raise exception.GaneshaCommandFailure(
stdout=e.stdout, stderr=e.stderr, exit_code=e.exit_code,
cmd=e.cmd)
def _check_export_file_exists(self, name):
return self._check_file_exists(self._getpath(name))
@ -476,12 +481,14 @@ class GaneshaManager(object):
else:
_mkindex_called = True
self._mkindex()
except Exception:
except Exception as e:
for u in undos:
u()
if not self.ganesha_rados_store_enable and not _mkindex_called:
self._mkindex()
raise
raise exception.GaneshaCommandFailure(
stdout=e.stdout, stderr=e.stderr, exit_code=e.exit_code,
cmd=e.cmd)
def update_export(self, name, confdict):
"""Update an export to Ganesha specified by confdict."""
@ -492,10 +499,12 @@ class GaneshaManager(object):
try:
self._dbus_send_ganesha("UpdateExport", "string:" + path,
"string:EXPORT(Export_Id=%d)" % xid)
except Exception:
except Exception as e:
# Revert the export update.
self._write_export(name, old_confdict)
raise
raise exception.GaneshaCommandFailure(
stdout=e.stdout, stderr=e.stderr, exit_code=e.exit_code,
cmd=e.cmd)
finally:
if self.ganesha_rados_store_enable:
# Clean up temp export file used for the DBus update call