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

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