[Freeipa-devel] [PATCH] 893 always save value of hostname

2011-10-13 Thread Rob Crittenden
In backup_and_replace_hostname() the value of hostname wasn't being 
saved if it wasn't in /etc/sysconfig/network. This should save it in 
every case.


rob
From f1aae37ab5d7c6558ba16c2ed5832cda91072edd Mon Sep 17 00:00:00 2001
From: Rob Crittenden rcrit...@redhat.com
Date: Thu, 13 Oct 2011 17:58:27 -0400
Subject: [PATCH] Save the value of hostname even if it doesn't appear in
 /etc/sysconfig/network

https://fedorahosted.org/freeipa/ticket/1871
---
 ipapython/platform/redhat.py |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/ipapython/platform/redhat.py b/ipapython/platform/redhat.py
index 9825ddf..5ac3106 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)
-- 
1.7.6.4

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Re: [Freeipa-devel] [PATCH] 893 always save value of hostname

2011-10-13 Thread Alexander Bokovoy
On Thu, 13 Oct 2011, Rob Crittenden wrote:
 In backup_and_replace_hostname() the value of hostname wasn't being
 saved if it wasn't in /etc/sysconfig/network. This should save it in
 every case.
ACK
(yes, I need to go to bed)
-- 
/ Alexander Bokovoy

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 893 always save value of hostname

2011-10-13 Thread Rob Crittenden

Alexander Bokovoy wrote:

On Thu, 13 Oct 2011, Rob Crittenden wrote:

In backup_and_replace_hostname() the value of hostname wasn't being
saved if it wasn't in /etc/sysconfig/network. This should save it in
every case.

ACK
(yes, I need to go to bed)


Why bother, it's almost time to get up, right? ;-)

pushed to master and ipa-2-1

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel