summaryrefslogtreecommitdiffstats
path: root/ipapython/ipautil.py
diff options
context:
space:
mode:
authorMartin Kosek <mkosek@redhat.com>2012-12-05 10:50:05 +0100
committerMartin Kosek <mkosek@redhat.com>2012-12-05 13:30:31 +0100
commit3896bf370a142eb95a4341e381ee7b1ff0f0c3e2 (patch)
treef6f803315b928cd73d9c2115a93ee0f593d252f7 /ipapython/ipautil.py
parentc6efd4c7aaf6961142b6fae5d30dd9691a493447 (diff)
downloadfreeipa-3896bf370a142eb95a4341e381ee7b1ff0f0c3e2.tar.gz
freeipa-3896bf370a142eb95a4341e381ee7b1ff0f0c3e2.tar.xz
freeipa-3896bf370a142eb95a4341e381ee7b1ff0f0c3e2.zip
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
Diffstat (limited to 'ipapython/ipautil.py')
-rw-r--r--ipapython/ipautil.py12
1 files changed, 12 insertions, 0 deletions
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))