>From efc583c357538b3c20b8538dd8275c510e60bab7 Mon Sep 17 00:00:00 2001
From: Abhishek Koneru <akoneru@redhat.com>
Date: Thu, 28 Mar 2013 09:32:45 -0400
Subject: [PATCH] Change timeout from number of tries to total time.

Change the current implementation of time out as
number of tries to, the total time for trying to
get the status of the Tomcat.

Ticket #563
---
 base/deploy/man/man8/pkidestroy.8       |    2 +-
 base/deploy/src/scriptlets/pkihelper.py |   13 +++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/base/deploy/man/man8/pkidestroy.8 b/base/deploy/man/man8/pkidestroy.8
index 56dc379073efca4f164b609bd82a532f707df91e..d32e7cf840449ea75c3e1bfc1b94e10e293d5a4d 100644
--- a/base/deploy/man/man8/pkidestroy.8
+++ b/base/deploy/man/man8/pkidestroy.8
@@ -18,7 +18,7 @@
 pkidestroy \- Removes a subsystem from an instance of Certificate Server.
 
 .SH SYNOPSIS
-pkidestroy -s <subsystem> -i <instance> [-h] [-v] [-p <prefix>]
+pkidestroy -s <subsystem> -i <instance> [-h] [-v] [-u] [-W] [-p <prefix>]
 
 .SH DESCRIPTION
 Removes a subsystem from an instance of Certificate Server.  This utility removes any of the Java-based Certificate Server subsystems (CA, KRA, OCSP, and TKS).
diff --git a/base/deploy/src/scriptlets/pkihelper.py b/base/deploy/src/scriptlets/pkihelper.py
index 92707c55365faa2f7851fe1bd84b1edc37d2a67c..59051e05d854d955acf9b615f162aa8b7014fc9e 100644
--- a/base/deploy/src/scriptlets/pkihelper.py
+++ b/base/deploy/src/scriptlets/pkihelper.py
@@ -33,6 +33,7 @@ import shutil
 import string
 import subprocess
 import time
+from datetime import datetime
 from grp import getgrgid
 from grp import getgrnam
 from pwd import getpwnam
@@ -1015,14 +1016,14 @@ class instance:
             return None
 
     def wait_for_startup(self, timeout):
-        tries = 1   
-        status = self.get_instance_status()
+        start_time = datetime.today()
+        stop_time = start_time
+        status = None
         while status != "running":
-            if tries >= timeout:
-                return None
-            time.sleep(1)
+            if (stop_time-start_time).total_seconds() >= timeout:
+                break
             status = self.get_instance_status()
-            tries = tries + 1
+            stop_time = datetime.today()
         return status
 
 # PKI Deployment Directory Class
-- 
1.7.10.2

