[node-patches] Change in ovirt-node[master]: module: persist/unpersist module should raise

dougsland at redhat.com dougsland at redhat.com
Tue Jun 30 12:20:28 UTC 2015


Douglas Schilling Landgraf has uploaded a new change for review.

Change subject: module: persist/unpersist module should raise
......................................................................

module: persist/unpersist module should raise

Currently, persist/unpersist modules returns -1
if some failure happens and it hiddes from the callers
the real reason. This patch will replace the return -1
with the raise call. Additionally, this patch updates
the persist and unpersist scripts.

Change-Id: I1a917b2476957ef31e5ff452bfb01a4152b44f51
Signed-off-by: Douglas Schilling Landgraf <dougsland at redhat.com>
---
M scripts/persist
M scripts/unpersist
M src/ovirt/node/utils/fs/__init__.py
3 files changed, 10 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/44/43044/1

diff --git a/scripts/persist b/scripts/persist
index 3a42ae6..92cbbca 100755
--- a/scripts/persist
+++ b/scripts/persist
@@ -41,10 +41,10 @@
             print "Already persisted: %s" % path
             continue
 
-        ret_persist = conf.persist(path)
-        if ret_persist == -1:
-            print "Cannot persist: %s" % path
-            return -1
+        try:
+            ret_persist = conf.persist(path)
+        except Exception:
+            raise
 
         if ret_persist is None:
             print "%s doesn't exist" % path
diff --git a/scripts/unpersist b/scripts/unpersist
index df303d3..828fcea 100755
--- a/scripts/unpersist
+++ b/scripts/unpersist
@@ -40,10 +40,10 @@
             print "File not explicitly persisted: %s" % path
             continue
 
-        ret_unpersist = conf.unpersist(path)
-        if ret_unpersist == -1:
-            print "Cannot unpersist: %s" % path
-            return -1
+        try:
+            ret_unpersist = conf.unpersist(path)
+        except Exception:
+            raise
 
         print "%s successully unpersisted" % path
 
diff --git a/src/ovirt/node/utils/fs/__init__.py b/src/ovirt/node/utils/fs/__init__.py
index 3e19f2a..d40a1ad 100644
--- a/src/ovirt/node/utils/fs/__init__.py
+++ b/src/ovirt/node/utils/fs/__init__.py
@@ -432,7 +432,7 @@
             except Exception:
                 self._logger.error('Failed to persist "%s"', path,
                                    exc_info=True)
-                return -1
+                raise
 
             restorecon(abspath)
             return True
@@ -601,7 +601,7 @@
             except Exception:
                 self._logger.error('Failed to unpersist "%s"', path,
                                    exc_info=True)
-                return -1
+                raise
         return True
 
     def _cleanup_tree(self, dirpath):


-- 
To view, visit https://gerrit.ovirt.org/43044
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1a917b2476957ef31e5ff452bfb01a4152b44f51
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Douglas Schilling Landgraf <dougsland at redhat.com>



More information about the node-patches mailing list