|
|
bbedc2 |
From 7aa3c50d1d02dd26bdeac99c49ada72f842d88e8 Mon Sep 17 00:00:00 2001
|
|
|
bbedc2 |
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
|
|
|
bbedc2 |
Date: Thu, 17 Jan 2019 16:52:52 +0100
|
|
|
bbedc2 |
Subject: [PATCH] fence_redfish: fail when using invalid cert without
|
|
|
bbedc2 |
--ssl-insecure
|
|
|
bbedc2 |
|
|
|
bbedc2 |
---
|
|
|
bbedc2 |
agents/redfish/fence_redfish.py | 16 ++++++++++------
|
|
|
bbedc2 |
1 file changed, 10 insertions(+), 6 deletions(-)
|
|
|
bbedc2 |
|
|
|
bbedc2 |
diff --git a/agents/redfish/fence_redfish.py b/agents/redfish/fence_redfish.py
|
|
|
bbedc2 |
index 67ef67ab..5b719d4b 100644
|
|
|
bbedc2 |
--- a/agents/redfish/fence_redfish.py
|
|
|
bbedc2 |
+++ b/agents/redfish/fence_redfish.py
|
|
|
bbedc2 |
@@ -6,6 +6,7 @@
|
|
|
bbedc2 |
|
|
|
bbedc2 |
import sys
|
|
|
bbedc2 |
import re
|
|
|
bbedc2 |
+import logging
|
|
|
bbedc2 |
import json
|
|
|
bbedc2 |
import requests
|
|
|
bbedc2 |
import atexit
|
|
|
bbedc2 |
@@ -20,6 +21,9 @@ def get_power_status(conn, options):
|
|
|
bbedc2 |
if response['ret'] is False:
|
|
|
bbedc2 |
fail_usage("Couldn't get power information")
|
|
|
bbedc2 |
data = response['data']
|
|
|
bbedc2 |
+
|
|
|
bbedc2 |
+ logging.debug("PowerState is: " + data[u'PowerState'])
|
|
|
bbedc2 |
+
|
|
|
bbedc2 |
if data[u'PowerState'].strip() == "Off":
|
|
|
bbedc2 |
return "off"
|
|
|
bbedc2 |
else:
|
|
|
bbedc2 |
@@ -50,21 +54,21 @@ def set_power_status(conn, options):
|
|
|
bbedc2 |
def send_get_request(options, uri):
|
|
|
bbedc2 |
full_uri = "https://" + options["--ip"] + uri
|
|
|
bbedc2 |
try:
|
|
|
bbedc2 |
- resp = requests.get(full_uri, verify=False,
|
|
|
bbedc2 |
+ resp = requests.get(full_uri, verify=not "--ssl-insecure" in options,
|
|
|
bbedc2 |
auth=(options["--username"], options["--password"]))
|
|
|
bbedc2 |
data = resp.json()
|
|
|
bbedc2 |
- except:
|
|
|
bbedc2 |
- return {'ret': False}
|
|
|
bbedc2 |
+ except Exception as e:
|
|
|
bbedc2 |
+ fail_usage("Failed: send_get_request: " + str(e))
|
|
|
bbedc2 |
return {'ret': True, 'data': data}
|
|
|
bbedc2 |
|
|
|
bbedc2 |
def send_post_request(options, uri, payload, headers):
|
|
|
bbedc2 |
full_uri = "https://" + options["--ip"] + uri
|
|
|
bbedc2 |
try:
|
|
|
bbedc2 |
requests.post(full_uri, data=json.dumps(payload),
|
|
|
bbedc2 |
- headers=headers, verify=False,
|
|
|
bbedc2 |
+ headers=headers, verify=not "--ssl-insecure" in options,
|
|
|
bbedc2 |
auth=(options["--username"], options["--password"]))
|
|
|
bbedc2 |
- except:
|
|
|
bbedc2 |
- return {'ret': False}
|
|
|
bbedc2 |
+ except Exception as e:
|
|
|
bbedc2 |
+ fail_usage("Failed: send_post_request: " + str(e))
|
|
|
bbedc2 |
return {'ret': True}
|
|
|
bbedc2 |
|
|
|
bbedc2 |
def find_systems_resource(options):
|