[node-patches] Change in ovirt-node[ovirt-3.5]: scripts: provide output msgs to [un]persist cmds

fabiand at redhat.com fabiand at redhat.com
Fri May 8 10:43:36 UTC 2015


Hello Douglas Schilling Landgraf,

I'd like you to do a code review.  Please visit

    https://gerrit.ovirt.org/40691

to review the following change.

Change subject: scripts: provide output msgs to [un]persist cmds
......................................................................

scripts: provide output msgs to [un]persist cmds

Previously persist and unpersit commands showed output
messages to users for success or unsuccess operations.
This patch returns the output to users.

Change-Id: I8f52960d7da50c35ada14474c2a46a38b5e153de
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1187034
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, 32 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/91/40691/1

diff --git a/scripts/persist b/scripts/persist
index fb486b8..3a42ae6 100755
--- a/scripts/persist
+++ b/scripts/persist
@@ -21,6 +21,7 @@
 # Convenience wrapper to give access to ovirt/node/utils/fs persistence
 # facilities
 import argparse
+import os
 import sys
 
 from ovirt.node.utils import fs
@@ -36,7 +37,22 @@
 
     conf = fs.Config()
     for path in arguments.FILE:
-        conf.persist(path)
+        if conf.exists(path):
+            print "Already persisted: %s" % path
+            continue
+
+        ret_persist = conf.persist(path)
+        if ret_persist == -1:
+            print "Cannot persist: %s" % path
+            return -1
+
+        if ret_persist is None:
+            print "%s doesn't exist" % path
+            return -1
+
+        print "Successfully persisted: %s" % path
+
+    return 0
 
 if __name__ == '__main__':
     sys.exit(persist())
diff --git a/scripts/unpersist b/scripts/unpersist
index 047000a..df303d3 100755
--- a/scripts/unpersist
+++ b/scripts/unpersist
@@ -21,6 +21,7 @@
 # Convenience wrapper to give access to ovirt/node/utils/fs persistence
 # facilities
 import argparse
+import os
 import sys
 
 from ovirt.node.utils import fs
@@ -35,7 +36,18 @@
 
     conf = fs.Config()
     for path in arguments.PATH:
-        conf.unpersist(path)
+        if not conf.exists(path):
+            print "File not explicitly persisted: %s" % path
+            continue
+
+        ret_unpersist = conf.unpersist(path)
+        if ret_unpersist == -1:
+            print "Cannot unpersist: %s" % path
+            return -1
+
+        print "%s successully unpersisted" % path
+
+    return 0
 
 if __name__ == '__main__':
     sys.exit(unpersist())
diff --git a/src/ovirt/node/utils/fs/__init__.py b/src/ovirt/node/utils/fs/__init__.py
index 7297135..1204776 100644
--- a/src/ovirt/node/utils/fs/__init__.py
+++ b/src/ovirt/node/utils/fs/__init__.py
@@ -433,6 +433,7 @@
                 return -1
 
             restorecon(abspath)
+            return True
 
     def copy_attributes(self, abspath, destpath):
         """Copy the owner/group, selinux context from abspath to destpath"""
@@ -599,6 +600,7 @@
                 self._logger.error('Failed to unpersist "%s"', path,
                                    exc_info=True)
                 return -1
+        return True
 
     def _cleanup_tree(self, dirpath):
         """Removes empty directories in the structure. abspath must be a dir"""


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8f52960d7da50c35ada14474c2a46a38b5e153de
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Fabian Deutsch <fabiand at redhat.com>
Gerrit-Reviewer: Douglas Schilling Landgraf <dougsland at redhat.com>
Gerrit-Reviewer: Fabian Deutsch <fabiand at redhat.com>



More information about the node-patches mailing list