If your VMware ESX hosts are like our ESX hosts, the hosts are in clusters and you have Distributed Resource Scheduling (DRS) enabled. So in the vCenter GUI, when you right click a host and select “Enter Maintenance Mode”, DRS evacuates all running virtual machines to other hosts in the cluster.
I’m learning more about scripting actions like this with the vSphere Command-Line Interface (vCLI).
Specifically, the book says that the vCLI command “vicfg-hostops –operation enter” (“Entering and Exiting Maintenance Mode with vicfg-hostops”, page 28) does exactly the same thing. In fact that page in the manual says “If VMware DRS is in use, virtual machines that are running on a host that enters maintenance mode are migrated to another host automatically.”
This is *NOT* true. When you run this command, runnings vm’s are SUSPENDED, not migrated.
As far as I can tell, I’m doing everything correctly. Others have seen the same thing.
I’m not sure if it’s a “feature” or what, but be careful. Telling a host to enter maintenance mode with a vCLI script may not migrate running machines.
(If it matters, I’m running ESX 4.1, Update 1.)