Custom Component - ESXi Stats

And ideas please @wxt9861 ? I’m in a world of pain…!

I dont use ESXi at home, but being a VMware specialist and architect at work I admire this :slight_smile:

You’d get more help if you added the answers to the following questions to your post:

What version of HA?
What version of the integration?

Anyone experiencinf problme with integration not starting after upgrade to 2022.7? Itried few times to reconfigure, restart etc, but integration does not strt and always get error message in log:

2022-07-07 21:04:02 ERROR (SyncWorker_3) [custom_components.esxi_stats] EOF occurred in violation of protocol (_ssl.c:997)
2022-07-07 21:04:02 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry ESXi Server for esxi_stats
Traceback (most recent call last):
  File "/config/custom_components/esxi_stats/__init__.py", line 159, in connect
    conn = esx_connect(**conn_details)
  File "/config/custom_components/esxi_stats/esxi.py", line 18, in esx_connect
    si = SmartConnectNoSSL(host=host, user=user, pwd=pwd, port=port)
  File "/usr/local/lib/python3.10/site-packages/pyVim/connect.py", line 887, in SmartConnectNoSSL
    return SmartConnect(protocol=protocol,
  File "/usr/local/lib/python3.10/site-packages/pyVim/connect.py", line 845, in SmartConnect
    supportedVersion = __FindSupportedVersion(protocol,
  File "/usr/local/lib/python3.10/site-packages/pyVim/connect.py", line 718, in __FindSupportedVersion
    serviceVersionDescription = __GetServiceVersionDescription(protocol,
  File "/usr/local/lib/python3.10/site-packages/pyVim/connect.py", line 639, in __GetServiceVersionDescription
    tree = __GetElementTree(protocol, server, port,
  File "/usr/local/lib/python3.10/site-packages/pyVim/connect.py", line 606, in __GetElementTree
    conn.request("GET", path)
  File "/usr/local/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.10/http/client.py", line 1037, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.10/http/client.py", line 975, in send
    self.connect()
  File "/usr/local/lib/python3.10/http/client.py", line 1454, in connect
    self.sock = self._context.wrap_socket(self.sock,
  File "/usr/local/lib/python3.10/ssl.py", line 513, in wrap_socket
    return self.sslsocket_class._create(
  File "/usr/local/lib/python3.10/ssl.py", line 1071, in _create
    self.do_handshake()
  File "/usr/local/lib/python3.10/ssl.py", line 1342, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:997)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/esxi_stats/__init__.py", line 167, in connect
    raise ConfigEntryNotReady
homeassistant.exceptions.ConfigEntryNotReady: None

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 353, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/config/custom_components/esxi_stats/__init__.py", line 129, in async_setup_entry
    lic = await hass.async_add_executor_job(connect, hass, config, entry)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/esxi_stats/__init__.py", line 169, in connect
    esx_disconnect(conn)
UnboundLocalError: local variable 'conn' referenced before assignment

Nope my ESXi stats is working just fine.

What ESXi version?

Can you see the values if you go to the development page?

The host is on ESXi 6.0 U2 (free version)… quite old, but working fine for my needs. HA itself (core, OS, Supervisor) is all the way up to the most recent versions. Same for ESXi integration.
Going to Developers Tools/States everything is unavailable. Integration does not start at all:
Screenshot 2022-07-07 at 22.50.32
Up to today morning it was working perfectly fine, so I link this to 2022.7 update… but might be wrong…

How is your hass installed? Container, virtenv, etc?

The issue seems to be related to this. Issue 43998: Increase security of TLS settings in 3.10 - Python tracker

Your version of esxi is really old and I don’t know for sure if it supports tls1.2
Can you go into advanced settings (in esxi ui) and search for ESXiVPsDisabledProtocols and show the output?

Well, perhaps it is time for unscheduled weekend work and finally upgrade to newer version… Anyhow, here is what I found in settings:


So it seems that tls 1.2 is supported and is not disabled… Just for curiosity I enabled later SSL v3, but this did not changed situation, exactly same error in the log file.

In my case HA is installed as VM on mentioned ESXi host.

For python 3.10+ you need TLS1.3

OK, than it means some extra work ahead of me… Especially that there is no stright upgrade path from 6.0 to 7.0 :frowning: Perhaps clean instal :man_shrugging:

What about 6.5 release? I didn’t upgrade the core yet

Do you have a source for that? Per What’s New In Python 3.10 — Python 3.10.5 documentation TLS1.2 is now the minimum, no mention of TLS1.3 being a requirement.

Apologies, I was misinformed. Thanks.

You could test it by specifically disabling TLS1.0 and 1.1. Changing the value to sslv3,tlsv1,tlsv1.1 should force TLS1.2.

Otherwise, I would not jump from 6 > 7. That’s a big jump with potential hardware compatibility implications.

No change, same errors… Time to think about upgrade strategy :slight_smile:
If not jumping to v7 (which would be the most futureproof at the moment) what is the minimum version requirement to restore compatibility? Would it be 6.5, 6.7?

No problem going for v7 as long as your hardware is compatible. But if you’re been running esxi 6 on the same hardware since its release, i would be cautious. If your hardware relies on old drivers, you might run into issues. Definitely check the HCL before you proceed. Otherwise, 6.7 should be fine.

I have just installed the esxi hacs integration but I have no idea how to configure the integration?
Where can I fill in the host IP, username and password?