Shahar Havivi has uploaded a new change for review.

Change subject: v2v: cleanup v2v directory leftovers
......................................................................

v2v: cleanup v2v directory leftovers

In case of a crush of vdsm/virt-v2v there may be ovf or tmp files in
/var/run/vdsm/v2v.
These are small text files that need to be remove.

Change-Id: Ic2f5b63863f4f7dc85d6af0ca015099274715441
Signed-off-by: Shahar Havivi <[email protected]>
---
M vdsm/clientIF.py
M vdsm/v2v.py
2 files changed, 17 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/89/39789/1

diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index 2719101..e01b976 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -39,6 +39,7 @@
 import caps
 import blkid
 import supervdsm
+import v2v
 from protocoldetector import MultiProtocolAcceptor
 
 from virt import migration
@@ -112,6 +113,7 @@
             self._createAcceptor(host, port)
             self._prepareXMLRPCBinding()
             self._prepareJSONRPCBinding()
+            v2v.clean_leftovers()
         except:
             self.log.error('failed to init clientIF, '
                            'shutting down storage dispatcher')
diff --git a/vdsm/v2v.py b/vdsm/v2v.py
index 004dcaf..c0f78c4 100644
--- a/vdsm/v2v.py
+++ b/vdsm/v2v.py
@@ -27,6 +27,7 @@
 from collections import namedtuple
 from contextlib import closing, contextmanager
 import errno
+from glob import glob
 import logging
 import os
 import re
@@ -212,6 +213,20 @@
     return ret
 
 
+def clean_leftovers():
+    for f in glob('%s/*.ovf' % _V2V_DIR):
+        try:
+            os.remove(f)
+        except Exception as e:
+            logging.warn('Cannot remove file: %s, err: %s', f, e)
+
+    for f in glob('%s/*.tmp' % _V2V_DIR):
+        try:
+            os.remove(f)
+        except Exception as e:
+            logging.warn('Cannot remove file: %s, err: %s', f, e)
+
+
 def _read_ovf(job_id):
     file_name = os.path.join(_V2V_DIR, "%s.ovf" % job_id)
     try:


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic2f5b63863f4f7dc85d6af0ca015099274715441
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Shahar Havivi <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to