Change in vdsm[master]: utils: Use ovirt node for persist and unpersist files
ykaplan at redhat.com
ykaplan at redhat.com
Mon Aug 18 08:29:33 UTC 2014
Yeela Kaplan has uploaded a new change for review.
Change subject: utils: Use ovirt node for persist and unpersist files
......................................................................
utils: Use ovirt node for persist and unpersist files
Change-Id: Ifaf19e5f8f5beca38d34a606c3eb370385dc206d
Signed-off-by: Yeela Kaplan <ykaplan at redhat.com>
---
M lib/vdsm/utils.py
1 file changed, 19 insertions(+), 15 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/84/31584/1
diff --git a/lib/vdsm/utils.py b/lib/vdsm/utils.py
index e88007c..b02daa8 100644
--- a/lib/vdsm/utils.py
+++ b/lib/vdsm/utils.py
@@ -143,6 +143,18 @@
raise
+def persistFile(name):
+ if isOvirtNode():
+ from ovirt.node.utils.fs import Config as NodeCfg
+ NodeCfg().persist(name)
+
+
+def unpersistFile(name):
+ if isOvirtNode():
+ from ovirt.node.utils.fs import Config as NodeCfg
+ NodeCfg().unpersist(name)
+
+
def rotateFiles(directory, prefixName, gen, cp=False, persist=False):
logging.debug("dir: %s, prefixName: %s, versions: %s" %
(directory, prefixName, gen))
@@ -171,37 +183,29 @@
for key in keys:
oldName = os.path.join(directory, fd[key]['old'])
newName = os.path.join(directory, fd[key]['new'])
- if isOvirtNode() and persist and not cp:
+ if persist and not cp:
try:
- execCmd([constants.EXT_UNPERSIST, oldName],
- sudo=True)
- execCmd([constants.EXT_UNPERSIST, newName],
- sudo=True)
+ unpersistFile(oldName)
+ unpersistFile(newName)
except:
pass
try:
if cp:
execCmd([constants.EXT_CP, oldName, newName], sudo=True)
- if (isOvirtNode() and
- persist and not os.path.exists(newName)):
- execCmd([constants.EXT_PERSIST, newName],
- sudo=True)
+ if (persist and not os.path.exists(newName)):
+ persistFile(newName)
else:
os.rename(oldName, newName)
except:
pass
- if isOvirtNode() and persist and not cp:
+ if persist and not cp:
try:
+ persistFile(newName)
execCmd([constants.EXT_PERSIST, newName],
sudo=True)
except:
pass
-
-
-def persistFile(name):
- if isOvirtNode():
- execCmd([constants.EXT_PERSIST, name], sudo=True)
def _parseMemInfo(lines):
--
To view, visit http://gerrit.ovirt.org/31584
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifaf19e5f8f5beca38d34a606c3eb370385dc206d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yeela Kaplan <ykaplan at redhat.com>
More information about the vdsm-patches
mailing list