mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-23 23:50:03 -06:00
Use correct DS instance in ipactl status
Make sure ipactl status check for correct DS instance. It should check for 'dirsrv@IPA-REALM' and not 'dirsrv.target'. https://fedorahosted.org/freeipa/ticket/3730
This commit is contained in:
parent
8d6d8459eb
commit
3b93df4e4e
@ -58,9 +58,10 @@ except ImportError:
|
|||||||
"""This exception is raised when a process run by check_call() returns
|
"""This exception is raised when a process run by check_call() returns
|
||||||
a non-zero exit status. The exit status will be stored in the
|
a non-zero exit status. The exit status will be stored in the
|
||||||
returncode attribute."""
|
returncode attribute."""
|
||||||
def __init__(self, returncode, cmd):
|
def __init__(self, returncode, cmd, output=None):
|
||||||
self.returncode = returncode
|
self.returncode = returncode
|
||||||
self.cmd = cmd
|
self.cmd = cmd
|
||||||
|
self.output = output
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Command '%s' returned non-zero exit status %d" % (self.cmd, self.returncode)
|
return "Command '%s' returned non-zero exit status %d" % (self.cmd, self.returncode)
|
||||||
|
|
||||||
@ -319,7 +320,7 @@ def run(args, stdin=None, raiseonerr=True,
|
|||||||
root_logger.debug('stderr=%s' % stderr)
|
root_logger.debug('stderr=%s' % stderr)
|
||||||
|
|
||||||
if p.returncode != 0 and raiseonerr:
|
if p.returncode != 0 and raiseonerr:
|
||||||
raise CalledProcessError(p.returncode, arg_string)
|
raise CalledProcessError(p.returncode, arg_string, stdout)
|
||||||
|
|
||||||
return (stdout, stderr, p.returncode)
|
return (stdout, stderr, p.returncode)
|
||||||
|
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
|
||||||
import sys
|
|
||||||
|
|
||||||
from ipapython import ipautil
|
from ipapython import ipautil
|
||||||
from ipapython.platform import base
|
from ipapython.platform import base
|
||||||
@ -36,12 +34,18 @@ class SystemdService(base.PlatformService):
|
|||||||
self.lib_path = os.path.join(self.SYSTEMD_LIB_PATH, self.systemd_name)
|
self.lib_path = os.path.join(self.SYSTEMD_LIB_PATH, self.systemd_name)
|
||||||
self.lib_path_exists = None
|
self.lib_path_exists = None
|
||||||
|
|
||||||
def service_instance(self, instance_name):
|
def service_instance(self, instance_name, operation=None):
|
||||||
if self.lib_path_exists is None:
|
if self.lib_path_exists is None:
|
||||||
self.lib_path_exists = os.path.exists(self.lib_path)
|
self.lib_path_exists = os.path.exists(self.lib_path)
|
||||||
|
|
||||||
elements = self.systemd_name.split("@")
|
elements = self.systemd_name.split("@")
|
||||||
|
|
||||||
|
# Make sure the correct DS instance is returned
|
||||||
|
if (elements[0] == 'dirsrv' and
|
||||||
|
not instance_name and
|
||||||
|
operation == 'is-active'):
|
||||||
|
return 'dirsrv@%s.service' % str(api.env.realm.replace('.', '-'))
|
||||||
|
|
||||||
# Short-cut: if there is already exact service name, return it
|
# Short-cut: if there is already exact service name, return it
|
||||||
if self.lib_path_exists and len(instance_name) == 0:
|
if self.lib_path_exists and len(instance_name) == 0:
|
||||||
if len(elements) == 1:
|
if len(elements) == 1:
|
||||||
@ -118,14 +122,27 @@ class SystemdService(base.PlatformService):
|
|||||||
self.__wait_for_open_ports(self.service_instance(instance_name))
|
self.__wait_for_open_ports(self.service_instance(instance_name))
|
||||||
|
|
||||||
def is_running(self, instance_name=""):
|
def is_running(self, instance_name=""):
|
||||||
ret = True
|
instance = self.service_instance(instance_name, 'is-active')
|
||||||
|
|
||||||
|
while True:
|
||||||
try:
|
try:
|
||||||
(sout, serr, rcode) = ipautil.run(["/bin/systemctl", "is-active", self.service_instance(instance_name)],capture_output=True)
|
(sout, serr, rcode) = ipautil.run(
|
||||||
if rcode != 0:
|
["/bin/systemctl", "is-active", instance],
|
||||||
ret = False
|
capture_output=True
|
||||||
except ipautil.CalledProcessError:
|
)
|
||||||
ret = False
|
except ipautil.CalledProcessError as e:
|
||||||
return ret
|
if e.returncode == 3 and 'activating' in str(e.output):
|
||||||
|
continue
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
# activating
|
||||||
|
if rcode == 3 and 'activating' in str(sout):
|
||||||
|
continue
|
||||||
|
# active
|
||||||
|
if rcode == 0:
|
||||||
|
return True
|
||||||
|
# not active
|
||||||
|
return False
|
||||||
|
|
||||||
def is_installed(self):
|
def is_installed(self):
|
||||||
installed = True
|
installed = True
|
||||||
|
Loading…
Reference in New Issue
Block a user