HewlettPackard / python-ilorest-library

Python library for interacting with devices which support a Redfish Service
Apache License 2.0
187 stars 92 forks source link

ChifDriverMissingOrNotFound with iLO 6 #154

Closed richotero closed 11 months ago

richotero commented 11 months ago

Example scripts from this repository work as expected with iLO 5 but fail with ChifDriverMissingOrNotFound with iLO 6. The problem can be demonstrated with get_ilo_ip.py. The CHIF driver is provided by the ilorest package from HPE's APT repository.

Modify get_ilo_ip.py for Local iLO

--- a/examples/Redfish/get_ilo_ip.py
+++ b/examples/Redfish/get_ilo_ip.py
@@ -63,18 +63,18 @@ def get_ilo_ip(_redfishobj, DISABLE_RESOURCE_DIR):

 if __name__ == "__main__":
     # When running on the server locally use the following commented values
-    #SYSTEM_URL = None
-    #LOGIN_ACCOUNT = None
-    #LOGIN_PASSWORD = None
+    SYSTEM_URL = None
+    LOGIN_ACCOUNT = None
+    LOGIN_PASSWORD = None

     # When running remotely connect using the secured (https://) address,
     # account name, and password to send https requests
     # SYSTEM_URL acceptable examples:
     # "https://10.0.0.100"
     # "https://ilo.hostname"
-    SYSTEM_URL = "https://10.0.0.100"
-    LOGIN_ACCOUNT = "admin"
-    LOGIN_PASSWORD = "password"
+    #SYSTEM_URL = "https://10.0.0.100"
+    #LOGIN_ACCOUNT = "admin"
+    #LOGIN_PASSWORD = "password"

     # flag to force disable resource directory. Resource directory and associated operations are
     # intended for HPE servers.

Failure on DL380 Gen11 (iLO 6, v1.30)

editshare@scarlet:~$ uname -a
Linux scarlet 5.15.0-85-generic #95~20.04.2-Ubuntu SMP Mon Sep 11 09:55:54 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

editshare@scarlet:~$ apt-cache policy ilorest
ilorest:
  Installed: 4.0.0.0-104
  Candidate: 4.0.0.0-104
  Version table:
 *** 4.0.0.0-104 500
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages
        100 /var/lib/dpkg/status
     3.3.0-79 500
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages
     3.2.2-33 500
        500 http://apt-mirror.editshare.com/devel 2023.2.0/editshare-ports amd64 Packages
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages
     3.1.1-12 500
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages
     3.1.0-32 500
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages
     3.0.1-8 500
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages
     3.0.0-38 500
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages
     2.4-126 500
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages
     2.3.4-2 500
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages
     2.3.3-8 500
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages
     2.2.2-7 500
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages
     2.1-74 500
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages

editshare@scarlet:~$ dpkg -l ilorest 
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  ilorest        4.0.0.0-104  amd64        RESTful Interface Tool

editshare@scarlet:~$ dpkg -L ilorest 
/.
/etc
/etc/ilorest
/etc/ilorest/redfish.conf
/usr
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/ilorest_chif.so
/usr/sbin
/usr/sbin/ilorest
/usr/share
/usr/share/doc
/usr/share/doc/ilorest
/usr/share/doc/ilorest/changelog.Debian.gz
/usr/share/doc/ilorest/copyright

editshare@scarlet:~$ ls -l /usr/lib/x86_64-linux-gnu/ilorest_chif.so 
-rw-r--r-- 1 root root 312840 Dec 14  2022 /usr/lib/x86_64-linux-gnu/ilorest_chif.so

editshare@scarlet:~$ md5sum /usr/lib/x86_64-linux-gnu/ilorest_chif.so 
58340b7ffbf4405483f4fa89548da53c  /usr/lib/x86_64-linux-gnu/ilorest_chif.so

editshare@scarlet:~$ python3 --version
Python 3.8.10

editshare@scarlet:~$ python3 -m venv tmp/venv

editshare@scarlet:~$ source tmp/venv/bin/activate

(venv) editshare@scarlet:~$ pip3 list
Package       Version
------------- -------
pip           20.0.2 
pkg-resources 0.0.0  
setuptools    44.0.0 

(venv) editshare@scarlet:~$ pip3 install python-ilorest-library
Processing ./.cache/pip/wheels/4d/1e/ed/04e68468ab2be1b909bea27f78dcac79e07812d0fff3aca55f/python_ilorest_library-4.5.0.0-py3-none-any.whl
Collecting jsonpatch
  Using cached jsonpatch-1.33-py2.py3-none-any.whl (12 kB)
Collecting urllib3
  Using cached urllib3-2.0.6-py3-none-any.whl (123 kB)
Processing ./.cache/pip/wheels/2b/f3/d4/2f6fb63766f0479b061d03bab249bbd44f116ae5c73b9f8a24/jsonpath_rw-1.4.0-py3-none-any.whl
Collecting six
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting jsonpointer
  Using cached jsonpointer-2.4-py2.py3-none-any.whl (7.8 kB)
