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

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