From 1f160196e40d129aca6713e9d2e014d540b4541c Mon Sep 17 00:00:00 2001 From: Tom Barron Date: Tue, 3 Jul 2018 14:50:59 -0400 Subject: [PATCH] Fix bare exceptions in ganesha manager Closes-Bug: #1779922 Change-Id: Ife18c61c4d195a73980a03287700df7ba9b52b9c --- manila/share/drivers/ganesha/manager.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/manila/share/drivers/ganesha/manager.py b/manila/share/drivers/ganesha/manager.py index 01491cbe1a..da27b8f9bc 100644 --- a/manila/share/drivers/ganesha/manager.py +++ b/manila/share/drivers/ganesha/manager.py @@ -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