diff options
-rw-r--r-- | cloudinit/distros/parsers/hosts.py | 1 | ||||
-rw-r--r-- | cloudinit/distros/rhel.py | 10 | ||||
-rw-r--r-- | tests/unittests/test_distros/test_sysconfig.py | 1 |
3 files changed, 5 insertions, 7 deletions
diff --git a/cloudinit/distros/parsers/hosts.py b/cloudinit/distros/parsers/hosts.py index 958a7c31..94c97051 100644 --- a/cloudinit/distros/parsers/hosts.py +++ b/cloudinit/distros/parsers/hosts.py @@ -90,4 +90,3 @@ class HostsConf(object): pieces = "\t".join(pieces) contents.write("%s%s\n" % (pieces, tail)) return contents.getvalue() - diff --git a/cloudinit/distros/rhel.py b/cloudinit/distros/rhel.py index 7df01c62..bc0877d5 100644 --- a/cloudinit/distros/rhel.py +++ b/cloudinit/distros/rhel.py @@ -48,7 +48,7 @@ class Distro(distros.Distro): clock_conf_fn = "/etc/sysconfig/clock" locale_conf_fn = '/etc/sysconfig/i18n' network_conf_fn = "/etc/sysconfig/network" - hostname_conf_fn = "/etc/sysconfig/network" + hostname_conf_fn = "/etc/sysconfig/network" network_script_tpl = '/etc/sysconfig/network-scripts/ifcfg-%s' resolve_conf_fn = "/etc/resolv.conf" tz_local_fn = "/etc/localtime" @@ -65,11 +65,11 @@ class Distro(distros.Distro): self.package_command('install', pkglist) def _adjust_resolve(self, dns_servers, search_servers): - r_conf = ResolvConf(util.load_file(self.resolve_conf_fn)) try: + r_conf = ResolvConf(util.load_file(self.resolve_conf_fn)) r_conf.parse() except IOError: - util.logexc(LOG, + util.logexc(LOG, "Failed at parsing %s reverting to an empty instance", self.resolve_conf_fn) r_conf = ResolvConf('') @@ -178,10 +178,10 @@ class Distro(distros.Distro): def _read_conf(self, fn): exists = False - if os.path.isfile(fn): + try: contents = util.load_file(fn).splitlines() exists = True - else: + except IOError: contents = [] return (exists, SysConf(contents)) diff --git a/tests/unittests/test_distros/test_sysconfig.py b/tests/unittests/test_distros/test_sysconfig.py index 1e34909d..0c651407 100644 --- a/tests/unittests/test_distros/test_sysconfig.py +++ b/tests/unittests/test_distros/test_sysconfig.py @@ -80,4 +80,3 @@ USEMD5=no''' contents = str(conf) self.assertIn("Z=d", contents) self.assertIn("BLAH=b", contents) - |