summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2011-10-13 17:58:27 -0400
committerRob Crittenden <rcritten@redhat.com>2011-10-13 01:01:15 -0400
commit16fc9f847c9f54dcb2e4ceea91bffdd0cb2c112d (patch)
tree22f6e0a3d9a9904641cf63992d4004ab0fa94392
parent58918c4593fed9d546368483d4509798fbaa9322 (diff)
downloadfreeipa-16fc9f847c9f54dcb2e4ceea91bffdd0cb2c112d.tar.gz
freeipa-16fc9f847c9f54dcb2e4ceea91bffdd0cb2c112d.tar.xz
freeipa-16fc9f847c9f54dcb2e4ceea91bffdd0cb2c112d.zip
Save the value of hostname even if it doesn't appear in /etc/sysconfig/network
https://fedorahosted.org/freeipa/ticket/1871
-rw-r--r--ipapython/platform/redhat.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/ipapython/platform/redhat.py b/ipapython/platform/redhat.py
index 9825ddfd3..5ac310609 100644
--- a/ipapython/platform/redhat.py
+++ b/ipapython/platform/redhat.py
@@ -23,6 +23,7 @@ import re
import os
import stat
import sys
+import socket
from ipapython import ipautil
from ipapython.platform import base
@@ -133,6 +134,7 @@ def restore_context(filepath):
ipautil.run(["/sbin/restorecon", filepath], raiseonerr=False)
def backup_and_replace_hostname(fstore, statestore, hostname):
+ old_hostname = socket.gethostname()
try:
ipautil.run(['/bin/hostname', hostname])
except ipautil.CalledProcessError, e:
@@ -144,4 +146,5 @@ def backup_and_replace_hostname(fstore, statestore, hostname):
restore_context("/etc/sysconfig/network")
if 'HOSTNAME' in old_values:
statestore.backup_state('network', 'hostname', old_values['HOSTNAME'])
-
+ else:
+ statestore.backup_state('network', 'hostname', old_hostname)