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

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