Collecting decorator
  Using cached decorator-5.1.1-py3-none-any.whl (9.1 kB)
Collecting ply
  Using cached ply-3.11-py2.py3-none-any.whl (49 kB)
Installing collected packages: jsonpointer, jsonpatch, urllib3, decorator, ply, six, jsonpath-rw, python-ilorest-library
Successfully installed decorator-5.1.1 jsonpatch-1.33 jsonpath-rw-1.4.0 jsonpointer-2.4 ply-3.11 python-ilorest-library-4.5.0.0 six-1.16.0 urllib3-2.0.6

(venv) editshare@scarlet:~$ pip3 list
Package                Version
---------------------- -------
decorator              5.1.1  
jsonpatch              1.33   
jsonpath-rw            1.4.0  
jsonpointer            2.4    
pip                    20.0.2 
pkg-resources          0.0.0  
ply                    3.11   
python-ilorest-library 4.5.0.0
setuptools             44.0.0 
six                    1.16.0 
urllib3                2.0.6

(venv) editshare@scarlet:~$ sudo -E env PATH=$PATH python3 ~/src/python-ilorest-library/examples/Redfish/get_ilo_ip.py 
Traceback (most recent call last):
  File "/home/editshare/tmp/venv/lib/python3.8/site-packages/redfish/rest/connections.py", line 399, in _init_connection
    bs2 = BlobStore2()
  File "/home/editshare/tmp/venv/lib/python3.8/site-packages/redfish/hpilo/risblobstore2.py", line 177, in __init__
    self.channel = HpIlo(dll=lib)
  File "/home/editshare/tmp/venv/lib/python3.8/site-packages/redfish/hpilo/rishpilo.py", line 137, in __init__
    raise HpIloInitialError(errmsg)
