diff options
| author | Petr Spacek <pspacek@redhat.com> | 2016-07-28 16:13:55 +0200 |
|---|---|---|
| committer | Jan Cholasta <jcholast@redhat.com> | 2016-08-10 10:48:05 +0200 |
| commit | 80e544e7a98ff22469e9d3a4f7bda2ed234601aa (patch) | |
| tree | f0c3514d94b47417089baa3859b03d0a7f1026d7 /ipaplatform/redhat | |
| parent | a83523e37ee70a10e49b40f8880c2d0fb3088562 (diff) | |
| download | freeipa-80e544e7a98ff22469e9d3a4f7bda2ed234601aa.tar.gz freeipa-80e544e7a98ff22469e9d3a4f7bda2ed234601aa.tar.xz freeipa-80e544e7a98ff22469e9d3a4f7bda2ed234601aa.zip | |
install: Call hostnamectl set-hostname only if --hostname option is used
This commit also splits hostname backup and configuration into two separate
functions. This allows us to backup hostname without setting it at the
same time.
https://fedorahosted.org/freeipa/ticket/6071
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipaplatform/redhat')
| -rw-r--r-- | ipaplatform/redhat/tasks.py | 13 |
1 files changed, 2 insertions, 11 deletions
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): |
