summaryrefslogtreecommitdiffstats
path: root/ipapython/platform
diff options
context:
space:
mode:
authorAna Krivokapic <akrivoka@redhat.com>2013-06-20 11:53:29 +0200
committerAlexander Bokovoy <abokovoy@redhat.com>2013-07-11 12:39:28 +0300
commit3b93df4e4e4035fb9bb1c3a97673ddcaa4a582a0 (patch)
treeb09528730a5d527f6de37056117799949781272c /ipapython/platform
parent8d6d8459ebaef42959cbbaa771163976439f00bc (diff)
downloadfreeipa-3b93df4e4e4035fb9bb1c3a97673ddcaa4a582a0.tar.gz
freeipa-3b93df4e4e4035fb9bb1c3a97673ddcaa4a582a0.tar.xz
freeipa-3b93df4e4e4035fb9bb1c3a97673ddcaa4a582a0.zip
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
Diffstat (limited to 'ipapython/platform')
-rw-r--r--ipapython/platform/base/systemd.py39
1 files changed, 28 insertions, 11 deletions
diff --git a/ipapython/platform/base/systemd.py b/ipapython/platform/base/systemd.py
index a9c1ec032..9721ac1a9 100644
--- a/ipapython/platform/base/systemd.py
+++ b/ipapython/platform/base/systemd.py
@@ -18,8 +18,6 @@
#
import os
-import shutil
-import sys
from ipapython import ipautil
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_exists = None
- def service_instance(self, instance_name):
+ def service_instance(self, instance_name, operation=None):
if self.lib_path_exists is None:
self.lib_path_exists = os.path.exists(self.lib_path)
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
if self.lib_path_exists and len(instance_name) == 0:
if len(elements) == 1:
@@ -118,14 +122,27 @@ class SystemdService(base.PlatformService):
self.__wait_for_open_ports(self.service_instance(instance_name))
def is_running(self, instance_name=""):
- ret = True
- try:
- (sout, serr, rcode) = ipautil.run(["/bin/systemctl", "is-active", self.service_instance(instance_name)],capture_output=True)
- if rcode != 0:
- ret = False
- except ipautil.CalledProcessError:
- ret = False
- return ret
+ instance = self.service_instance(instance_name, 'is-active')
+
+ while True:
+ try:
+ (sout, serr, rcode) = ipautil.run(
+ ["/bin/systemctl", "is-active", instance],
+ capture_output=True
+ )
+ except ipautil.CalledProcessError as e:
+ 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):
installed = True