From 5a15c6b604e210d92827a23fdc88e706868a2171 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 14 May 2019 16:51:52 -0400 Subject: [PATCH] Fix system_configuration Some redfish implementations may use a trailing slash in registries. Additionally, any json may be gzipped. Support these two scenarios. Change-Id: I6437af21c927d13a74e8d914ed261412c1a3afa1 --- pyghmi/redfish/command.py | 2 ++ pyghmi/util/webclient.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index 4b2b72c5..4ab2c054 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -670,6 +670,8 @@ class Command(object): for cand in reglist.get('Members', []): cand = cand.get('@odata.id', '') candname = cand.split('/')[-1] + if candname == '': # implementation uses trailing slash + candname = cand.split('/')[-2] if candname == biosinfo['AttributeRegistry']: regurl = cand break diff --git a/pyghmi/util/webclient.py b/pyghmi/util/webclient.py index fe770b8b..2d0afe1c 100644 --- a/pyghmi/util/webclient.py +++ b/pyghmi/util/webclient.py @@ -17,6 +17,7 @@ # 2.6 as is found in commonly used enterprise linux distributions. import base64 +import gzip import json import pyghmi.exceptions as pygexc import socket @@ -195,6 +196,8 @@ class SecureHTTPConnection(httplib.HTTPConnection, object): webclient.request(method, url, referer=referer, headers=headers) rsp = webclient.getresponse() body = rsp.read() + if rsp.getheader('Content-Encoding', None) == 'gzip': + body = gzip.GzipFile(fileobj=StringIO.StringIO(body)).read() if rsp.status >= 200 and rsp.status < 300: return json.loads(body) if body else {}, rsp.status return body, rsp.status