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

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