On 05/31/2016 11:40 AM, Stanislav Laznicka wrote:
On 05/31/2016 10:22 AM, Stanislav Laznicka wrote:
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.
Self.NACK - can't add 'wait' agrument to service.Service.is_running this easy.

Should be fixed now.
From 7de58955f4876a3c9cfbfb22b38931b9dd95062e 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/base/services.py   |  4 ++--
 ipaplatform/redhat/services.py | 17 +++++++++++++++++
 ipaserver/install/service.py   |  4 ++--
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/ipaplatform/base/services.py b/ipaplatform/base/services.py
index 641a654183c52c0330cb4ece2a54c6bd0a96394c..a36b2f4ff7f325f882bdb9974e59259656b9a10e 100644
--- a/ipaplatform/base/services.py
+++ b/ipaplatform/base/services.py
@@ -148,7 +148,7 @@ class PlatformService(object):
     def restart(self, instance_name="", capture_output=True, wait=True):
         return
 
-    def is_running(self, instance_name=""):
+    def is_running(self, instance_name="", wait=True):
         return False
 
     def is_installed(self):
@@ -303,7 +303,7 @@ class SystemdService(PlatformService):
         if wait and self.is_running(instance_name):
             self.wait_for_open_ports(self.service_instance(instance_name))
 
-    def is_running(self, instance_name=""):
+    def is_running(self, instance_name="", wait=True):
         instance = self.service_instance(instance_name, 'is-active')
 
         while True:
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