diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-09-19 21:13:48 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-09-19 21:13:48 -0700 |
commit | f59369d1bb0eac874dcd2fa91abfad9186b22810 (patch) | |
tree | 2effeb939e4f31444508144ae2e8f896ce5c0330 | |
parent | 355b0e372aec58360d4fb728088edefec27f86a1 (diff) | |
download | vyos-cloud-init-f59369d1bb0eac874dcd2fa91abfad9186b22810.tar.gz vyos-cloud-init-f59369d1bb0eac874dcd2fa91abfad9186b22810.zip |
Use a common header creation function
to avoid duplicating the same code in
this file.
-rw-r--r-- | cloudinit/distros/rhel.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/cloudinit/distros/rhel.py b/cloudinit/distros/rhel.py index c00627c6..1ea7952b 100644 --- a/cloudinit/distros/rhel.py +++ b/cloudinit/distros/rhel.py @@ -63,6 +63,11 @@ def _make_sysconfig_bool(val): return 'no' +def _make_header(): + ci_ver = version.version_string() + return '# Created by cloud-init v. %s' % (ci_ver) + + class Distro(distros.Distro): def __init__(self, name, cfg, paths): @@ -83,7 +88,7 @@ class Distro(distros.Distro): if search_servers: contents.append("search %s" % (" ".join(search_servers))) if contents: - contents.insert(0, '# Created by cloud-init') + contents.insert(0, _make_header()) util.write_file("/etc/resolv.conf", "\n".join(contents), 0644) def _write_network(self, settings): @@ -137,8 +142,7 @@ class Distro(distros.Distro): if updated_am: lines = contents.write() if not exists: - ci_ver = version.version_string() - lines.insert(0, '# Created by cloud-init v. %s' % (ci_ver)) + lines.insert(0, _make_header()) util.write_file(fn, "\n".join(lines), 0644) def set_hostname(self, hostname): @@ -212,7 +216,7 @@ class Distro(distros.Distro): } self._update_sysconfig_file("/etc/sysconfig/clock", clock_cfg) # This ensures that the correct tz will be used for the system - util.copy(tz_file, self._paths.join(False, "/etc/localtime")) + util.copy(tz_file, "/etc/localtime") def package_command(self, command, args=None): cmd = ['yum'] |