[NEW PATCH] Related to BZ#720911 - Use context manager in updateLvmConf (via gerrit-bot)
Saggi Mizrahi
smizrahi at redhat.com
Sun Jul 24 16:34:49 UTC 2011
New patch submitted by Saggi Mizrahi (smizrahi at redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/739
commit 212c14563ad4ed65cd8ddcc64566617300d2933e
Author: Saggi Mizrahi <smizrahi at redhat.com>
Date: Sun Jul 24 18:59:06 2011 +0300
Related to BZ#720911 - Use context manager in updateLvmConf
Change-Id: I60b64d70a26c1b27e563f28a287f75a8cc621128
diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py
index 8b08a24..ffceffd 100644
--- a/vdsm/storage/lvm.py
+++ b/vdsm/storage/lvm.py
@@ -233,9 +233,10 @@ def updateLvmConf():
try:
if not os.path.isdir(VDSM_LVM_SYSTEM_DIR):
os.mkdir(VDSM_LVM_SYSTEM_DIR)
- lvmconf = file(VDSM_LVM_CONF, "w")
- lvmconf.write(EXTRA_LVMCONF)
- lvmconf.close()
+
+ with open(VDSM_LVM_CONF, "w") as lvmconf:
+ lvmconf.write(VDSM_LVM_CONF)
+
except IOError, e:
# We are not interested in exceptions here, note it and
log.warning("Cannot create %s file %s", VDSM_LVM_CONF, str(e))
More information about the vdsm-patches
mailing list