Blame SOURCES/bz1771594-2-fence_redfish-fence_vmware_soap-suppress-warning.patch

21d5fd
From 559771f2c5a638f7e14ec9c0ef1068c86ee9d40e Mon Sep 17 00:00:00 2001
21d5fd
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
21d5fd
Date: Tue, 26 Nov 2019 14:09:14 +0100
21d5fd
Subject: [PATCH] fence_redfish/fence_vmware_soap: suppress warnings correctly
21d5fd
 with new python-requests
21d5fd
21d5fd
python-requests doesnt suppress warnings anymore, so it needs to be done in urllib3: https://stackoverflow.com/questions/27981545/suppress-insecurerequestwarning-unverified-https-request-is-being-made-in-pytho/28002687#28002687
21d5fd
---
21d5fd
 agents/redfish/fence_redfish.py         | 4 ++--
21d5fd
 agents/vmware_soap/fence_vmware_soap.py | 4 ++--
21d5fd
 2 files changed, 4 insertions(+), 4 deletions(-)
21d5fd
21d5fd
diff --git a/agents/redfish/fence_redfish.py b/agents/redfish/fence_redfish.py
21d5fd
index 390a4827..c7c6492c 100644
21d5fd
--- a/agents/redfish/fence_redfish.py
21d5fd
+++ b/agents/redfish/fence_redfish.py
21d5fd
@@ -12,7 +12,6 @@
21d5fd
 import atexit
21d5fd
 sys.path.append("@FENCEAGENTSLIBDIR@")
21d5fd
 
21d5fd
-from requests.packages.urllib3.exceptions import InsecureRequestWarning
21d5fd
 from fencing import *
21d5fd
 from fencing import fail_usage, run_delay
21d5fd
 
21d5fd
@@ -143,7 +142,8 @@ def main():
21d5fd
 
21d5fd
     # Disable insecure-certificate-warning message
21d5fd
     if "--ssl-insecure" in opt:
21d5fd
-        requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
21d5fd
+        import urllib3
21d5fd
+        urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
21d5fd
 
21d5fd
     # backwards compatibility for <ip>:<port>
21d5fd
     if options["--ip"].count(":") == 1:
21d5fd
diff --git a/agents/vmware_soap/fence_vmware_soap.py b/agents/vmware_soap/fence_vmware_soap.py
21d5fd
index dd1a4ed6..53e8d8f4 100644
21d5fd
--- a/agents/vmware_soap/fence_vmware_soap.py
21d5fd
+++ b/agents/vmware_soap/fence_vmware_soap.py
21d5fd
@@ -37,10 +37,10 @@ def soap_login(options):
21d5fd
 	if "--ssl" in options or "--ssl-secure" in options or "--ssl-insecure" in options:
21d5fd
 		if "--ssl-insecure" in options:
21d5fd
 			import ssl
21d5fd
-			from requests.packages.urllib3.exceptions import InsecureRequestWarning
21d5fd
+			import urllib3
21d5fd
 			if hasattr(ssl, '_create_unverified_context'):
21d5fd
 				ssl._create_default_https_context = ssl._create_unverified_context
21d5fd
-			requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
21d5fd
+			urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
21d5fd
 			verify = False
21d5fd
 		else:
21d5fd
 			verify = True