Change in vdsm[master]: bootstrap: remove temporary files even if some missing

Alon Bar-Lev alonbl at redhat.com
Sat Aug 18 21:17:55 UTC 2012


Alon Bar-Lev has uploaded a new change for review.

Change subject: bootstrap: remove temporary files even if some missing
......................................................................

bootstrap: remove temporary files even if some missing

Current code simply skip the whole process if one temporary file is
missing.

We need to remove as much temporary files as possible, so ignore single
file exception.

Change-Id: I7f69af679e798846e15faa0b9674aeeadc6d01e4
Signed-off-by: Alon Bar-Lev <alonbl at redhat.com>
---
M vdsm_reg/deployUtil.py.in
1 file changed, 22 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/02/7302/1

diff --git a/vdsm_reg/deployUtil.py.in b/vdsm_reg/deployUtil.py.in
index 5521fed..0f31b27 100644
--- a/vdsm_reg/deployUtil.py.in
+++ b/vdsm_reg/deployUtil.py.in
@@ -189,33 +189,36 @@
     logging.debug("setCoreDumpPath end:" + str(fReturn))
     return fReturn
 
+def _removeNoError(file):
+    try:
+        os.remove(file)
+    except OSError:
+        pass
+
 def cleanAll(random_num):
     """ Remove temp files.
     """
-    fReturn = True
-    try:
-        for f in (
-            '/vds_bootstrap_%s.py' % random_num,
-            '/vds_bootstrap_complete_%s.py' % random_num,
-            '/deployUtil.py'
-        ):
-            os.unlink(_WORK_DIR + f)
-            os.unlink(_WORK_DIR + f + "c")
 
-        for f in (
-            '/req_%s.conf' % random_num,
-            '/cert_%s.req' % random_num,
-            '/cert_%s.pem' % random_num,
-            '/CA_%s.pem' % random_num
-        ):
-            os.unlink(_WORK_DIR + f)
-    except:
-        pass
+    for f in (
+        '/vds_bootstrap_%s.py' % random_num,
+        '/vds_bootstrap_complete_%s.py' % random_num,
+        '/deployUtil.py'
+    ):
+        _removeNoError(_WORK_DIR + f)
+        _removeNoError(_WORK_DIR + f + "c")
+
+    for f in (
+        '/req_%s.conf' % random_num,
+        '/cert_%s.req' % random_num,
+        '/cert_%s.pem' % random_num,
+        '/CA_%s.pem' % random_num
+    ):
+        _removeNoError(_WORK_DIR + f)
 
     print "<BSTRAP component='cleanAll' status='OK'/>"
     logging.debug("cleanAll end:" + str(fReturn))
 
-    return fReturn
+    return True
 
 def setVdsConf(configStr, confFile):
     """


--
To view, visit http://gerrit.ovirt.org/7302
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7f69af679e798846e15faa0b9674aeeadc6d01e4
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <alonbl at redhat.com>


More information about the vdsm-patches mailing list