Make use of named well-known service

The systemd unit name of `named`(which is actually used) is platform-dependent:
debian - bind9-pkcs11.service
fedora - named-pkcs11.service
redhat - named-pkcs11.service

Other systems may have their own name of `bind` service.
But the default one (`named-pkcs11`) is assumed in many tests.
Of course, these tests fail on such platforms.

This can be easily fixed.
All platforms define well-knownservice `named`, which is linked to
the actually utilized one.

Fixes: https://pagure.io/freeipa/issue/7990
Signed-off-by: Stanislav Levin <slev@altlinux.org>
Reviewed-By: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
Stanislav Levin
2019-06-22 00:01:41 +03:00
committed by Rob Crittenden
parent 0184e967e5
commit 8f7d333565
2 changed files with 11 additions and 13 deletions

View File

@@ -42,6 +42,7 @@ from cryptography.hazmat.backends import default_backend
from ipapython import certdb
from ipapython import ipautil
from ipaplatform.paths import paths
from ipaplatform.services import knownservices
from ipapython.dn import DN
from ipalib import errors
from ipalib.util import get_reverse_zone_default, verify_host_resolvable
@@ -549,14 +550,8 @@ def install_adtrust(host):
# Restart named because it lost connection to dirsrv
# (Directory server restarts during the ipa-adtrust-install)
# we use two services named and named-pkcs11,
# if named is masked restart named-pkcs11
result = host.run_command(['systemctl', 'is-enabled', 'named'],
raiseonerr=False)
if result.stdout_text.startswith("masked"):
host.run_command(['systemctl', 'restart', 'named-pkcs11'])
else:
host.run_command(['systemctl', 'restart', 'named'])
host.run_command(['systemctl', 'restart',
knownservices.named.systemd_name])
# Check that named is running and has loaded the information from LDAP
dig_command = ['dig', 'SRV', '+short', '@localhost',
@@ -1581,7 +1576,8 @@ def assert_error(result, stderr_text, returncode=None):
def restart_named(*args):
time.sleep(20) # give a time to DNSSEC daemons to provide keys for named
for host in args:
host.run_command(["systemctl", "restart", "named-pkcs11.service"])
host.run_command(['systemctl', 'restart',
knownservices.named.systemd_name])
time.sleep(20) # give a time to named to be ready (zone loading)