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

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