Blame SOURCES/bz1654973-fence_vmware_soap-cleanup-sigterm.patch

658b6c
From 116fb7d1253ac31a8f174187dfe9f4a0c6546ade Mon Sep 17 00:00:00 2001
658b6c
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
658b6c
Date: Fri, 7 Sep 2018 15:56:56 +0200
658b6c
Subject: [PATCH] fence_vmware_soap: cleanup when receiving SIGTERM
658b6c
658b6c
---
658b6c
 agents/vmware_soap/fence_vmware_soap.py | 7 ++++++-
658b6c
 1 file changed, 6 insertions(+), 1 deletion(-)
658b6c
658b6c
diff --git a/agents/vmware_soap/fence_vmware_soap.py b/agents/vmware_soap/fence_vmware_soap.py
658b6c
index b90edc9b..dd1a4ed6 100644
658b6c
--- a/agents/vmware_soap/fence_vmware_soap.py
658b6c
+++ b/agents/vmware_soap/fence_vmware_soap.py
658b6c
@@ -3,7 +3,7 @@
658b6c
 import sys
658b6c
 import shutil, tempfile, suds
658b6c
 import logging, requests
658b6c
-import atexit
658b6c
+import atexit, signal
658b6c
 sys.path.append("@FENCEAGENTSLIBDIR@")
658b6c
 
658b6c
 from suds.client import Client
658b6c
@@ -211,6 +211,9 @@ def logout():
658b6c
 	except Exception:
658b6c
 		pass
658b6c
 
658b6c
+def signal_handler(signum, frame):
658b6c
+	raise Exception("Signal \"%d\" received which has triggered an exit of the process." % signum)
658b6c
+
658b6c
 def main():
658b6c
 	global options_global
658b6c
 	global conn_global
658b6c
@@ -219,6 +222,8 @@ def main():
658b6c
 	atexit.register(atexit_handler)
658b6c
 	atexit.register(logout)
658b6c
 
658b6c
+	signal.signal(signal.SIGTERM, signal_handler)
658b6c
+
658b6c
 	options_global = check_input(device_opt, process_input(device_opt))
658b6c
 
658b6c
 	##