diff --git a/examples/Redfish/mount_virtual_media_iso.py b/examples/Redfish/mount_virtual_media_iso.py index 3b3315e..0bc9acd 100644 --- a/examples/Redfish/mount_virtual_media_iso.py +++ b/examples/Redfish/mount_virtual_media_iso.py @@ -91,6 +91,7 @@ def mount_virtual_media_iso(_redfishobj, iso_url, media_type, boot_on_next_serve LOGIN_PASSWORD = "password" MEDIA_URL = "http:///media.iso" + #specify the type of content the media represents MEDIA_TYPE = "CD" #current possible options: Floppy, USBStick, CD, DVD #specify if the server should attempt to boot this media on system restart diff --git a/examples/Redfish/reboot_server.py b/examples/Redfish/reboot_server.py index 695a6dd..d529b12 100644 --- a/examples/Redfish/reboot_server.py +++ b/examples/Redfish/reboot_server.py @@ -46,9 +46,16 @@ def reboot_server(_redfishobj): if systems_response: system_reboot_uri = systems_response.obj['Actions']['#ComputerSystem.Reset']['target'] body = dict() + resettype = ['ForceRestart','GracefulRestart'] body['Action'] = 'ComputerSystem.Reset' - body['ResetType'] = "ForceRestart" - resp = _redfishobj.post(system_reboot_uri, body) + for reset in resettype: + if reset.lower() == "forcerestart": + body['ResetType'] = "ForceRestart" + resp = _redfishobj.post(system_reboot_uri, body) + elif reset.lower() == "gracefulrestart": + body['ResetType'] = "GracefulRestart" + resp = _redfishobj.post(system_reboot_uri, body) + #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended info #error message to see what went wrong if resp.status == 400: diff --git a/examples/Redfish/reset_server.py b/examples/Redfish/reset_server.py index 7a55430..b8d017d 100644 --- a/examples/Redfish/reset_server.py +++ b/examples/Redfish/reset_server.py @@ -42,9 +42,15 @@ def reset_server(_redfishobj): if managers_members_response: path = managers_members_response.obj["Actions"]["#ComputerSystem.Reset"]["target"] body = dict() + resettype = ['ForceRestart','GracefulRestart'] body["Action"] = "ComputerSystem.Reset" - body["ResetType"] = "ForceRestart" - resp = _redfishobj.post(path, body) + for reset in resettype: + if reset.lower() == "forcerestart": + body['ResetType'] = "ForceRestart" + resp = _redfishobj.post(path, body) + elif reset.lower() == "gracefulrestart": + body['ResetType'] = "GracefulRestart" + resp = _redfishobj.post(path, body) #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended info #error message to see what went wrong diff --git a/setup.py b/setup.py index e0d3c3d..4af5668 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ extras = {} setup(name='python-ilorest-library', - version='3.6.0.0', + version='4.0.0.0', description='iLO Rest Python Library', author = 'Hewlett Packard Enterprise', author_email = 'rajeevalochana.kallur@hpe.com', diff --git a/src/redfish/__init__.py b/src/redfish/__init__.py index a8e3b87..9529235 100644 --- a/src/redfish/__init__.py +++ b/src/redfish/__init__.py @@ -1,7 +1,7 @@ """ Redfish restful library """ __all__ = ["rest", "ris", "hpilo"] -__version__ = "3.6.0.0" +__version__ = "3.3.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 151f7f2..e804fdd 100644 --- a/src/redfish/hpilo/risblobstore2.py +++ b/src/redfish/hpilo/risblobstore2.py @@ -913,24 +913,29 @@ def gethprestchifhandle(): """Multi platform handle for chif hprest library""" excp = None libhandle = None - libnames = ( - ["ilorest_chif.dll", "hprest_chif.dll"] - if os.name == "nt" - else [ - "ilorest_chif_dev.so", - "hprest_chif_dev.so", - "ilorest_chif.so", - "hprest_chif.so", - ] - ) - for libname in libnames: - try: - libpath = BlobStore2.checkincurrdirectory(libname) + if os.name != "nt": + libpath = '/opt/ilorest/lib64/libilorestchif.so' + if os.path.isfile(libpath): libhandle = cdll.LoadLibrary(libpath) - if libhandle: - break - except Exception as exp: - excp = exp + if not libhandle: + libnames = ( + ["ilorest_chif.dll", "hprest_chif.dll"] + if os.name == "nt" + else [ + "ilorest_chif_dev.so", + "hprest_chif_dev.so", + "ilorest_chif.so", + "hprest_chif.so", + ] + ) + for libname in libnames: + try: + libpath = BlobStore2.checkincurrdirectory(libname) + libhandle = cdll.LoadLibrary(libpath) + if libhandle: + break + except Exception as exp: + excp = exp if libhandle: BlobStore2.setglobalhprestchifrandnumber(libhandle) diff --git a/src/redfish/rest/connections.py b/src/redfish/rest/connections.py index c3315ee..e9d53fe 100644 --- a/src/redfish/rest/connections.py +++ b/src/redfish/rest/connections.py @@ -156,17 +156,19 @@ def _init_connection(self): self._connection_properties.pop("ca_cert_data") except KeyError: pass - timeout = urllib3.util.Timeout(connect=40.0, read=None) + timeout = urllib3.Timeout(connect=60.0, read=60.0) if "timeout" not in self._connection_properties: http = PoolManager( cert_reqs=cert_reqs, maxsize=6, timeout=timeout, + retries=urllib3.Retry(connect=50, read=50, redirect=2), **self._connection_properties ) else: http = PoolManager( - cert_reqs=cert_reqs, maxsize=6, **self._connection_properties + cert_reqs=cert_reqs, maxsize=6, **self._connection_properties, + retries=urllib3.Retry(connect=50, read=50, redirect=2) ) self._conn = http.request diff --git a/src/redfish/rest/v1.py b/src/redfish/rest/v1.py index 23473ed..b21f3a6 100644 --- a/src/redfish/rest/v1.py +++ b/src/redfish/rest/v1.py @@ -610,9 +610,11 @@ class LegacyRestClient(RestClient): For full description of the arguments allowed see :class:`RestClient`""" def __init__(self, **client_kwargs): - super(LegacyRestClient, self).__init__( - default_prefix="/rest/v1", is_redfish=False, **client_kwargs - ) + kwargs = { + "default_prefix": client_kwargs.pop("default_prefix", "/rest/v1"), + "is_redfish": client_kwargs.pop("is_redfish", False), + } + super().__init__(**kwargs, **client_kwargs) class RedfishClient(RestClient): @@ -629,6 +631,8 @@ class RedfishClient(RestClient): For full description of the arguments allowed see :class:`RestClient`""" def __init__(self, **client_kwargs): - super(RedfishClient, self).__init__( - default_prefix="/redfish/v1/", is_redfish=True, **client_kwargs - ) + kwargs = { + "default_prefix": client_kwargs.pop("default_prefix", "/redfish/v1"), + "is_redfish": client_kwargs.pop("is_redfish", True), + } + super().__init__(**kwargs, **client_kwargs) diff --git a/src/redfish/ris/gen_compat.py b/src/redfish/ris/gen_compat.py index 7186154..86e4988 100644 --- a/src/redfish/ris/gen_compat.py +++ b/src/redfish/ris/gen_compat.py @@ -324,6 +324,7 @@ def __init__(self): self.regfilecollectiontype = "#MessageRegistryFileCollection." self.hpilolicensecollectiontype = "HpeiLOLicenseCollection." self.hpiloactivehealthsystemtype = "#HpeiLOActiveHealthSystem." + self.securityservice = "HpeSecurityService." self.hpiscsisoftwareinitiatortype = "HpeiSCSISoftwareInitiator." self.hpilofederationgrouptypecoll = "HpeiLOFederationGroupCollection." self.bootoverridetargettype = "BootSourceOverrideTarget@Redfish.AllowableValues" diff --git a/src/redfish/ris/resp_handler.py b/src/redfish/ris/resp_handler.py index f32b3e4..6ffab3f 100644 --- a/src/redfish/ris/resp_handler.py +++ b/src/redfish/ris/resp_handler.py @@ -19,6 +19,7 @@ with registries available on system, otherwise will return generic error responses.""" import logging +from rdmc_helper import IloLicenseError, ScepenabledError from redfish.ris.ris import SessionExpired from redfish.ris.utils import warning_handler, get_errmsg_type, json_traversal from redfish.ris.rmc_helper import ( @@ -87,6 +88,13 @@ def output_resp(self, response, dl_reg=False, verbosity=1): elif response.status == 401: raise SessionExpired() elif response.status == 403: + results = response.dict["error"]["@Message.ExtendedInfo"] + for result in results: + if ( + "License" in list(result.values())[0] + or "license" in list(result.values())[0] + ): + raise IloLicenseError("") raise IdTokenError() elif response.status == 412: warning_handler( @@ -102,6 +110,16 @@ def output_resp(self, response, dl_reg=False, verbosity=1): message_text=message_text, dl_reg=dl_reg, ) + if response.status == 400: + results = response.dict["error"]["@Message.ExtendedInfo"] + for result in results: + if ( + "License" in list(result.values())[0] + or "license" in list(result.values())[0] + ): + raise IloLicenseError("") + if "UnsupportedOperationACEEnabled" in list(result.values())[0]: + raise ScepenabledError("") if response.status > 299: raise IloResponseError("") else: diff --git a/src/redfish/ris/utils.py b/src/redfish/ris/utils.py index c800eda..08c5dbf 100644 --- a/src/redfish/ris/utils.py +++ b/src/redfish/ris/utils.py @@ -25,6 +25,8 @@ if six.PY3: from functools import reduce +if six.PY2: + from collections import Mapping from collections.abc import Mapping import jsonpath_rw