2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-27 19:37:44 +00:00

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
This commit is contained in:
Jarrod Johnson 2019-05-14 16:51:52 -04:00
parent 904a2428c7
commit 5a15c6b604
2 changed files with 5 additions and 0 deletions

View File

@ -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

View File

@ -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