From f3f5e3c2ade8f316e08fc93f871059f119d32d52 Mon Sep 17 00:00:00 2001 From: Rajeevalochana Kallur Date: Wed, 5 Apr 2023 17:45:54 +0530 Subject: [PATCH] v4.1.0.0 --- src/redfish/__init__.py | 2 +- src/redfish/hpilo/risblobstore2.py | 9 ++++++++ src/redfish/hpilo/rishpilo.py | 9 ++++++-- src/redfish/rest/connections.py | 34 +++++++++++++++++------------- src/redfish/ris/rmc.py | 3 +++ src/redfish/ris/rmc_helper.py | 8 ++++--- 6 files changed, 44 insertions(+), 21 deletions(-) diff --git a/src/redfish/__init__.py b/src/redfish/__init__.py index 9529235..aa61b35 100644 --- a/src/redfish/__init__.py +++ b/src/redfish/__init__.py @@ -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 diff --git a/src/redfish/hpilo/risblobstore2.py b/src/redfish/hpilo/risblobstore2.py index e804fdd..a7a10f2 100644 --- a/src/redfish/hpilo/risblobstore2.py +++ b/src/redfish/hpilo/risblobstore2.py @@ -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 @@ -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: @@ -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: @@ -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) diff --git a/src/redfish/hpilo/rishpilo.py b/src/redfish/hpilo/rishpilo.py index d0fe9aa..8068581 100644 --- a/src/redfish/hpilo/rishpilo.py +++ b/src/redfish/hpilo/rishpilo.py @@ -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( @@ -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 = ( @@ -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 @@ -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 ) @@ -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: diff --git a/src/redfish/rest/connections.py b/src/redfish/rest/connections.py index 1537ce3..193fcd6 100644 --- a/src/redfish/rest/connections.py +++ b/src/redfish/rest/connections.py @@ -16,6 +16,7 @@ # -*- coding: utf-8 -*- """All Connections for interacting with REST.""" +import os import time import gzip import json @@ -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) @@ -133,13 +134,17 @@ 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: @@ -147,7 +152,9 @@ def _init_connection(self): http = ProxyManager( self.proxy, cert_reqs=cert_reqs, - maxsize=6, + maxsize=50, + timeout=timeout, + retries=retries, **self._connection_properties ) else: @@ -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 diff --git a/src/redfish/ris/rmc.py b/src/redfish/ris/rmc.py index 4830244..c4a068d 100644 --- a/src/redfish/ris/rmc.py +++ b/src/redfish/ris/rmc.py @@ -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: diff --git a/src/redfish/ris/rmc_helper.py b/src/redfish/ris/rmc_helper.py index fdd9cad..84b65c4 100644 --- a/src/redfish/ris/rmc_helper.py +++ b/src/redfish/ris/rmc_helper.py @@ -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( (