Closed megapearl closed 1 year ago
I reinstalled your component from the 'master' branch, configured the esxi servers again and problem is gone now.
Can you help me get a bit of info on this. Maybe this is a bug.
You have a vCenter cluster and when the component was connected via vCenter everything is working fine. However, when you configure the component to talk to the host directly you are having issue. Am I getting this correct?
Is the host and VM still part of a vCenter cluster?
That's right and yes the host and VM are still part of a vCenter cluster.
I changed from vCenter to ESXi directly, because vCenter itself is running as VM in ESXi, so if that one is down I can't control the other VM's via homeassistant. So I removed the component via HACS, and removed everything from configuration.yaml, and started over by reinstalling via HACS en configuring again via Configuration -> Devices & Services -> Add Integration -> ESXi Stats. Maybe there where some files cached locally from the old setup I don't know. I can't reproduce it anymore since I reinstalled all stuff, but if I can test some stuff for you please let me know.
Thank you. I will investigate.
The problem returned, how to debug? Using v0.7.0beta 2 of you component.
[547045256736] VM UUID not found Traceback (most recent call last): File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/websocket_api/commands.py", line 193, in handle_call_service await hass.services.async_call( File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/core.py", line 1634, in async_call task.result() File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/core.py", line 1671, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/entity_component.py", line 204, in handle_service await service.entity_service_call( File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/service.py", line 677, in entity_service_call future.result() # pop exception if have File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/entity.py", line 955, in async_request_call await coro File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/service.py", line 714, in _handle_entity_call await result File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/template/switch.py", line 159, in async_turn_on await self._on_script.async_run(context=self._context) File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/script.py", line 1275, in async_run await asyncio.shield(run.async_run()) File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/script.py", line 359, in async_run await self._async_step(log_exceptions=False) File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/script.py", line 379, in _async_step await getattr(self, handler)() File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/script.py", line 582, in _async_call_service_step await service_task File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/core.py", line 1634, in async_call task.result() File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/core.py", line 1671, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/home/homeassistant/.homeassistant/custom_components/esxi_stats/__init__.py", line 338, in vm_power vm_uuid = async_get_vm_details(vm_name) File "/home/homeassistant/.homeassistant/custom_components/esxi_stats/__init__.py", line 321, in async_get_vm_details raise ValueError("VM UUID not found") ValueError: VM UUID not found
It looks like using UUID as identifier is not reliable when a host is part of vCenter. I will take a closer look at how vCenter handles unique IDs for VMs so we can handle vCenter differently than standalone hosts. Time is a little tight right now but hope to have something soon.
Not quite sure if it is a bug or expected vCenter / ESXi behaviour that @megapearl didn't anticipate on.
When "asking" vCenter or ESXi directly for a VM, they are seen as different VMs. For example when VEEAM Image level backup makes backups of a VM through vCenter, it can't match the VM when you try to backup it through ESXi directly.
I have the same problem 'VM UUID' not found, whenever I configure the component using vCenter or ESXi directly.
Updated to 0.7.0beta4 and still having this problem, tried to add the ESXi hosts directly and tried the vCenter vm. Is there anything I can check to debug this issue?
That's still outstanding. See release notes.
Having the same problem using 0.7.0beta4. I connect directly to the host and host is not part of a vCenter and has never been part of it.
I did have a look at the function where i am getting the error: async_get_vm_details
and i see that the vm_name
parameter is passed down direclty from service call data. So if the vm name has spaces it will receive the error "VM UUID not found". Other places in code the vm name is lowered and spaces are replaced with underscore. This should also be done here. So the function would look something like this:
def async_get_vm_details(vm_name):
vm_name_cleaned = vm_name.replace(" ", "_").lower()
for _entry in hass.data[DOMAIN_DATA]:
if vm_name_cleaned in hass.data[DOMAIN_DATA][_entry]["vm"]:
return hass.data[DOMAIN_DATA][_entry]["vm"][vm_name_cleaned]["uuid"]
raise ValueError("VM UUID not found")
I tested that and it now works for me with this change made.
Other option would be ofc just mention that in the service call vm
parameter description that spaces need to be replaced with underscores and it has to be in lowercase.
Thanks for your solution! I adjusted the code also, and can start and stop VM's again.
Hi,
As I didn't have this problem before with vCenter, I do have it when configured the ESXi host directly. When I start or stop a virtual machine I got this error:
and
configuration.yaml snippet:
How to troubleshoot?