Log errors from backup_and_replace hostname to logger

Without logging errors to logger  is hard to debug issue from logfile.

https://fedorahosted.org/freeipa/ticket/5794

Reviewed-By: David Kupka <dkupka@redhat.com>
This commit is contained in:
Martin Basti 2016-04-19 18:47:25 +02:00
parent d3ac5125ce
commit 5e10b2eed2

View File

@ -332,8 +332,11 @@ class RedHatTaskNamespace(BaseTaskNamespace):
try:
self.set_hostname(hostname)
except ipautil.CalledProcessError as e:
print(("Failed to set this machine hostname to "
"%s (%s)." % (hostname, str(e))), file=sys.stderr)
root_logger.debug(traceback.format_exc())
root_logger.error(
"Failed to set this machine hostname to %s (%s).",
old_hostname, e
)
filepath = paths.ETC_HOSTNAME
if os.path.exists(filepath):