Blame SOURCES/bz1819965-3-azure-events-decode-when-type-not-str.patch

02ddf4
From 57424bd1f158f1ff597034e09ca90da864925a16 Mon Sep 17 00:00:00 2001
02ddf4
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
02ddf4
Date: Thu, 16 Jul 2020 09:58:55 +0200
02ddf4
Subject: [PATCH] azure-events: only decode() when exec() output not of type
02ddf4
 str
02ddf4
02ddf4
---
02ddf4
 heartbeat/azure-events.in | 10 ++++++----
02ddf4
 1 file changed, 6 insertions(+), 4 deletions(-)
02ddf4
02ddf4
diff --git a/heartbeat/azure-events.in b/heartbeat/azure-events.in
02ddf4
index a48a86309..d4a166d9f 100644
02ddf4
--- a/heartbeat/azure-events.in
02ddf4
+++ b/heartbeat/azure-events.in
02ddf4
@@ -179,6 +179,8 @@ class clusterHelper:
02ddf4
 		ocf.logger.debug("_exec: cmd = %s" % " ".join(command))
02ddf4
 		try:
02ddf4
 			ret = subprocess.check_output(command)
02ddf4
+			if type(ret) != str:
02ddf4
+				ret = ret.decode()
02ddf4
 			ocf.logger.debug("_exec: return = %s" % ret)
02ddf4
 			return ret.rstrip()
02ddf4
 		except Exception as err:
02ddf4
@@ -232,7 +234,7 @@ class clusterHelper:
02ddf4
 
02ddf4
 		nodes = []
02ddf4
 		nodeList = clusterHelper._exec("crm_node", "--list")
02ddf4
-		for n in nodeList.decode().split("\n"):
02ddf4
+		for n in nodeList.split("\n"):
02ddf4
 			nodes.append(n.split()[1])
02ddf4
 		ocf.logger.debug("getAllNodes: finished; return %s" % str(nodes))
02ddf4
 
02ddf4
@@ -303,7 +305,7 @@ class clusterHelper:
02ddf4
 			ocf.logger.warning("transitionSummary: received unexpected transition summary: %s" % summary)
02ddf4
 			return False
02ddf4
 		summary = summary.split("Transition Summary:")[1]
02ddf4
-		ret = summary.decode().split("\n").pop(0)
02ddf4
+		ret = summary.split("\n").pop(0)
02ddf4
 
02ddf4
 		ocf.logger.debug("transitionSummary: finished; return = %s" % str(ret))
02ddf4
 		return ret
02ddf4
@@ -324,7 +326,7 @@ class clusterHelper:
02ddf4
 		if len(resources) == 0:
02ddf4
 			ret = []
02ddf4
 		else:
02ddf4
-			ret = resources.decode().split("\n")
02ddf4
+			ret = resources.split("\n")
02ddf4
 
02ddf4
 		ocf.logger.debug("listOperationsOnNode: finished; return = %s" % str(ret))
02ddf4
 		return ret
02ddf4
@@ -470,7 +472,7 @@ class Node:
02ddf4
 
02ddf4
 		eventIDStr = clusterHelper.getAttr(attr_pendingEventIDs, node=node)
02ddf4
 		if eventIDStr:
02ddf4
-			eventIDs = eventIDStr.decode().split(",")
02ddf4
+			eventIDs = eventIDStr.split(",")
02ddf4
 		else:
02ddf4
 			eventIDs = None
02ddf4