Do not log error when removing a non-existing file

When the uninstaller tries to remove /etc/systemd/system/httpd.d/ipa.conf and
the file does not exist, only log to debug instead of error.

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

Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
Florence Blanc-Renaud 2016-06-30 09:15:45 +02:00 committed by Martin Basti
parent 3ac3882631
commit d9ae9ee1b5

View File

@ -29,6 +29,7 @@ import os
import socket
import base64
import traceback
import errno
from cffi import FFI
from ctypes.util import find_library
@ -466,10 +467,16 @@ class RedHatTaskNamespace(BaseTaskNamespace):
try:
os.unlink(paths.SYSTEMD_SYSTEM_HTTPD_IPA_CONF)
except OSError as e:
root_logger.error(
'Error removing %s: %s',
paths.SYSTEMD_SYSTEM_HTTPD_IPA_CONF, e
)
if e.errno == errno.ENOENT:
root_logger.debug(
'Trying to remove %s but file does not exist',
paths.SYSTEMD_SYSTEM_HTTPD_IPA_CONF
)
else:
root_logger.error(
'Error removing %s: %s',
paths.SYSTEMD_SYSTEM_HTTPD_IPA_CONF, e
)
def set_hostname(self, hostname):
ipautil.run([paths.BIN_HOSTNAMECTL, 'set-hostname', hostname])