pgreco / rpms / ipa

Forked from forks/areguera/rpms/ipa 4 years ago
Clone
Blob Blame History Raw
From 3229a4c7ae1167103e954d5101bac1d56b28ce0d Mon Sep 17 00:00:00 2001
From: Jan Cholasta <jcholast@redhat.com>
Date: Tue, 13 Jan 2015 10:59:08 +0000
Subject: [PATCH] Do not crash on unknown services in
 installutils.stopped_service

https://fedorahosted.org/freeipa/ticket/4835

Reviewed-By: David Kupka <dkupka@redhat.com>
---
 ipaserver/install/installutils.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py
index 0ab09abea03c8b317e7d00466e127cda00ed17d9..e40535d4822f603ea432094c85396c59222dbe5c 100644
--- a/ipaserver/install/installutils.py
+++ b/ipaserver/install/installutils.py
@@ -870,20 +870,22 @@ def stopped_service(service, instance_name=""):
                       'the next set of commands is being executed.', service,
                       log_instance_name)
 
+    service_obj = services.service(service)
+
     # Figure out if the service is running, if not, yield
-    if not services.knownservices[service].is_running(instance_name):
+    if not service_obj.is_running(instance_name):
         root_logger.debug('Service %s%s is not running, continue.', service,
                           log_instance_name)
         yield
     else:
         # Stop the service, do the required stuff and start it again
         root_logger.debug('Stopping %s%s.', service, log_instance_name)
-        services.knownservices[service].stop(instance_name)
+        service_obj.stop(instance_name)
         try:
             yield
         finally:
             root_logger.debug('Starting %s%s.', service, log_instance_name)
-            services.knownservices[service].start(instance_name)
+            service_obj.start(instance_name)
 
 def check_entropy():
     '''
-- 
2.1.0