Blame SOURCES/bz1695656-gcp-vpc-move-route-vip-fix-python3-encoding.patch

4d1913
From 17fe1dfeef1534b270e4765277cb8d7b42c4a9c4 Mon Sep 17 00:00:00 2001
4d1913
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
4d1913
Date: Fri, 5 Apr 2019 09:15:40 +0200
4d1913
Subject: [PATCH] gcp-vpc-move-route/gcp-vpc-move-vip: fix Python 3 encoding
4d1913
 issue
4d1913
4d1913
---
4d1913
 heartbeat/gcp-vpc-move-route.in | 2 +-
4d1913
 heartbeat/gcp-vpc-move-vip.in   | 4 ++--
4d1913
 2 files changed, 3 insertions(+), 3 deletions(-)
4d1913
4d1913
diff --git a/heartbeat/gcp-vpc-move-route.in b/heartbeat/gcp-vpc-move-route.in
4d1913
index 591b97b1c..7dd47150d 100644
4d1913
--- a/heartbeat/gcp-vpc-move-route.in
4d1913
+++ b/heartbeat/gcp-vpc-move-route.in
4d1913
@@ -193,7 +193,7 @@ def get_metadata(metadata_key, params=None, timeout=None):
4d1913
   url = '%s?%s' % (metadata_url, params)
4d1913
   request = urlrequest.Request(url, headers=METADATA_HEADERS)
4d1913
   request_opener = urlrequest.build_opener(urlrequest.ProxyHandler({}))
4d1913
-  return request_opener.open(request, timeout=timeout * 1.1).read()
4d1913
+  return request_opener.open(request, timeout=timeout * 1.1).read().decode("utf-8")
4d1913
 
4d1913
 
4d1913
 def validate(ctx):
4d1913
diff --git a/heartbeat/gcp-vpc-move-vip.in b/heartbeat/gcp-vpc-move-vip.in
4d1913
index bd6cf86cd..953d61ed7 100755
4d1913
--- a/heartbeat/gcp-vpc-move-vip.in
4d1913
+++ b/heartbeat/gcp-vpc-move-vip.in
4d1913
@@ -106,7 +106,7 @@ def get_metadata(metadata_key, params=None, timeout=None):
4d1913
   url = '%s?%s' % (metadata_url, params)
4d1913
   request = urlrequest.Request(url, headers=METADATA_HEADERS)
4d1913
   request_opener = urlrequest.build_opener(urlrequest.ProxyHandler({}))
4d1913
-  return request_opener.open(request, timeout=timeout * 1.1).read()
4d1913
+  return request_opener.open(request, timeout=timeout * 1.1).read().decode("utf-8")
4d1913
 
4d1913
 
4d1913
 def get_instance(project, zone, instance):
4d1913
@@ -162,7 +162,7 @@ def get_alias(project, zone, instance):
4d1913
 
4d1913
 def get_localhost_alias():
4d1913
   net_iface = get_metadata('instance/network-interfaces', {'recursive': True})
4d1913
-  net_iface = json.loads(net_iface.decode('utf-8'))
4d1913
+  net_iface = json.loads(net_iface)
4d1913
   try:
4d1913
     return net_iface[0]['ipAliases'][0]
4d1913
   except (KeyError, IndexError):