esxi_stats icon indicating copy to clipboard operation
esxi_stats copied to clipboard

Add graceful shutdown and reboot Host

Open Veuchez opened this issue 4 years ago • 7 comments

Could you please add the ability to graceful shutdown and restart the host? Thanks!

Veuchez avatar May 03 '20 08:05 Veuchez

This would be awesome! +1

arandax avatar May 03 '20 16:05 arandax

+1!

This would become really handy when trying to gracefully shutdown all VMs by leveraging the autostart/stop feature in vSphere.

Currently, when power goes out and my UPS starts running low, I execute a NodeRED flow that will shutdown all VMs. It'd be much easier to simply tell the host to shutdown and it will take care of gracefully shutting down the VMs.

Also, I have a RaspberryPI pinging my host every X time and, if it doesn't respond (and house power is not out), it sends a WOL package to wake it up. When it wakes up it automatically starts my VMs again.

So if power goes out, I'd turn off the host and when it comes back, my Pi would come back online automatically, ping the host and WOL it if it doesn't respond.

santibur06 avatar Jun 25 '20 14:06 santibur06

+1, sounds like a good idea, I would like to automate the start up and shutdown on my OpenVPN VM based on geolocation, when I leave the house.

@santibur06 would you possibly share your Node-RED config for shutting down VMs?

Thanks in advance.

levickij avatar Jul 27 '20 20:07 levickij

I am not sure how many people run vVotion vs single host. But I think both scenarios need to be addressed to make it successful.

if vMotion

  1. put the host into MM
  2. Wait until VMs are migrated
  3. Shut down host

OR in a single host confiigurationi

  1. Put the host into MM
  2. Shutdown all VMs
  3. Shut down host

wxt9861 avatar Jan 11 '21 16:01 wxt9861

This would be very nice!

megapearl avatar Oct 15 '21 21:10 megapearl

any chance to introduce ESXi gracefull shutdown?

Claudio1L avatar Apr 27 '22 06:04 Claudio1L

please aadd the shutdown host option... this will be very very useful for anyone like me that manage the UPS infrastructure via home assistant. I think is ok to issue the shutdown command without entering MM

andreaconfa avatar Apr 29 '22 19:04 andreaconfa

With power outages potentially becoming more common, this really would be useful to complete my full automation of a UPS-related power down.

Seaniau avatar Nov 29 '22 12:11 Seaniau

I am looking for an automated way to power on/power off gracefully my home lab ESXi host, no vSphere, (for work) using HA. This enhancement would be exactly what I would need. I would like to avoid MM so that a simple power on would start the VM in the auto-startup.

jens-fluegel avatar Jan 17 '23 10:01 jens-fluegel

I would even be okay with doing this from a script, but I can't get the list of associated VMs for a host from this integration. -- only the number of running VMs on the host?!?

ecoen66 avatar Oct 26 '23 02:10 ecoen66

@ecoen66 host shutdown is available in latest beta, but if you want to get a list of VMs associated with a host you can use a jinja template to create a list like this

{% set vms= namespace(name=[]) %}

# replace ''placeholder'' in the IF statement with name of ESXi host
{% for state in states.sensor %}
  {% if state_attr(state.entity_id, 'host_name') == 'placeholder' %}
    {% set vms.name = vms.name + [state_attr(state.entity_id,'name')] %}
  {% endif %}
{% endfor %}

{{ vms.name }}

wxt9861 avatar Oct 26 '23 03:10 wxt9861

Hmm… Is that supposed to shutdown all VMs cleanly prior to host shutdown? If so, that would save me a ton of script logic for my VMs, host + CIMC shutdown sequence for UCS C-series…

ecoen66 avatar Oct 31 '23 21:10 ecoen66

The host shutdown command is going to shutdown your host. There is no logic for handling VM shutdowns.

wxt9861 avatar Oct 31 '23 21:10 wxt9861

Released in 0.7.0

wxt9861 avatar Jan 12 '24 13:01 wxt9861