Skip to content

Commit

Permalink
version 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rajeevkallur committed Dec 21, 2022
1 parent 9bc2836 commit ab39f1f
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 31 deletions.
1 change: 1 addition & 0 deletions examples/Redfish/mount_virtual_media_iso.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def mount_virtual_media_iso(_redfishobj, iso_url, media_type, boot_on_next_serve
LOGIN_PASSWORD = "password"

MEDIA_URL = "http://<SERVER_URL>/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
Expand Down
11 changes: 9 additions & 2 deletions examples/Redfish/reboot_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 8 additions & 2 deletions examples/Redfish/reset_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '[email protected]',
Expand Down
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.6.0.0"
__version__ = "3.3.0"

import logging
from redfish.rest.v1 import AuthMethod, LegacyRestClient, RedfishClient
Expand Down
39 changes: 22 additions & 17 deletions src/redfish/hpilo/risblobstore2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions src/redfish/rest/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 10 additions & 6 deletions src/redfish/rest/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
1 change: 1 addition & 0 deletions src/redfish/ris/gen_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]"
Expand Down
18 changes: 18 additions & 0 deletions src/redfish/ris/resp_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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(
Expand All @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions src/redfish/ris/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ab39f1f

Please sign in to comment.