From 90e716460e2e1acf95a74370d5e4dfd9f9138bcf Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Wed, 29 Sep 2010 13:55:54 -0400 Subject: Include time duration hints when configuring services in ipa-server-install. Give a better heads-up on how long the installation will take. Particularly important when configuring dogtag. ticket 139 --- ipaserver/install/cainstance.py | 4 ++-- ipaserver/install/dsinstance.py | 2 +- ipaserver/install/httpinstance.py | 2 +- ipaserver/install/krbinstance.py | 4 ++-- ipaserver/install/service.py | 22 ++++++++++++++++++++-- 5 files changed, 26 insertions(+), 8 deletions(-) (limited to 'ipaserver/install') diff --git a/ipaserver/install/cainstance.py b/ipaserver/install/cainstance.py index f1dcc9b51..1998928a3 100644 --- a/ipaserver/install/cainstance.py +++ b/ipaserver/install/cainstance.py @@ -245,7 +245,7 @@ class CADSInstance(service.Service): self.step("configuring directory to start on boot", self.__enable) self.step("restarting directory server", self.__restart_instance) - self.start_creation("Configuring directory server for the CA:") + self.start_creation("Configuring directory server for the CA", 30) def __setup_sub_dict(self): server_root = dsinstance.find_server_root() @@ -455,7 +455,7 @@ class CAInstance(service.Service): self.step("configuring certificate server to start on boot", self.__enable) self.step("restarting certificate server", self.__restart_instance) - self.start_creation("Configuring certificate server:") + self.start_creation("Configuring certificate server", 360) def create_instance(self): """ diff --git a/ipaserver/install/dsinstance.py b/ipaserver/install/dsinstance.py index 7dbfdaabe..0c79032d5 100644 --- a/ipaserver/install/dsinstance.py +++ b/ipaserver/install/dsinstance.py @@ -224,7 +224,7 @@ class DsInstance(service.Service): self.step("configuring directory to start on boot", self.__enable) - self.start_creation("Configuring directory server:") + self.start_creation("Configuring directory server", 60) def __enable(self): self.backup_state("enabled", self.is_enabled()) diff --git a/ipaserver/install/httpinstance.py b/ipaserver/install/httpinstance.py index af8fdde18..13d7a6601 100644 --- a/ipaserver/install/httpinstance.py +++ b/ipaserver/install/httpinstance.py @@ -83,7 +83,7 @@ class HTTPInstance(service.Service): self.step("restarting httpd", self.__start) self.step("configuring httpd to start on boot", self.__enable) - self.start_creation("Configuring the web interface") + self.start_creation("Configuring the web interface", 60) def __start(self): self.backup_state("running", self.is_running()) diff --git a/ipaserver/install/krbinstance.py b/ipaserver/install/krbinstance.py index 358fdaac1..736ba7362 100644 --- a/ipaserver/install/krbinstance.py +++ b/ipaserver/install/krbinstance.py @@ -178,7 +178,7 @@ class KrbInstance(service.Service): self.__common_post_setup() - self.start_creation("Configuring Kerberos KDC") + self.start_creation("Configuring Kerberos KDC", 30) self.kpasswd = KpasswdInstance() @@ -199,7 +199,7 @@ class KrbInstance(service.Service): self.__common_post_setup() - self.start_creation("Configuring Kerberos KDC") + self.start_creation("Configuring Kerberos KDC", 30) self.kpasswd = KpasswdInstance() self.kpasswd.create_instance() diff --git a/ipaserver/install/service.py b/ipaserver/install/service.py index 47489c09c..4affef457 100644 --- a/ipaserver/install/service.py +++ b/ipaserver/install/service.py @@ -26,6 +26,8 @@ from ipalib import uuid, errors import ldap from ipaserver import ipaldap import base64 +import time +import datetime def stop(service_name, instance_name=""): @@ -233,13 +235,29 @@ class Service: def step(self, message, method): self.steps.append((message, method)) - def start_creation(self, message): - self.print_msg(message) + def start_creation(self, message, runtime=-1): + if runtime > 0: + plural='' + est = time.localtime(runtime) + if est.tm_min > 0: + if est.tm_min > 1: + plural = 's' + self.print_msg('%s: Estimated time %d minute%s' % (message, est.tm_min, plural)) + else: + if est.tm_sec > 1: + plural = 's' + self.print_msg('%s: Estimated time %d second%s' % (message, est.tm_sec, plural)) + else: + self.print_msg(message) step = 0 for (message, method) in self.steps: self.print_msg(" [%d/%d]: %s" % (step+1, len(self.steps), message)) + s = datetime.datetime.now() method() + e = datetime.datetime.now() + d = e - s + logging.debug(" duration: %d seconds" % d.seconds) step += 1 self.print_msg("done configuring %s." % self.service_name) -- cgit