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

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