redfish.hpilo.rishpilo.HpIloInitialError: chif

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/editshare/src/python-ilorest-library/examples/Redfish/get_ilo_ip.py", line 85, in <module>
    REDFISHOBJ = RedfishClient(base_url=SYSTEM_URL, username=LOGIN_ACCOUNT, \
  File "/home/editshare/tmp/venv/lib/python3.8/site-packages/redfish/rest/v1.py", line 616, in __init__
    super().__init__(**kwargs, **client_kwargs)
  File "/home/editshare/tmp/venv/lib/python3.8/site-packages/redfish/rest/v1.py", line 272, in __init__
    super(RestClient, self).__init__(
  File "/home/editshare/tmp/venv/lib/python3.8/site-packages/redfish/rest/v1.py", line 85, in __init__
    self._build_connection(**client_kwargs)
  File "/home/editshare/tmp/venv/lib/python3.8/site-packages/redfish/rest/v1.py", line 103, in _build_connection
    self.connection = Blobstore2Connection(**conn_kwargs)
  File "/home/editshare/tmp/venv/lib/python3.8/site-packages/redfish/rest/connections.py", line 386, in __init__
    self._init_connection(**self._connection_properties)
  File "/home/editshare/tmp/venv/lib/python3.8/site-packages/redfish/rest/connections.py", line 413, in _init_connection
    raise ChifDriverMissingOrNotFound()
redfish.rest.connections.ChifDriverMissingOrNotFound

Success on Apollo 4510 Gen10 (iLO 5, v2.60)

editshare@emma:~$ uname -a
Linux emma 5.15.0-83-generic #92~20.04.1-Ubuntu SMP Mon Aug 21 14:00:49 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

editshare@emma:~$ apt-cache policy ilorest
ilorest:
  Installed: 4.0.0.0-104
  Candidate: 4.0.0.0-104
  Version table:
 *** 4.0.0.0-104 500
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages
        100 /var/lib/dpkg/status
     3.3.0-79 500
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages
     3.2.2-33 500
        500 http://apt-repo.dev.editshare.com/devel 2023.2.0/editshare-ports amd64 Packages
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages
     3.1.1-12 500
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages
     3.1.0-32 500
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages
     3.0.1-8 500
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages
     3.0.0-38 500
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages
     2.4-126 500
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages
     2.3.4-2 500
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages
     2.3.3-8 500
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages
     2.2.2-7 500
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages
     2.1-74 500
        500 http://downloads.linux.hpe.com/SDR/repo/ilorest focal/current/non-free amd64 Packages

editshare@emma:~$ dpkg -l ilorest 
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  ilorest        4.0.0.0-104  amd64        RESTful Interface Tool

editshare@emma:~$ dpkg -L ilorest 
/.
/etc
/etc/ilorest
/etc/ilorest/redfish.conf
/usr
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/ilorest_chif.so
/usr/sbin
/usr/sbin/ilorest
/usr/share
/usr/share/doc
/usr/share/doc/ilorest
/usr/share/doc/ilorest/changelog.Debian.gz
/usr/share/doc/ilorest/copyright

editshare@emma:~$ ls -l /usr/lib/x86_64-linux-gnu/ilorest_chif.so 
-rw-r--r-- 1 root root 312840 Dec 14  2022 /usr/lib/x86_64-linux-gnu/ilorest_chif.so

editshare@emma:~$ md5sum /usr/lib/x86_64-linux-gnu/ilorest_chif.so 
58340b7ffbf4405483f4fa89548da53c  /usr/lib/x86_64-linux-gnu/ilorest_chif.so

editshare@emma:~$ python3 --version
Python 3.8.10

editshare@emma:~$ python3 -m venv tmp/venv

editshare@emma:~$ source tmp/venv/bin/activate

(venv) editshare@emma:~$ pip3 list
Package       Version
------------- -------
pip           20.0.2 
pkg-resources 0.0.0  
setuptools    44.0.0 

(venv) editshare@emma:~$ pip3 install python-ilorest-library
Processing ./.cache/pip/wheels/4d/1e/ed/04e68468ab2be1b909bea27f78dcac79e07812d0fff3aca55f/python_ilorest_library-4.5.0.0-py3-none-any.whl
Collecting jsonpointer
  Using cached jsonpointer-2.4-py2.py3-none-any.whl (7.8 kB)
Collecting six
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting jsonpatch
  Using cached jsonpatch-1.33-py2.py3-none-any.whl (12 kB)
Collecting urllib3
  Using cached urllib3-2.0.6-py3-none-any.whl (123 kB)
Processing ./.cache/pip/wheels/2b/f3/d4/2f6fb63766f0479b061d03bab249bbd44f116ae5c73b9f8a24/jsonpath_rw-1.4.0-py3-none-any.whl
Collecting ply
  Using cached ply-3.11-py2.py3-none-any.whl (49 kB)
Collecting decorator
  Using cached decorator-5.1.1-py3-none-any.whl (9.1 kB)
Installing collected packages: jsonpointer, six, jsonpatch, urllib3, ply, decorator, jsonpath-rw, python-ilorest-library
Successfully installed decorator-5.1.1 jsonpatch-1.33 jsonpath-rw-1.4.0 jsonpointer-2.4 ply-3.11 python-ilorest-library-4.5.0.0 six-1.16.0 urllib3-2.0.6

(venv) editshare@emma:~$ pip3 list
Package                Version
---------------------- -------
decorator              5.1.1  
jsonpatch              1.33   
jsonpath-rw            1.4.0  
jsonpointer            2.4    
pip                    20.0.2 
pkg-resources          0.0.0  
ply                    3.11   
python-ilorest-library 4.5.0.0
setuptools             44.0.0 
six                    1.16.0 
urllib3                2.0.6

(venv) editshare@emma:~$ sudo -E env PATH=$PATH python3 ~/src/python-ilorest-library/examples/Redfish/get_ilo_ip.py 
    Found resource directory at /redfish/v1/resourcedirectory

Showing iLO IPv4 Address Info on: /redfish/v1/Managers/1/EthernetInterfaces/1

[
    {
        "Address": "172.18.200.239",
        "AddressOrigin": "DHCP",
        "Gateway": "0.0.0.0",
        "SubnetMask": "255.255.128.0"
    }
]

Showing iLO IPv4 Address Info on: /redfish/v1/Managers/1/EthernetInterfaces/2

[
    {
        "Address": "0.0.0.0",
        "AddressOrigin": "DHCP",
        "Gateway": "0.0.0.0",
        "SubnetMask": "255.255.255.255"
    }
]

Showing iLO IPv4 Address Info on: /redfish/v1/Managers/1/EthernetInterfaces/3

[]
richotero commented 11 months ago

On my servers, the CHIF shared library is provided by the ilorest Debian package from HPE's SDR. I noticed that the current version number of the Python API is 4.5.0.0 whereas the latest version of ilorest in the SDR is 4.0.0.0. I thought there might be a compatibility problem between the v4.0.0.0 CHIF shared library and iLO 6 that would affect both the Python API and the ilorest program.

I found newer ilorest packages for RHEL on support.hpe.com, so I downloaded the v4.5.0.0 RPM, extracted the shared library file ilorest_chif.so, and replaced the old version on my servers (in /usr/lib/x86_64-linux-gnu). There was no change in behavior.

richotero commented 11 months ago

My problem can apparently be attributed to user error. I've been searching the web for information and I eventually came across some forum posts that mentioned an hpilo kernel module. I found that hpilo was loaded on the server with iLO 5 but not installed or loaded on the server with iLO 6.

I'm working with a custom Linux distribution that is derived from Ubuntu. The hpilo module should be provided by the linux-modules-extra package. It seems that the installer I built and used on the newer server had a slightly different set of packages or some other issue with package dependencies that resulted in linux-modules-extra and the hpilo module not being installed. After I corrected that, I can no longer reproduce the problem that's described here. Using the Python API to connect and make requests to iLO 5 and iLO 6 works as expected as long as hpilo is loaded and the CHIF driver shared library from the ilorest package is installed.