I have searched through the RCLI docs and can not seem to find the command that will shut down an ESXi host. Can someone provide this?
Thanks
John
There's another copy of the script in \Perl\apps\host that works. I had to enter maintenance mode first and then could shutdown the host. I was running this against an ESXi host directly (no VC server). See the syntax in the attached image.
Have you considered the Powershell toolkit for this as an alternative? It might be a little less awkward.
I don't know if the RCLI has this command or not, but try
shutdown -h now
Give hostops.pl a try - you'll find it in VMware VI Remote CLI\Perl\samples.
If it's a test system and you have SSH enabled then you can use /sbin/poweroff (and there is also /sbin/reboot).
What happens to VMs when you issue one of these commands?
Depends on how the VMs are configured. VMs can be configured to do a graceful shutdown. By default, I think they are configured for a power-off. You can configure this by selecting the server in VI Client > Configuration tab > Virtual Machine Startup/shutdown.
Bala
Dell Inc
Well it deifnitly seems to be the right script. However when I run the script with the appropriate variables I get this:
"Undefined subroutine &main::shutdown called at C:\Program Files\VMware\VMware VI
Remote CLI\Perl\samples\host\hostops.pl line 102."
Here is the full command line I'm using:
hostops.pl --username xxxxx --password xxxxx --host xxxxx --operation shutdown
There's another copy of the script in \Perl\apps\host that works. I had to enter maintenance mode first and then could shutdown the host. I was running this against an ESXi host directly (no VC server). See the syntax in the attached image.
Have you considered the Powershell toolkit for this as an alternative? It might be a little less awkward.
That did the trick. However I noticed a few things that may prevent me from using the script:
1) --target_host variable will only accept FQDN.
2) You MUST execute the enter_maintenance operation prior to shutdown. My intent is to create a script to shutdown resources during a power outage. Once the power comes back on the servers will still be in maintenance mode and therfore will not start associated guests automatically on restart. I'm wondering if I just shutdown the guests and let the servers just power off when the battery runs down? Looks like there would be minimal risk to the ESXi OS.
Thanks
2) Yes, that was the reply I got at the VMWare booth at MS TechEd in Orlando. Use traditional script to shut down guests, then let the hosts just die.
/H
Joboo12,
Did you ever figure out a way to do this?
Turn out you can but you need to slghtly edit VMware VI Remote CLI\Perl\samples\hostops.pl
The function call for shutdown is wrong on line 22:
"shutdown => \&shutdown," should be "shutdown => \&shutdown_host,"
Then change line 236: "$host->ShutdownHost(force => 0);" to "$host->ShutdownHost(force => 1);"
Host will then suspend all vms and shutdown gracefully, when power is returned assuming the server and vms are configureed to come up again all is good.
For a standalone ESXi box without VCenter I use the command:
hstops.pl --host <FQDN to Host> --server <FQDN to Host> --username **** --password **** --operation shutdown
Hope this helps someone
Ah! Yes! It works very well. I also tweaked the .pl script to only do a shutdown of the host with no suspend done. This way it behaves exactly like you have set it up with autostart/shutdown.
Nice!
/Henrik
Is it wroking to ESXi 4.1 free?