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

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