summaryrefslogtreecommitdiffstats
path: root/ipaplatform
diff options
context:
space:
mode:
Diffstat (limited to 'ipaplatform')
-rw-r--r--ipaplatform/base/tasks.py7
-rw-r--r--ipaplatform/redhat/tasks.py13
2 files changed, 4 insertions, 16 deletions
diff --git a/ipaplatform/base/tasks.py b/ipaplatform/base/tasks.py
index c6860ce47..1e687b618 100644
--- a/ipaplatform/base/tasks.py
+++ b/ipaplatform/base/tasks.py
@@ -45,14 +45,11 @@ class BaseTaskNamespace(object):
raise NotImplementedError()
- def backup_and_replace_hostname(self, fstore, statestore, hostname):
+ def backup_hostname(self, fstore, statestore):
"""
Backs up the current hostname in the statestore (so that it can be
restored by the restore_hostname platform task).
- Makes sure that new hostname (passed via hostname argument) is set
- as a new pemanent hostname for this host.
-
No return value expected.
"""
@@ -109,7 +106,7 @@ class BaseTaskNamespace(object):
def restore_hostname(self, fstore, statestore):
"""
Restores the original hostname as backed up in the
- backup_and_replace_hostname platform task.
+ backup_hostname platform task.
"""
raise NotImplementedError()
diff --git a/ipaplatform/redhat/tasks.py b/ipaplatform/redhat/tasks.py
index 8ac88511e..dbe005abb 100644
--- a/ipaplatform/redhat/tasks.py
+++ b/ipaplatform/redhat/tasks.py
@@ -332,22 +332,13 @@ class RedHatTaskNamespace(BaseTaskNamespace):
return result
- def backup_and_replace_hostname(self, fstore, statestore, hostname):
- old_hostname = socket.gethostname()
- try:
- self.set_hostname(hostname)
- except ipautil.CalledProcessError as e:
- root_logger.debug(traceback.format_exc())
- root_logger.error(
- "Failed to set this machine hostname to %s (%s).",
- old_hostname, e
- )
-
+ def backup_hostname(self, fstore, statestore):
filepath = paths.ETC_HOSTNAME
if os.path.exists(filepath):
fstore.backup_file(filepath)
# store old hostname
+ old_hostname = socket.gethostname()
statestore.backup_state('network', 'hostname', old_hostname)
def restore_hostname(self, fstore, statestore):