Yaniv Bronhaim has uploaded a new change for review. Change subject: Fix failure while related services conf files do not exist ......................................................................
Fix failure while related services conf files do not exist During vdsm configuration we failed if one of the conf files (such as libvirtd.conf) was not exist. This failed the configuration process and introduced a regression. This patch will create the file if not exists and move on with vdsm configure. Change-Id: Idb6565ce9cef6c7aa3f14c85f1dae0715e1858e2 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1135664 Signed-off-by: Yaniv Bronhaim <[email protected]> --- M lib/vdsm/tool/configurators/configfile.py 1 file changed, 12 insertions(+), 10 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/66/32166/1 diff --git a/lib/vdsm/tool/configurators/configfile.py b/lib/vdsm/tool/configurators/configfile.py index 62b99b1..84651e3 100644 --- a/lib/vdsm/tool/configurators/configfile.py +++ b/lib/vdsm/tool/configurators/configfile.py @@ -1,4 +1,4 @@ -# Copyright 2013 Red Hat, Inc. +# Copyright 2014 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -24,6 +24,7 @@ import re import selinux import io +import errno from ... import utils if utils.isOvirtNode(): @@ -87,11 +88,6 @@ sectionEnd='## end of configuration section by vdsm', prefix='# VDSM backup', lineComment='by vdsm'): - if not os.path.exists(filename): - raise OSError( - 'No such file or directory: %s' % (filename, ) - ) - self._filename = filename self._context = False self._sectionStart = sectionStart @@ -238,10 +234,16 @@ """ Notice this method can be called out of context since it is read only """ - for line in open(self._filename, 'r'): - if line == self._start(): - return True - return False + try: + with open(self._filename, 'r') as f: + for line in f: + if line == self._start(): + return True + return False + except IOError as e: + if e.errno == errno.ENOENT: + utils.touchFile(self._filename) + return False class ParserWrapper(object): -- To view, visit http://gerrit.ovirt.org/32166 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idb6565ce9cef6c7aa3f14c85f1dae0715e1858e2 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
