Expose timeout option to Redfish modules (#54130)

* added timeout option to Redfish modules

* Apply suggestions from code review

Removed 'required: false' and added 'type: int' to 'timeout' documentation string.

Co-Authored-By: billdodd <billdodd@gmail.com>
This commit is contained in:
Bill Dodd 2019-03-26 12:19:24 -05:00 committed by John R Barker
parent a47edc9968
commit d8536e47d3
5 changed files with 57 additions and 13 deletions

View file

@ -15,9 +15,10 @@ HEADERS = {'content-type': 'application/json'}
class RedfishUtils(object):
def __init__(self, creds, root_uri):
def __init__(self, creds, root_uri, timeout):
self.root_uri = root_uri
self.creds = creds
self.timeout = timeout
self._init_session()
return
@ -29,7 +30,7 @@ class RedfishUtils(object):
url_password=self.creds['pswd'],
force_basic_auth=True, validate_certs=False,
follow_redirects='all',
use_proxy=False)
use_proxy=False, timeout=self.timeout)
data = json.loads(resp.read())
except HTTPError as e:
return {'ret': False, 'msg': "HTTP Error: %s" % e.code}
@ -49,7 +50,7 @@ class RedfishUtils(object):
url_password=self.creds['pswd'],
force_basic_auth=True, validate_certs=False,
follow_redirects='all',
use_proxy=False)
use_proxy=False, timeout=self.timeout)
except HTTPError as e:
return {'ret': False, 'msg': "HTTP Error: %s" % e.code}
except URLError as e:
@ -68,7 +69,7 @@ class RedfishUtils(object):
url_password=self.creds['pswd'],
force_basic_auth=True, validate_certs=False,
follow_redirects='all',
use_proxy=False)
use_proxy=False, timeout=self.timeout)
except HTTPError as e:
return {'ret': False, 'msg': "HTTP Error: %s" % e.code}
except URLError as e:
@ -87,7 +88,7 @@ class RedfishUtils(object):
url_password=self.creds['pswd'],
force_basic_auth=True, validate_certs=False,
follow_redirects='all',
use_proxy=False)
use_proxy=False, timeout=self.timeout)
except HTTPError as e:
return {'ret': False, 'msg': "HTTP Error: %s" % e.code}
except URLError as e: