HewlettPackard / python-ilorest-library

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

Not able to connect to Gen8 iLO4 with the REST client #72

Closed nlin24 closed 5 years ago

nlin24 commented 5 years ago

Hello,

I am having trouble establishing a connection to a Gen8 iLO4 and wanted to see if anybody has a resolution to it. My script seems to work with Gen9 iLO4, with iLO Advanced Limited NRF, firmware version at 2.61 July 27 2018, but for unknown reason I can't get it to connect with a DL360 Gen8 iLO4, with iLO Advanced license, and firmware version at 2.55 Aug 16 2017. It fails for protocol error. I'm able to SSH to the Gen8 iLO4 and also access its web GUI. I am running on Ubuntu 18 LTS and Python 3.6.8. Any suggestions? Thanks in advance.

Error message:

nathan@boa:~$ PYTHONHTTPSVERIFY=0 python3 gen9_sys_data_buntu.py
Traceback (most recent call last):
  File "gen9_sys_data_buntu.py", line 128, in <module>
    gen9 = Gen9RestObj(iLO_https_url, iLO_account, iLO_password)
  File "gen9_sys_data_buntu.py", line 31, in __init__
    self.rest_client = rest_client(base_url=host, username=login_account, password=login_password)
  File "/home/nathan/.local/lib/python3.6/site-packages/redfish/rest/v1.py", line 1265, in get_client_instance
    is_redfish=is_redfish, cache=cache, proxy=proxy)
  File "/home/nathan/.local/lib/python3.6/site-packages/redfish/rest/v1.py", line 471, in __init__
    self.get_root_object()
  File "/home/nathan/.local/lib/python3.6/site-packages/redfish/rest/v1.py", line 620, in get_root_object
    raise excp
  File "/home/nathan/.local/lib/python3.6/site-packages/redfish/rest/v1.py", line 618, in get_root_object
    resp = self.get(str(self.__url.path)+self.default_prefix)
  File "/home/nathan/.local/lib/python3.6/site-packages/redfish/rest/v1.py", line 652, in get
    headers=headers)
  File "/home/nathan/.local/lib/python3.6/site-packages/redfish/rest/v1.py", line 863, in _rest_request
    raise RetriesExhaustedError()
redfish.rest.v1.RetriesExhaustedError
nathan@boa:~$

Redfish log:

2019-10-18 22:19:58,228 - redfish - INFO - HPE Restful API examples
2019-10-18 22:19:58,229 - redfish.rest.v1 - INFO - Initializing no proxy.
2019-10-18 22:19:58,229 - redfish.rest.v1 - INFO - Attempt 1 of /rest/v1
2019-10-18 22:24:58,531 - redfish.rest.v1 - INFO - Retrying /rest/v1 [HTTPSConnectionPool(host='172.168.100.184', port=443): Max retries exceeded with url: /rest/v1 (Caused by ProtocolError('Connection aborted.', OSError(0, 'Error')))]
2019-10-18 22:24:59,533 - redfish.rest.v1 - INFO - Initializing no proxy.
nlin24 commented 5 years ago

@Yergidy hey, I tried accessing the APIs on Gen8 again using the requests module; it seems to fail for Protocol Error as well. Please see below for more detail. Any thought? Thanks.

(venv36) nathan@boa:~$ python pull_ilo_data.py --iloip 192.168.1.188 --username admin-ro
password: iLO login password
> 
Traceback (most recent call last):
  File "/home/nathan/git/venv36/lib/python3.6/site-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/home/nathan/git/venv36/lib/python3.6/site-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/home/nathan/git/venv36/lib/python3.6/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
    conn.connect()
  File "/home/nathan/git/venv36/lib/python3.6/site-packages/urllib3/connection.py", line 394, in connect
    ssl_context=context,
  File "/home/nathan/git/venv36/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 383, in ssl_wrap_socket
    return context.wrap_socket(sock)
  File "/usr/lib/python3.6/ssl.py", line 407, in wrap_socket
    _context=self, _session=session)
  File "/usr/lib/python3.6/ssl.py", line 817, in __init__
    self.do_handshake()
  File "/usr/lib/python3.6/ssl.py", line 1077, in do_handshake
    self._sslobj.do_handshake()
  File "/usr/lib/python3.6/ssl.py", line 689, in do_handshake
    self._sslobj.do_handshake()
OSError: [Errno 0] Error
 
During handling of the above exception, another exception occurred:
 
Traceback (most recent call last):
  File "/home/nathan/git/venv36/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/home/nathan/git/venv36/lib/python3.6/site-packages/urllib3/connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/home/nathan/git/venv36/lib/python3.6/site-packages/urllib3/util/retry.py", line 400, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/nathan/git/venv36/lib/python3.6/site-packages/urllib3/packages/six.py", line 734, in reraise
    raise value.with_traceback(tb)
  File "/home/nathan/git/venv36/lib/python3.6/site-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/home/nathan/git/venv36/lib/python3.6/site-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/home/nathan/git/venv36/lib/python3.6/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
    conn.connect()
  File "/home/nathan/git/venv36/lib/python3.6/site-packages/urllib3/connection.py", line 394, in connect
    ssl_context=context,
  File "/home/nathan/git/venv36/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 383, in ssl_wrap_socket
    return context.wrap_socket(sock)
  File "/usr/lib/python3.6/ssl.py", line 407, in wrap_socket
    _context=self, _session=session)
  File "/usr/lib/python3.6/ssl.py", line 817, in __init__
    self.do_handshake()
  File "/usr/lib/python3.6/ssl.py", line 1077, in do_handshake
    self._sslobj.do_handshake()
  File "/usr/lib/python3.6/ssl.py", line 689, in do_handshake
    self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', OSError(0, 'Error'))
 
During handling of the above exception, another exception occurred:
 
Traceback (most recent call last):
  File "pull_ilo_data.py", line 405, in <module>
    download_configs(ilo_ip=iLO_creds["ip"], username=iLO_creds["username"], password=iLO_creds["password"])
  File "pull_ilo_data.py", line 311, in download_configs
    res = requests.post(session_api,headers=headers,json=data,verify=False)
  File "/home/nathan/git/venv36/lib/python3.6/site-packages/requests/api.py", line 116, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/home/nathan/git/venv36/lib/python3.6/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/nathan/git/venv36/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/nathan/git/venv36/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/home/nathan/git/venv36/lib/python3.6/site-packages/requests/adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', OSError(0, 'Error'))
(venv36) nathan@boa:~$
Yergidy commented 5 years ago

@nlin24 Just to be sure, you are using the iLO IP to connect and not the SSH IP?

nlin24 commented 5 years ago

Hey @Yergidy we got it working. It's a weird one, such that we observed the error on Gen8 occurs on Python 3.6.8 but not on Python 3.8.0. Not sure what's the root cause but seems to be Python interpreter related. Will probably just not-use version 3.6.8. Shall I go ahead and I close the ticket? Thanks.

By the way, yes, I am 100% sure I had the correct iLO IP and login credentials.

Yergidy commented 5 years ago

If you root caused the issue back to Python 3.6.8 you can close. Thanks!