Skip to content

Commit

Permalink
v4.1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rajeevkallur committed Apr 5, 2023
1 parent fd20533 commit f3f5e3c
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 21 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__ = "3.3.0"
__version__ = "4.1.0.0"

import logging
from redfish.rest.v1 import AuthMethod, LegacyRestClient, RedfishClient
Expand Down
9 changes: 9 additions & 0 deletions src/redfish/hpilo/risblobstore2.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,8 +931,10 @@ def gethprestchifhandle():
for libname in libnames:
try:
libpath = BlobStore2.checkincurrdirectory(libname)
LOGGER.info("Loading Library %s for libhpsrv", libpath)
libhandle = cdll.LoadLibrary(libpath)
if libhandle:
LOGGER.info("Got Libhandle %s for libhpsrv", libhandle)
break
except Exception as exp:
excp = exp
Expand Down Expand Up @@ -960,9 +962,12 @@ def initializecreds(username=None, password=None):
:param password: The password to login.
:type password: str.
"""
LOGGER.info("Inside initializecreds")
dll = BlobStore2.gethprestchifhandle()
if LOGGER.isEnabledFor(logging.DEBUG):
LOGGER.info("Enabling DEBUG from libhpsrv")
dll.enabledebugoutput()
LOGGER.info("Calling ChifInitialize from libhpsrv")
dll.ChifInitialize(None)
if username:
if not password:
Expand All @@ -974,7 +979,9 @@ def initializecreds(username=None, password=None):
usernew = create_string_buffer(username.encode("utf-8"))
passnew = create_string_buffer(password.encode("utf-8"))

LOGGER.info("Calling initiate_credentials from libhpsrv")
dll.initiate_credentials(usernew, passnew)
LOGGER.info("Calling ChifVerifyCredentials from libhpsrv")
credreturn = dll.ChifVerifyCredentials()
if not credreturn == BlobReturnCodes.SUCCESS:
if credreturn == hpiloreturncodes.CHIFERR_AccessDenied:
Expand All @@ -988,9 +995,11 @@ def initializecreds(username=None, password=None):
dll.ChifDisableSecurity()
else:
# if high security return False
LOGGER.info("Calling ChifIsSecurityRequired from libhpsrv")
if dll.ChifIsSecurityRequired() > 0:
return False
else:
LOGGER.info("Calling ChifDisableSecurity from libhpsrv")
dll.ChifDisableSecurity()

BlobStore2.unloadchifhandle(dll)
Expand Down
9 changes: 7 additions & 2 deletions src/redfish/hpilo/rishpilo.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,16 @@ def __init__(self, dll=None):
fhandle = c_void_p()
self.dll = dll
if LOGGER.isEnabledFor(logging.DEBUG):
LOGGER.info("Enabling DEBUG from libhpsrv")
self.dll.enabledebugoutput()
LOGGER.info("Calling ChifInitialize from libhpsrv")
self.dll.ChifInitialize(None)

self.dll.ChifCreate.argtypes = [c_void_p]
self.dll.ChifCreate.restype = c_uint32

try:
LOGGER.info("Calling ChifCreate from libhpsrv - handle = %s", fhandle)
status = self.dll.ChifCreate(byref(fhandle))
if status != BlobReturnCodes.SUCCESS:
raise HpIloInitialError(
Expand All @@ -128,6 +131,7 @@ def __init__(self, dll=None):
self.fhandle = fhandle

if not "skip_ping" in os.environ:
LOGGER.info("Calling ChifPing from libhpsrv - handle = %s", self.fhandle)
status = self.dll.ChifPing(self.fhandle)
if status != BlobReturnCodes.SUCCESS:
errmsg = (
Expand All @@ -139,7 +143,7 @@ def __init__(self, dll=None):
elif status == BlobReturnCodes.CHIFERR_AccessDenied:
errmsg = "You must be root/Administrator to use this program."
raise HpIloInitialError(errmsg)

LOGGER.info("Calling ChifSetRecvTimeout from libhpsrv - handle = %s", self.fhandle)
self.dll.ChifSetRecvTimeout(self.fhandle, 60000)
except:
raise
Expand All @@ -155,7 +159,7 @@ def chif_packet_exchange(self, data):
buff = create_string_buffer(bytes(data))

recbuff = create_string_buffer(datarecv)

LOGGER.info("Calling ChifPacketExchange from libhpsrv - handle = %s", self.fhandle)
error = self.dll.ChifPacketExchange(
self.fhandle, byref(buff), byref(recbuff), datarecv
)
Expand Down Expand Up @@ -213,6 +217,7 @@ def close(self):
"""Chif close function"""
try:
if self.fhandle is not None:
LOGGER.info("Calling ChifClose from libhpsrv - handle = %s", self.fhandle)
self.dll.ChifClose(self.fhandle)
self.fhandle = None
except Exception:
Expand Down
34 changes: 19 additions & 15 deletions src/redfish/rest/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

# -*- coding: utf-8 -*-
"""All Connections for interacting with REST."""
import os
import time
import gzip
import json
Expand Down Expand Up @@ -106,7 +107,7 @@ def __init__(self, base_url, cert_data, **client_kwargs):
self._connection_properties = 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"]
"ca_certs" in cert_data and cert_data["ca_certs"]
):
self._connection_properties.update({"ca_cert_data": cert_data})
self._proxy = self._connection_properties.pop("proxy", None)
Expand All @@ -133,21 +134,27 @@ def _init_connection(self):
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=6,
maxsize=50,
timeout=timeout,
retries=retries,
**self._connection_properties
)
else:
LOGGER.info("Initializing a HTTP proxy.")
http = ProxyManager(
self.proxy,
cert_reqs=cert_reqs,
maxsize=6,
maxsize=50,
timeout=timeout,
retries=retries,
**self._connection_properties
)
else:
Expand All @@ -156,20 +163,17 @@ def _init_connection(self):
self._connection_properties.pop("ca_cert_data")
except KeyError:
pass
timeout = urllib3.Timeout(connect=40.0, read=40.0)

if "timeout" not in self._connection_properties:
http = PoolManager(
cert_reqs=cert_reqs,
maxsize=6,
timeout=timeout,
retries=urllib3.Retry(connect=10, read=10, redirect=2),
**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=6, **self._connection_properties,
retries=urllib3.Retry(connect=10, read=10, redirect=2)
)
http = PoolManager(cert_reqs=cert_reqs, maxsize=50, retries=retries, **self._connection_properties)


self._conn = http.request

Expand Down
3 changes: 3 additions & 0 deletions src/redfish/ris/rmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,9 @@ def get_handler(

if results and getattr(results, "status", None) and results.status == 404:
return results

if results and results.status == 200 and sessionid:
return results

if not uncache and results.status == 200 and not sessionid:
if self.monolith:
Expand Down
8 changes: 5 additions & 3 deletions src/redfish/ris/rmc_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,11 @@ def logout_del_function(self, url=None):
)[-1]
sesurl = None
else:
loc = data["login"]["session_location"].split(
data["login"]["url"]
)[-1]
loc = None
if data["login"]["session_location"] is not None:
loc = data["login"]["session_location"].split(
data["login"]["url"]
)[-1]
sesurl = data["login"]["url"]
sessionlocs.append(
(
Expand Down

0 comments on commit f3f5e3c

Please sign in to comment.