Blame SOURCES/bz1793739-fence_vmware_rest-2-support-utf-8-vm-names.patch

91f48e
From 80aea3942aaca881349230a32b5dcc06c57de98a Mon Sep 17 00:00:00 2001
91f48e
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
91f48e
Date: Tue, 19 May 2020 15:10:16 +0200
91f48e
Subject: [PATCH] fence_vmware_rest: support UTF-8 VM names
91f48e
91f48e
---
91f48e
 agents/vmware_rest/fence_vmware_rest.py | 7 +++++--
91f48e
 1 file changed, 5 insertions(+), 2 deletions(-)
91f48e
91f48e
diff --git a/agents/vmware_rest/fence_vmware_rest.py b/agents/vmware_rest/fence_vmware_rest.py
91f48e
index 675de246..a038a096 100644
91f48e
--- a/agents/vmware_rest/fence_vmware_rest.py
91f48e
+++ b/agents/vmware_rest/fence_vmware_rest.py
91f48e
@@ -8,11 +8,14 @@
91f48e
 from fencing import *
91f48e
 from fencing import fail, run_delay, EC_LOGIN_DENIED, EC_STATUS
91f48e
 
91f48e
+if sys.version_info[0] > 2: import urllib.parse as urllib
91f48e
+else: import urllib
91f48e
+
91f48e
 state = {"POWERED_ON": "on", 'POWERED_OFF': "off", 'SUSPENDED': "off"}
91f48e
 
91f48e
 def get_power_status(conn, options):
91f48e
 	try:
91f48e
-		res = send_command(conn, "vcenter/vm?filter.names={}".format(options["--plug"]))["value"]
91f48e
+		res = send_command(conn, "vcenter/vm?filter.names={}".format(urllib.quote(options["--plug"])))["value"]
91f48e
 	except Exception as e:
91f48e
 		logging.debug("Failed: {}".format(e))
91f48e
 		fail(EC_STATUS)
91f48e
@@ -58,7 +61,7 @@ def get_list(conn, options):
91f48e
 			fail(EC_STATUS)
91f48e
 
91f48e
 	for r in res["value"]:
91f48e
-		outlets[r["name"]] = ("", state[r["power_state"]])
91f48e
+		outlets[r["name"].encode("UTF-8")] = ("", state[r["power_state"]])
91f48e
 
91f48e
 	return outlets
91f48e