From 3896bf370a142eb95a4341e381ee7b1ff0f0c3e2 Mon Sep 17 00:00:00 2001 From: Martin Kosek Date: Wed, 5 Dec 2012 10:50:05 +0100 Subject: Change network configuration file Fedora+systemd changed deprecated /etc/sysconfig/network which was used by IPA to store static hostname for the IPA machine. See https://bugzilla.redhat.com/show_bug.cgi?id=881785 for details. Change Fedora platform files to store the hostname to /etc/hostname instead. https://fedorahosted.org/freeipa/ticket/3279 --- ipapython/ipautil.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'ipapython/ipautil.py') diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py index 10ad2c341..1053fc665 100644 --- a/ipapython/ipautil.py +++ b/ipapython/ipautil.py @@ -1162,3 +1162,15 @@ def dn_attribute_property(private_name): return value return property(getter, setter) + +def restore_hostname(statestore): + """ + Restore hostname of a machine, if it was set before + """ + old_hostname = statestore.restore_state('network','hostname') + system_hostname = socket.gethostname() + if old_hostname is not None and old_hostname != system_hostname: + try: + run(['/bin/hostname', old_hostname]) + except CalledProcessError, e: + print >>sys.stderr, "Failed to set this machine hostname back to %s: %s" % (old_hostname, str(e)) -- cgit