File 0001-azure-events-import-URLError-and-encode-postData-whe.patch of Package resource-agents.27073
From f2bf1d8a07ea810099b03469883cb7f485ab9ac1 Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Mon, 27 Jul 2020 10:09:43 +0200
Subject: [PATCH 1/1] azure-events: import URLError and encode postData when
necessary
---
heartbeat/azure-events.in | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/heartbeat/azure-events.in b/heartbeat/azure-events.in
index d4a166d9..a7f35946 100644
--- a/heartbeat/azure-events.in
+++ b/heartbeat/azure-events.in
@@ -13,8 +13,10 @@ import subprocess
import json
try:
import urllib2
+ from urllib2 import URLError
except ImportError:
import urllib.request as urllib2
+ from urllib.error import URLError
import socket
from collections import defaultdict
@@ -76,9 +78,13 @@ class azHelper:
Send a request to Azure's Azure Metadata Service API
"""
url = "%s/%s?api-version=%s" % (azHelper.metadata_host, endpoint, azHelper.api_version)
+ data = ""
ocf.logger.debug("_sendMetadataRequest: begin; endpoint = %s, postData = %s" % (endpoint, postData))
ocf.logger.debug("_sendMetadataRequest: url = %s" % url)
+ if postData and type(postData) != bytes:
+ postData = postData.encode()
+
req = urllib2.Request(url, postData)
req.add_header("Metadata", "true")
req.add_header("User-Agent", USER_AGENT)
--
2.26.2