Skip to content

Commit 82d7ae4

Browse files
committed
Version 6.1
1 parent 4ad0220 commit 82d7ae4

File tree

13 files changed

+201
-62
lines changed

13 files changed

+201
-62
lines changed

.flake8

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[flake8]
2+
max-line-length = 120
3+
extend-ignore = E203, E722, C901, E731
4+
exclude =
5+
.git,
6+
packaging,
7+
__pycache__,
8+
build,
9+
dist,
10+
docs
11+
max-complexity = 10

.isort.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[settings]
2+
profile = black
3+
skip_glob=.gitignore,.dockerignore,packaging/*,build/*,dist/*,.git,tests/*,docs/*

README.rst

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
python-ilorest-library
22
======================
3+
.. image:: https://travis-ci.org/HewlettPackard/python-ilorest-library.svg?branch=master
4+
:target: https://travis-ci.org/HewlettPackard/python-ilorest-library
35
.. image:: https://img.shields.io/pypi/v/python-ilorest-library.svg?maxAge=2592000
46
:target: https://pypi.python.org/pypi/python-ilorest-library
57
.. image:: https://img.shields.io/github/release/HewlettPackard/python-ilorest-library.svg?maxAge=2592000
@@ -8,14 +10,17 @@ python-ilorest-library
810
:target: https://raw.githubusercontent.com/HewlettPackard/python-ilorest-library/master/LICENSE
911
.. image:: https://img.shields.io/pypi/pyversions/python-ilorest-library.svg?maxAge=2592000
1012
:target: https://pypi.python.org/pypi/python-ilorest-library
13+
.. image:: https://api.codacy.com/project/badge/Grade/1283adc3972d42b4a3ddb9b96660bc07
14+
:target: https://www.codacy.com/app/rexysmydog/python-ilorest-library?utm_source=github.com&utm_medium=referral&utm_content=HewlettPackard/python-ilorest-library&utm_campaign=Badge_Grade
15+
1116

1217
.. contents:: :depth: 1
1318

1419
Description
1520
----------
1621
The python-ilorest-library is a python library built for interacting with the Redfish API remotely to any BMC that
1722
implements a Redfish API or any HPE system locally. The library also supports HPE's legacy REST API. Go to the library
18-
`documentation <https://hewlettpackard.github.io/python-ilorest-library/API-Overview.html>`_ for more details.
23+
`documentation <https://pages.github.hpe.com/intelligent-provisioning/python-redfish-library/>`_ for more details.
1924

2025
HPE RESTful API for iLO is a RESTful application programming interface for the
2126
management of iLO and iLO Chassis Manager based HPE servers. REST
@@ -69,17 +74,19 @@ Inband communication
6974
To enable support for inband communications, you must download the DLL/SO for your system. By downloading, you agree to the terms and conditions of the `Hewlett Packard Enterprise Software License Agreement`_.
7075
It must be placed in your working environment path.
7176

72-
Windows Chif Driver Download: ilorest_chif.dll_
77+
Windows Download: ilorest_chif.dll_
7378

74-
Linux Chif Driver Download: ilorest_chif.so_
79+
Linux Download: ilorest_chif.so_
7580

7681
.. _`Hewlett Packard Enterprise Software License Agreement` : https://www.hpe.com/us/en/software/licensing.html
77-
.. _ilorest_chif.dll: https://github.com/HewlettPackard/python-ilorest-library/releases/tag/v3.6.0.0/ilorest_chif.dll
78-
.. _ilorest_chif.so: https://github.com/HewlettPackard/python-ilorest-library/releases/tag/v3.6.0.0/ilorest_chif.so
82+
.. _ilorest_chif.dll: https://downloads.hpe.com/pub/softlib2/software1/pubsw-windows/p1463761240/v167985/ilorest_chif.dll
83+
.. _ilorest_chif.so: https://downloads.hpe.com/pub/softlib2/software1/pubsw-linux/p1093353304/v168967/ilorest_chif.so
7984

8085
Usage
8186
----------
82-
For usage documentation: https://hewlettpackard.github.io/python-ilorest-library/API-Overview.html
87+
For 3.x and greater versions of the library see the documentation for usage: https://pages.github.hpe.com/intelligent-provisioning/python-redfish-library/
88+
89+
For 2.x versions of the library documentation is located at the `Wiki <https://github.hpe.com/intelligent-provisioning/python-redfish-library/wiki>`_.
8390

8491
Contributing
8592
----------
@@ -115,8 +122,6 @@ History
115122
* 07/11/2019: Release of v2.5.1
116123
* 08/13/2019: Release of v2.5.2
117124
* 11/13/2019: Release of v3.0.0
118-
* 09/29/2022: Release of v3.6.0
119-
* 10/14/2024: Release of v5.3.0.0
120125

121126
Copyright and License
122127
---------------------

flake8.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.\src\redfish\ris\resp_handler.py:227:74: F821 undefined name 'key'

pylint.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!bin/bash
1+
#!/bin/bash
22
echo "Running pylint and exporting to file"
33
pylint -f parseable redfish | tee pylint.out
4-
echo "Pylint done!"
4+
echo "Pylint done!"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
extras = {}
44

55
setup(name='python-ilorest-library',
6-
version='6.0.0.0',
6+
version='6.1.0.0',
77
description='iLO Rest Python Library',
88
author='Hewlett Packard Enterprise',
99
author_email='[email protected]',

src/redfish/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
""" Redfish restful library """
22

33
__all__ = ["rest", "ris", "hpilo"]
4-
__version__ = "6.0.0.0"
4+
__version__ = "6.1.0.0"
55

66
import logging
77

src/redfish/hpilo/risblobstore2.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ def delete(self, key, namespace, retries=0):
558558
LOGGER.warning(f"Max retries reached. Unable to delete blob key={key}. Raising Blob2OverrideError.")
559559
raise Blob2OverrideError(errorcode)
560560
elif errorcode not in (BlobReturnCodes.SUCCESS, BlobReturnCodes.NOTMODIFIED):
561-
LOGGER.error(f"Error during blob deletion: {errorcode}. Raising HpIloError.")
561+
LOGGER.debug(f"Error during blob deletion: {errorcode}. Raising HpIloError.")
562562
raise HpIloError(errorcode)
563563
else:
564564
LOGGER.info(f"Blob deletion successful for key={key} in namespace={namespace}.")
@@ -1059,6 +1059,9 @@ def cert_login(self, cert_file, priv_key, key_pass):
10591059
@staticmethod
10601060
def gethprestchifhandle():
10611061
"""Multi platform handle for chif hprest library"""
1062+
import platform
1063+
if platform.system() == "Darwin":
1064+
raise ChifDllMissingError()
10621065
LOGGER.debug("Retrieving Chif library handle.")
10631066
excp = None
10641067
libhandle = None
@@ -1107,7 +1110,7 @@ def gethprestchifhandle():
11071110
LOGGER.debug("Successfully loaded Chif library.")
11081111
BlobStore2.setglobalhprestchifrandnumber(libhandle)
11091112
return libhandle
1110-
LOGGER.error("Failed to load Chif library: %s", str(e))
1113+
LOGGER.debug("Failed to load Chif library: %s", str(excp))
11111114
raise ChifDllMissingError(excp)
11121115

11131116
@staticmethod

src/redfish/ris/ris.py

Lines changed: 109 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
###
1616
# -*- coding: utf-8 -*-
1717
"""Monolith database implementation. Crawls Redfish and Legacy REST implementations
18-
and holds all data retrieved. The created database is called the **monolith** and referenced as
19-
such in the code documentation."""
18+
and holds all data retrieved. The created database is called the **monolith** and referenced as
19+
such in the code documentation."""
2020

2121
# ---------Imports---------
2222

@@ -455,6 +455,7 @@ def load(
455455
loadcomplete=False,
456456
path_refresh=False,
457457
json_out=False,
458+
single=True,
458459
):
459460
"""Walks the entire data model and caches all responses or loads an individual path into
460461
the monolith. Supports both threaded and sequential crawling.
@@ -489,7 +490,7 @@ def load(
489490
selectivepath = path
490491
if not selectivepath:
491492
selectivepath = self.client.default_prefix
492-
if loadtype == "href" and not self.client.base_url.startswith("blobstore://."):
493+
if loadtype == "href" and not self.client.base_url.startswith("blobstore://.") and not single:
493494
if not self.threads:
494495
for _ in range(6):
495496
workhand = LoadWorker(self.get_queue)
@@ -545,6 +546,65 @@ def load(
545546
if self.directory_load and init:
546547
self._populatecollections()
547548

549+
def loadallconfig(
550+
self,
551+
path=None,
552+
includelogs=False,
553+
init=False,
554+
crawl=True,
555+
loadtype="href",
556+
loadcomplete=False,
557+
path_refresh=False,
558+
json_out=False,
559+
single=True,
560+
):
561+
"""Walks the entire data model and caches all responses or loads an individual path into
562+
the monolith. Supports both threaded and sequential crawling.
563+
564+
:param path: The path to start the crawl from the provided path if crawling or
565+
loads the path into monolith. If path is not included, crawl will start with
566+
the default. The default is */redfish/v1/* or */rest/v1* depending on if the
567+
system is Redfish or LegacyRest.
568+
:type path: str.
569+
:param includelogs: Flag to determine if logs should be downloaded as well in the crawl.
570+
:type includelogs: bool
571+
:param init: Flag to determine if this is the initial load.
572+
:type init: bool
573+
:param crawl: Flag to determine if load should crawl through found links.
574+
:type crawl: bool
575+
:param loadtype: Flag to determine if loading standard links: *href* or schema links: *ref*.
576+
:type loadtype: str.
577+
:param loadcomplete: Flag to download the entire data model including registries and
578+
schemas.
579+
:type loadcomplete: bool
580+
:param path_refresh: Flag to reload the path specified, clearing any patches and overwriting the
581+
current data in the monolith.
582+
:type path_refresh: bool
583+
"""
584+
585+
selectivepath = path
586+
if not selectivepath:
587+
selectivepath = self.client.default_prefix
588+
self._load(
589+
selectivepath,
590+
originaluri=None,
591+
crawl=crawl,
592+
includelogs=includelogs,
593+
init=init,
594+
loadtype=loadtype,
595+
loadcomplete=loadcomplete,
596+
path_refresh=path_refresh,
597+
prevpath=None,
598+
)
599+
600+
if init:
601+
if LOGGER.getEffectiveLevel() >= 20 and not json_out:
602+
sys.stdout.write("Done\n")
603+
else:
604+
LOGGER.info("Done\n")
605+
if self.directory_load and init:
606+
self._populatecollections()
607+
548608
def _load(
549609
self,
550610
path,
@@ -580,7 +640,9 @@ def _load(
580640
if (path.endswith("?page=1") or path.endswith(".json")) and not loadcomplete:
581641
# Don't download schemas in crawl unless we are loading absolutely everything
582642
return
583-
elif not includelogs and crawl:
643+
elif path == "/" or "telemetry" in path.lower() or not path.startswith("/redfish/v1"):
644+
return
645+
elif not includelogs:
584646
# Only include logs when asked as there can be an extreme amount of entries
585647
if "/log" in path.lower():
586648
return
@@ -1090,23 +1152,55 @@ def _populatecollections(self):
10901152
colltype = ".".join(coll.split(".", 2)[:2]).split("#")[-1]
10911153
self.colltypes[typename].add(colltype)
10921154

1093-
def capture(self, redmono=False):
1094-
"""Crawls the server specified by the client and returns the entire monolith.
1155+
def capture(self, redmono=False, single=True):
1156+
"""Crawls the server and returns the monolith data or just headers and responses.
1157+
1158+
:param redmono: If True, returns only headers and responses; otherwise, returns full monolith data.
1159+
:type redmono: bool
1160+
:rtype: dict
1161+
"""
1162+
self.load(includelogs=False, crawl=True, loadcomplete=True, path_refresh=True, init=True, single=single)
1163+
1164+
if not redmono:
1165+
return self.to_dict()
10951166

