mirror of
https://opendev.org/x/pyghmi
synced 2025-01-15 04:07:48 +00:00
Merge "Tolerate spec deviations"
This commit is contained in:
commit
5e123f677f
@ -1456,7 +1456,7 @@ class Command(object):
|
||||
return
|
||||
for vmurl in vmurls:
|
||||
vminfo = self._do_web_request(vmurl, cache=False)
|
||||
if vminfo['ConnectedVia'] != 'NotConnected':
|
||||
if vminfo.get('ConnectedVia', None) != 'NotConnected':
|
||||
continue
|
||||
self._do_web_request(vmurl, {'Image': url, 'Inserted': True},
|
||||
'PATCH')
|
||||
|
@ -73,11 +73,12 @@ class OEMHandler(object):
|
||||
vmurls = [x['@odata.id'] for x in vmlist.get('Members', [])]
|
||||
for vminfo in fishclient._do_bulk_requests(vmurls):
|
||||
vminfo = vminfo[0]
|
||||
if vminfo['Image']:
|
||||
if vminfo.get('Image', None):
|
||||
imageurl = vminfo['Image'].replace(
|
||||
'/' + vminfo['ImageName'], '')
|
||||
yield media.Media(vminfo['ImageName'], imageurl)
|
||||
elif vminfo['Inserted'] and vminfo['ImageName']:
|
||||
elif vminfo.get('Inserted', None) and vminfo.get(
|
||||
'ImageName', None):
|
||||
yield media.Media(vminfo['ImageName'])
|
||||
|
||||
def get_inventory_descriptions(self, withids=False):
|
||||
|
@ -239,7 +239,12 @@ class SecureHTTPConnection(httplib.HTTPConnection, object):
|
||||
raise
|
||||
body = rsp.read()
|
||||
if rsp.getheader('Content-Encoding', None) == 'gzip':
|
||||
body = gzip.GzipFile(fileobj=io.BytesIO(body)).read()
|
||||
try:
|
||||
body = gzip.GzipFile(fileobj=io.BytesIO(body)).read()
|
||||
except IOError:
|
||||
# some implementations will send non-gzipped and claim it as
|
||||
# gzip
|
||||
pass
|
||||
if rsp.status >= 200 and rsp.status < 300:
|
||||
if body and not isinstance(body, str):
|
||||
body = body.decode('utf8')
|
||||
@ -307,7 +312,12 @@ class SecureHTTPConnection(httplib.HTTPConnection, object):
|
||||
% rsp.read())
|
||||
body = rsp.read()
|
||||
if rsp.getheader('Content-Encoding', None) == 'gzip':
|
||||
body = gzip.GzipFile(fileobj=io.BytesIO(body)).read()
|
||||
try:
|
||||
body = gzip.GzipFile(fileobj=io.BytesIO(body)).read()
|
||||
except IOError:
|
||||
# In case the implementation lied, let the body return
|
||||
# unprocessed
|
||||
pass
|
||||
return body
|
||||
|
||||
def get_upload_progress(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user