Blame SOURCES/bz1677327-1-fence_redfish-use-ipport-parameter.patch

77640d
From 9ebd2e2e36ae0de5c9164f4ac3fd29bdac0cab61 Mon Sep 17 00:00:00 2001
77640d
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
77640d
Date: Thu, 14 Feb 2019 10:03:33 +0100
77640d
Subject: [PATCH] fence_redfish: use "ipport" parameter and improve logging
77640d
77640d
---
77640d
 agents/redfish/fence_redfish.py | 9 ++++++---
77640d
 1 file changed, 6 insertions(+), 3 deletions(-)
77640d
77640d
diff --git a/agents/redfish/fence_redfish.py b/agents/redfish/fence_redfish.py
77640d
index 5b719d4b..28840058 100644
77640d
--- a/agents/redfish/fence_redfish.py
77640d
+++ b/agents/redfish/fence_redfish.py
77640d
@@ -22,7 +22,10 @@ def get_power_status(conn, options):
77640d
         fail_usage("Couldn't get power information")
77640d
     data = response['data']
77640d
 
77640d
-    logging.debug("PowerState is: " + data[u'PowerState'])
77640d
+    try:
77640d
+        logging.debug("PowerState is: " + data[u'PowerState'])
77640d
+    except Exception:
77640d
+        fail_usage("Unable to get PowerState: " + "https://" + options["--ip"] + ":" + str(options["--ipport"]) + options["--systems-uri"])
77640d
 
77640d
     if data[u'PowerState'].strip() == "Off":
77640d
         return "off"
77640d
@@ -52,7 +55,7 @@ def set_power_status(conn, options):
77640d
     return
77640d
 
77640d
 def send_get_request(options, uri):
77640d
-    full_uri = "https://" + options["--ip"] + uri
77640d
+    full_uri = "https://" + options["--ip"] + ":" + str(options["--ipport"]) + uri
77640d
     try:
77640d
         resp = requests.get(full_uri, verify=not "--ssl-insecure" in options,
77640d
                             auth=(options["--username"], options["--password"]))
77640d
@@ -62,7 +65,7 @@ def send_get_request(options, uri):
77640d
     return {'ret': True, 'data': data}
77640d
 
77640d
 def send_post_request(options, uri, payload, headers):
77640d
-    full_uri = "https://" + options["--ip"] + uri
77640d
+    full_uri = "https://" + options["--ip"] + ":" + str(options["--ipport"]) + uri
77640d
     try:
77640d
         requests.post(full_uri, data=json.dumps(payload),
77640d
                       headers=headers, verify=not "--ssl-insecure" in options,