1096-
:param redmono: Flag to return only the headers and responses instead of the entire monolith
1097-
member data.
1167+
ret = {}
1168+
try:
1169+
for x, v in self.paths.items():
1170+
if v:
1171+
v_resp = v.resp
1172+
if v_resp:
1173+
ret[x] = {"Headers": v_resp.getheaders(), "Response": v_resp.dict}
1174+
except Exception as e:
1175+
LOGGER.debug("Error in capture: %s", e)
1176+
ret = {}
1177+
return ret
1178+
1179+
def captureallconfig(self, single=True, exclueurl=None):
1180+
"""Crawls the server and returns the monolith data or just headers and responses.
1181+
1182+
:param redmono: If True, returns only headers and responses; otherwise, returns full monolith data.
10981183
:type redmono: bool
10991184
:rtype: dict
11001185
"""
1101-
self.load(includelogs=True, crawl=True, loadcomplete=True, path_refresh=True, init=True)
1102-
return (
1103-
self.to_dict()
1104-
if not redmono
1105-
else {
1106-
x: {"Headers": v.resp.getheaders(), "Response": v.resp.dict} for x, v in list(self.paths.items()) if v
1107-
}
1186+
self.loadallconfig(
1187+
includelogs=False, crawl=True, loadcomplete=True, path_refresh=True, init=True, single=single
11081188
)
11091189

1190+
ret = {}
1191+
1192+
try:
1193+
for x, v in self.paths.items():
1194+
if exclueurl.lower() not in x.lower():
1195+
if v:
1196+
v_resp = v.resp
1197+
if v_resp:
1198+
ret[x] = {"Headers": v_resp.getheaders(), "Response": v_resp.dict}
1199+
except Exception as e:
1200+
LOGGER.debug("Error in capture: %s", e)
1201+
ret = {}
1202+
return ret
1203+
11101204
def killthreads(self):
11111205
"""Function to kill threads on logout"""
11121206
threads = []

src/redfish/ris/ris_threaded.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ def run(self):
7979
# Don't download schemas in crawl unless we are loading absolutely everything
8080
self.queue.task_done()
8181
continue
82-
elif not includelogs and crawl:
82+
elif path == "/" or "telemetry" in path.lower() or not path.startswith("/redfish/v1"):
83+
self.queue.task_done()
84+
continue
85+
elif not includelogs:
8386
# Only include logs when asked as there can be an extreme amount of entries
8487
if "/log" in path.lower():
8588
self.queue.task_done()
@@ -255,4 +258,4 @@ def run(self):
255258

256259
def get_exception(self):
257260
"""Get any exception from the thread"""
258-
return self.exception
261+
return self.exception

0 commit comments

Comments
 (0)