Merge "Fix bare exceptions in ganesha manager"

This commit is contained in:
Zuul 2018-07-08 12:37:33 +00:00 committed by Gerrit Code Review
commit a3bda72609

View File

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