krjhitch
Contributor
Contributor

Scheduled Task: Maintenance Mode

Is there something I'm missing?

There's no scheduled task for 'enter maint mode' in VirtualCenter (though there are useless ones, like schedule adding a host to the farm).

I've tried the vimsh for enter maint mode, and that works, provided there are no running VMs on the machine. The closest that I have come to what I want is using Vcenter to schedule tasks to move all the VMs off of a host, and provided that the host hasn't had any new VMs placed on it and none of the Vmotions off fail, a cron job that launches the vimsh/enter maint mode works.

But even in that case, virtualcenter does none of the logic/load balancing of where to place the VMs.

Is there something in the SDK? Or something someone has written? Or something someone knows of that I'm missing? Or is it something they're planning for a new version? I can't imagine that this wouldn't be helpful to just about everyone, since maint mode is there for that reason. Most people may just click to enter maint mode and let the DRS migrate the VMs, but in my environment, they're hyper-paranoid about 'user initiated action'. If I put a host into maint mode at 2:00PM and something happens to any of the VMs (although it never does) they'd be in a position they don't want to be, so they defer actions like that until 10PM. But rather than VPN in at 10PM and put a host into maint mode so that I can work on it the next day, I'd prefer to schedule vcenter to do the vmotion logic + maint mode.

Any ideas?

0 Kudos
3 Replies
weinstein5
Immortal
Immortal

Are you using DRS? - If you are nad have DRS in fully automatic mode it will vmtion all running vms off for you -

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
0 Kudos
krjhitch
Contributor
Contributor

I am using DRS. And it's in fully automatic, it's just at 5 stars, so it will only do anything if I put a host into maint mode or if I have VM affinity/anti-affinity set.

But my question is how do I schedule the entry into maint mode. As I said, I've created cron jobs to run the vimsh to enter maint mode, but on the host it fails if there are running VMs.

I am looking for some way to initiate it from vcenter. Perhaps a perl script, or batch file, or something that I can run as a scheduled task that will take the parameter of a host and kick off the entry into maint mode, which would either fail (if the VMs fail to evacuate for any reason) or succeed in vmotioning all the VMs off and then entering maint mode, instead of the current way, which is to create a seperate vcenter scheduled task to vmotion each machine off, and then run a shell script (via cron) on the host I want to go into maint mode.

(Looking back, my first post may not have been clear, but what I'm looking for is a way to schedule the entry into maint mode)

0 Kudos
kjb007
Immortal
Immortal

As you said, the vimsh commands aren't that reliable. Use poweshell vi toolkit on your vc server. It is better and provides a lot more functionality. You can create a powershell script, and put that script in windows scheduler to do what you want. It is a very simple powershell script (get-vmhost esx-host-name|set-vmhost -state maintenance)

-KjB

vExpert/VCP/VCAP vmwise.com / @vmwise -KjB
0 Kudos