From 5bf1c9a6f7d734c296c8eb987cfc4f7e2a345130 Mon Sep 17 00:00:00 2001 From: Jan Cholasta 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 --- 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 c2b7ae512..1a4c170f4 100644 --- a/ipaserver/install/installutils.py +++ b/ipaserver/install/installutils.py @@ -931,20 +931,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():