Ido Barkan has uploaded a new change for review.

Change subject: Teach utils.rmFile to handle ovirtNode
......................................................................

Teach utils.rmFile to handle ovirtNode

We need to handle files in other places in vdsm so moving it down
the file hierarchy.

Change-Id: I080c4f34f8962ac5589f0a2c54f26e808d65ec33
Signed-off-by: Ido Barkan <ibar...@redhat.com>
---
M lib/vdsm/utils.py
M vdsm/network/configurators/ifcfg.py
2 files changed, 24 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/73/40573/1

diff --git a/lib/vdsm/utils.py b/lib/vdsm/utils.py
index 4856cf9..520542b 100644
--- a/lib/vdsm/utils.py
+++ b/lib/vdsm/utils.py
@@ -135,6 +135,26 @@
 
     If the file doesn't exist it's assumed that it was already removed.
     """
+    if isOvirtNode():
+        try:
+            _rmFileInNode(fileToRemove)
+        except OSError as e:
+            if e.errno == errno.ENOENT:
+                logging.warning("File: %s already removed", fileToRemove)
+            else:
+                logging.error("Removing file: %s failed", fileToRemove,
+                              exc_info=True)
+                raise
+    else:
+        _rmFile(fileToRemove)
+
+
+def _rmFileInNode(fileToRemove):
+    """unpersists and shreds the file"""
+    node_fs.Config().delete(fileToRemove)
+
+
+def _rmFile(fileToRemove):
     try:
         os.unlink(fileToRemove)
     except OSError as e:
@@ -1088,6 +1108,9 @@
             bool(glob.glob('/etc/ovirt-node-*-release')))
 
 
+if isOvirtNode():
+    from ovirt.node.utils import fs as node_fs
+
 # Copied from
 # http://docs.python.org/2.6/library/itertools.html?highlight=grouper#recipes
 def grouper(iterable, n, fillvalue=None):
diff --git a/vdsm/network/configurators/ifcfg.py 
b/vdsm/network/configurators/ifcfg.py
index 6d35c0a..cdb22c8 100644
--- a/vdsm/network/configurators/ifcfg.py
+++ b/vdsm/network/configurators/ifcfg.py
@@ -280,11 +280,7 @@
 
     @staticmethod
     def _removeFile(filename):
-        """Remove file (directly or using oVirt node's library)"""
-        if utils.isOvirtNode():
-            node_fs.Config().delete(filename)  # unpersists and shreds the file
-        else:
-            utils.rmFile(filename)
+        utils.rmFile(filename)
         logging.debug("Removed file %s", filename)
 
     def createLibvirtNetwork(self, network, bridged=True, iface=None,


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I080c4f34f8962ac5589f0a2c54f26e808d65ec33
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ido Barkan <ibar...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to