From 2735a4ee096f87fda2e94029db7f059d7be28464 Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Thu, 5 Sep 2019 10:28:18 +0200
Subject: [PATCH] fence_zvmip: fix Python 3 issues

---
 agents/zvm/fence_zvmip.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/agents/zvm/fence_zvmip.py b/agents/zvm/fence_zvmip.py
index 5fbe53e4..e6bb01d1 100644
--- a/agents/zvm/fence_zvmip.py
+++ b/agents/zvm/fence_zvmip.py
@@ -37,7 +37,7 @@ def open_socket(options):
 	return conn
 
 def smapi_pack_string(string):
-	return struct.pack("!i%ds" % (len(string)), len(string), string)
+	return struct.pack("!i%ds" % (len(string)), len(string), string.encode("UTF-8"))
 
 def prepare_smapi_command(options, smapi_function, additional_args):
 	packet_size = 3*INT4 + len(smapi_function) + len(options["--username"]) + len(options["--password"])
@@ -126,7 +126,7 @@ def get_list_of_images(options, command, data_as_plug):
 		data = ""
 
 		while True:
-			read_data = conn.recv(1024, socket.MSG_WAITALL)
+			read_data = conn.recv(1024, socket.MSG_WAITALL).decode("UTF-8")
 			data += read_data
 			if array_len == len(data):
 				break
@@ -136,9 +136,9 @@ def get_list_of_images(options, command, data_as_plug):
 
 		parsed_len = 0
 		while parsed_len < array_len:
-			string_len = struct.unpack("!i", data[parsed_len:parsed_len+INT4])[0]
+			string_len = struct.unpack("!i", data[parsed_len:parsed_len+INT4].encode("UTF-8"))[0]
 			parsed_len += INT4
-			image_name = struct.unpack("!%ds" % (string_len), data[parsed_len:parsed_len+string_len])[0]
+			image_name = struct.unpack("!%ds" % (string_len), data[parsed_len:parsed_len+string_len].encode("UTF-8"))[0].decode("UTF-8")
 			parsed_len += string_len
 			images.add(image_name)
 
