mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Fix: use DS socket check only for upgrade
To detect if DS server is running, use the slapd socket for upgrade, and the LDAP port for installation. Without enabled LDAPi socket checking doesnt work. https://fedorahosted.org/freeipa/ticket/4904 Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
This commit is contained in:
parent
4bcc2546d5
commit
f903c2d5bf
@ -25,6 +25,7 @@ Contains Red Hat OS family-specific service class implementations.
|
||||
import os
|
||||
import time
|
||||
import xml.dom.minidom
|
||||
import contextlib
|
||||
|
||||
from ipaplatform.tasks import tasks
|
||||
from ipaplatform.base import services as base_services
|
||||
@ -124,7 +125,8 @@ class RedHatDirectoryService(RedHatService):
|
||||
|
||||
return True
|
||||
|
||||
def restart(self, instance_name="", capture_output=True, wait=True):
|
||||
def restart(self, instance_name="", capture_output=True, wait=True,
|
||||
ldapi=False):
|
||||
# We need to explicitly enable instances to install proper symlinks as
|
||||
# dirsrv.target.wants/ dependencies. Standard systemd service class does it
|
||||
# on enable() method call. Unfortunately, ipa-server-install does not do
|
||||
@ -150,22 +152,35 @@ class RedHatDirectoryService(RedHatService):
|
||||
os.unlink(srv_lnk)
|
||||
os.symlink(srv_etc, srv_lnk)
|
||||
|
||||
super(RedHatDirectoryService, self).restart(instance_name,
|
||||
capture_output=capture_output, wait=wait)
|
||||
with self.__wait(instance_name, wait, ldapi) as wait:
|
||||
super(RedHatDirectoryService, self).restart(
|
||||
instance_name, capture_output=capture_output, wait=wait)
|
||||
|
||||
def wait_for_open_ports(self, instance_name=""):
|
||||
if instance_name.endswith('.service'):
|
||||
instance_name = instance_name[:-8]
|
||||
if instance_name.startswith('dirsrv@'):
|
||||
instance_name = instance_name[7:]
|
||||
def start(self, instance_name="", capture_output=True, wait=True,
|
||||
ldapi=False):
|
||||
with self.__wait(instance_name, wait, ldapi) as wait:
|
||||
super(RedHatDirectoryService, self).start(
|
||||
instance_name, capture_output=capture_output, wait=wait)
|
||||
|
||||
if instance_name:
|
||||
|
||||
ipautil.wait_for_open_socket(
|
||||
paths.SLAPD_INSTANCE_SOCKET_TEMPLATE % instance_name,
|
||||
self.api.env.startup_timeout)
|
||||
@contextlib.contextmanager
|
||||
def __wait(self, instance_name, wait, ldapi):
|
||||
if ldapi:
|
||||
instance_name = self.service_instance(instance_name)
|
||||
if instance_name.endswith('.service'):
|
||||
instance_name = instance_name[:-8]
|
||||
if instance_name.startswith('dirsrv'):
|
||||
# this is intentional, return the empty string if the instance
|
||||
# name is 'dirsrv'
|
||||
instance_name = instance_name[7:]
|
||||
if not instance_name:
|
||||
ldapi = False
|
||||
if ldapi:
|
||||
yield False
|
||||
socket_name = paths.SLAPD_INSTANCE_SOCKET_TEMPLATE % instance_name
|
||||
ipautil.wait_for_open_socket(socket_name,
|
||||
self.api.env.startup_timeout)
|
||||
else:
|
||||
super(RedHatDirectoryService, self).wait_for_open_ports()
|
||||
yield wait
|
||||
|
||||
|
||||
class RedHatIPAService(RedHatService):
|
||||
|
@ -24,6 +24,7 @@ import shutil
|
||||
import random
|
||||
import traceback
|
||||
from ipaplatform.paths import paths
|
||||
from ipaplatform import services
|
||||
from ipapython.ipa_log_manager import *
|
||||
from ipapython import ipaldap
|
||||
|
||||
@ -172,7 +173,7 @@ class IPAUpgrade(service.Service):
|
||||
self.realm = realm_name
|
||||
|
||||
def __start(self):
|
||||
super(IPAUpgrade, self).start()
|
||||
services.service(self.service_name).start(self.serverid, ldapi=True)
|
||||
|
||||
def __stop_instance(self):
|
||||
"""Stop only the main DS instance"""
|
||||
|
Loading…
Reference in New Issue
Block a user