cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #00544
[Merge] lp:~harlowja/cloud-init/fixed-rhel7-test into lp:cloud-init
Joshua Harlow has proposed merging lp:~harlowja/cloud-init/fixed-rhel7-test into lp:cloud-init.
Requested reviews:
cloud init development team (cloud-init-dev)
For more details, see:
https://code.launchpad.net/~harlowja/cloud-init/fixed-rhel7-test/+merge/238766
Expose uses_systemd as a distro function
--
https://code.launchpad.net/~harlowja/cloud-init/fixed-rhel7-test/+merge/238766
Your team cloud init development team is requested to review the proposed merge of lp:~harlowja/cloud-init/fixed-rhel7-test into lp:cloud-init.
=== modified file 'cloudinit/distros/rhel.py'
--- cloudinit/distros/rhel.py 2014-02-03 22:03:14 +0000
+++ cloudinit/distros/rhel.py 2014-10-17 19:45:00 +0000
@@ -98,7 +98,7 @@
rhel_util.update_sysconfig_file(self.network_conf_fn, net_cfg)
return dev_names
- def _dist_uses_systemd(self):
+ def uses_systemd(self):
# Fedora 18 and RHEL 7 were the first adopters in their series
(dist, vers) = util.system_info()['dist'][:2]
major = (int)(vers.split('.')[0])
@@ -106,7 +106,7 @@
or (dist.startswith('Fedora') and major >= 18))
def apply_locale(self, locale, out_fn=None):
- if self._dist_uses_systemd():
+ if self.uses_systemd():
if not out_fn:
out_fn = self.systemd_locale_conf_fn
out_fn = self.systemd_locale_conf_fn
@@ -119,7 +119,7 @@
rhel_util.update_sysconfig_file(out_fn, locale_cfg)
def _write_hostname(self, hostname, out_fn):
- if self._dist_uses_systemd():
+ if self.uses_systemd():
util.subp(['hostnamectl', 'set-hostname', str(hostname)])
else:
host_cfg = {
@@ -135,14 +135,14 @@
return hostname
def _read_system_hostname(self):
- if self._dist_uses_systemd():
+ if self.uses_systemd():
host_fn = self.systemd_hostname_conf_fn
else:
host_fn = self.hostname_conf_fn
return (host_fn, self._read_hostname(host_fn))
def _read_hostname(self, filename, default=None):
- if self._dist_uses_systemd():
+ if self.uses_systemd():
(out, _err) = util.subp(['hostname'])
if len(out):
return out
@@ -163,7 +163,7 @@
def set_timezone(self, tz):
tz_file = self._find_tz_file(tz)
- if self._dist_uses_systemd():
+ if self.uses_systemd():
# Currently, timedatectl complains if invoked during startup
# so for compatibility, create the link manually.
util.del_file(self.tz_local_fn)
=== modified file 'tests/unittests/test_handler/test_handler_set_hostname.py'
--- tests/unittests/test_handler/test_handler_set_hostname.py 2014-07-23 16:16:07 +0000
+++ tests/unittests/test_handler/test_handler_set_hostname.py 2014-10-17 19:45:00 +0000
@@ -37,10 +37,11 @@
self.patchUtils(self.tmp)
cc_set_hostname.handle('cc_set_hostname',
cfg, cc, LOG, [])
- contents = util.load_file("/etc/sysconfig/network")
- n_cfg = ConfigObj(StringIO(contents))
- self.assertEquals({'HOSTNAME': 'blah.blah.blah.yahoo.com'},
- dict(n_cfg))
+ if not distro.uses_systemd():
+ contents = util.load_file("/etc/sysconfig/network")
+ n_cfg = ConfigObj(StringIO(contents))
+ self.assertEquals({'HOSTNAME': 'blah.blah.blah.yahoo.com'},
+ dict(n_cfg))
def test_write_hostname_debian(self):
cfg = {
Follow ups