On 05/30/2016 12:54 PM, Jan Cholasta wrote:
On 30.5.2016 12:36, Martin Basti wrote:



On 26.05.2016 19:31, Stanislav Laznicka wrote:

Self NACK. I should not post patches when tired, sorry. Minor fix is
attached.


On 05/26/2016 07:21 PM, Stanislav Laznicka wrote:
Hello,

Please, see the attached patch. Fixes
https://fedorahosted.org/freeipa/ticket/5898

Standa







LGTM, if nobody is against this, I will push it in 2 days

NACK, please add `wait` argument and call self.wait_until_running(), same as in start() and restart().

A pretty good point, please see the modified patch.
From bce6e608e3b952a61ecb49542d43f576689a93aa Mon Sep 17 00:00:00 2001
From: Stanislav Laznicka <slazn...@redhat.com>
Date: Thu, 26 May 2016 15:24:15 +0200
Subject: [PATCH] Fixes CA always being presented as running

Even after manually stopping the pki-tomcatd service instance the
service's is_running() method would still return True.

https://fedorahosted.org/freeipa/ticket/5898
---
 ipaplatform/redhat/services.py | 17 +++++++++++++++++
 ipaserver/install/service.py   |  4 ++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/ipaplatform/redhat/services.py b/ipaplatform/redhat/services.py
index 92dae452a31a0b3680e9c407eccb120881cc9e25..849737059d54df5af47ae288ef97b933d9e869fe 100644
--- a/ipaplatform/redhat/services.py
+++ b/ipaplatform/redhat/services.py
@@ -222,6 +222,23 @@ class RedHatCAService(RedHatService):
         if wait:
             self.wait_until_running()
 
+    def is_running(self, instance_name="", wait=True):
+        if instance_name:
+            return super(RedHatCAService, self).is_running(instance_name)
+        try:
+            status = dogtag.ca_status()
+            if status == 'running':
+                return True
+            elif status == 'starting' and wait:
+                # Exception is raised if status is 'starting' even after wait
+                self.wait_until_running()
+                return True
+        except Exception as e:
+            root_logger.debug(
+                'Failed to check CA status: {err}'.format(err=e)
+            )
+        return False
+
 
 # Function that constructs proper Red Hat OS family-specific server classes for
 # services of specified name
diff --git a/ipaserver/install/service.py b/ipaserver/install/service.py
index 40767acd57d5e1fa8126144ca64f6951848ce214..c09dc9013b091e6eebcf9b297fef8337671ce40e 100644
--- a/ipaserver/install/service.py
+++ b/ipaserver/install/service.py
@@ -346,8 +346,8 @@ class Service(object):
     def restart(self, instance_name="", capture_output=True, wait=True):
         self.service.restart(instance_name, capture_output=capture_output, wait=wait)
 
-    def is_running(self):
-        return self.service.is_running()
+    def is_running(self, instance_name="", wait=True):
+        return self.service.is_running(instance_name, wait)
 
     def install(self):
         self.service.install()
-- 
2.5.5

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to