Skip to content

Commit

Permalink
Version 4.8
Browse files Browse the repository at this point in the history
  • Loading branch information
rajeevkallur committed Jan 31, 2024
1 parent 2028d95 commit c609e0d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/redfish/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
""" Redfish restful library """

__all__ = ["rest", "ris", "hpilo"]
__version__ = "4.7.0.0"
__version__ = "4.8.0.0"

import logging

Expand Down
24 changes: 11 additions & 13 deletions src/redfish/rest/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ class HttpConnection(object):
def __init__(self, base_url, cert_data, **client_kwargs):
self._conn = None
self.base_url = base_url
self._connection_properties = client_kwargs
# Default values for connection properties
self._connection_properties = {
'timeout': urllib3.util.Timeout(connect=4800, read=4800),
'retries': urllib3.util.Retry(connect=50, read=50, redirect=50),
}
self._connection_properties.update(client_kwargs)
if cert_data:
if ("cert_file" in cert_data and cert_data["cert_file"]) or (
"ca_certs" in cert_data and cert_data["ca_certs"]
Expand Down Expand Up @@ -157,17 +162,13 @@ def _init_connection(self):
cert_reqs = "CERT_NONE"
self._connection_properties.update(self._connection_properties.pop("ca_cert_data"))

timeout = urllib3.util.Timeout(connect=4800, read=4800)
retries = urllib3.util.Retry(connect=50, read=50, redirect=50)
if self.proxy:
if self.proxy.startswith("socks"):
LOGGER.info("Initializing a SOCKS proxy.")
http = SOCKSProxyManager(
self.proxy,
cert_reqs=cert_reqs,
maxsize=50,
timeout=timeout,
retries=retries,
**self._connection_properties
)
else:
Expand All @@ -176,8 +177,6 @@ def _init_connection(self):
self.proxy,
cert_reqs=cert_reqs,
maxsize=50,
timeout=timeout,
retries=retries,
**self._connection_properties
)
else:
Expand All @@ -187,12 +186,11 @@ def _init_connection(self):
except KeyError:
pass

if "timeout" not in self._connection_properties:
http = PoolManager(
maxsize=50, cert_reqs=cert_reqs, timeout=timeout, retries=retries, **self._connection_properties
)
else:
http = PoolManager(cert_reqs=cert_reqs, maxsize=50, retries=retries, **self._connection_properties)
http = PoolManager(
cert_reqs=cert_reqs,
maxsize=50,
**self._connection_properties
)

self._conn = http.request

Expand Down
12 changes: 12 additions & 0 deletions src/redfish/rest/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

from six import BytesIO, StringIO, string_types, text_type
from six.moves import http_client
from urllib3.util import Timeout, Retry


class JSONEncoder(json.JSONEncoder):
Expand All @@ -49,6 +50,17 @@ def default(self, obj):
return jsondict
if isinstance(obj, bytes):
obj = obj.decode("utf-8")
if isinstance(obj, Timeout):
jsondict = OrderedDict()
jsondict["connect_timeout"] = obj.connect_timeout
jsondict["read_timeout"] = obj.read_timeout
return jsondict
if isinstance(obj, Retry):
jsondict = OrderedDict()
jsondict["connect"] = obj.connect
jsondict["read"] = obj.read
jsondict["redirect"] = obj.redirect
return jsondict
return json.JSONEncoder.default(self, obj)


Expand Down
3 changes: 1 addition & 2 deletions src/redfish/ris/ris.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ class RisMonolith(Dictable):
"""Monolithic cache of RIS data. This takes a :class:`redfish.rest.v1.RestClient` and uses it to
gather data from a server and saves it in a modifiable database called monolith.
:param client: client to use for data retrieval. Client is saved as a weakref, using it requires
parenthesis and will not survive if the client used in init is removed.
:param client: client to use for data retrieval.
:type client: :class:`redfish.rest.v1.RestClient`
:param typepath: The compatibility class to use for differentiating between Redfish/LegacyRest.
:type typepath: :class:`redfish.rest.ris.Typesandpathdefines`
Expand Down

0 comments on commit c609e0d

Please sign in to comment.