Does anyone know how to initiate a host to go into maintenance mode on a specific timeframe?
I tried vicfg-hostops --operation enter on the VC4.1 cluster but it didn't initiate the automatic vmotions that I was expecting, it suspended all the virtual machines....good thing I tried this in my test area first!
It would be nice to have that feature in the scheduled tasks. That way I could schedule a host to go in maintenace mode in off peak hours and work on it during the daytime.
Thanks
VMotioner
the more experienced guys should come with suggestions shortly....
i haven't tried it myself...might give it a try to see whether it is possible (not familiar with cron jobs yet): creat a cron job to run vicfg-hostops --operation enter during off-peak hours and to vicfg-hostops --operation exit at specific time to exit maintenance mode.
I believe this should provide you with a schedule task type of things.
HTH
Did you configure the DRS in Automatic mode, and please make sure that VMs are showing fully automated under virtual machine options under DRS/HA edit settings.
Otherwise once you enter the host in to Maintenance mode, it wont do the VMotion. It would have given a warning to migrate the VMs manually.
Nithin
I was going to setup a cron job from the VMA interface but didn't get to it yet....manually typing in the command did a supend instead of a vmotion.
Yes DRS works perfectly when I manually initiate maintenance mode from VC. All the VMs vmotion to the other hosts in the cluster.
You're actually doing everything correctly if you have a fully automated DRS cluster and if you've manually enabled maintenance mode for the host and your VMs are being vMotioned off, then the functionality works. The issue is actually how VMware decided to implement the esxcfg-hostops and didn't bother to provide the option for users, it's not that you can't automate this via the CLI.
Basically, when you try to enter maintenance mode using their script, they're assuming this is for a stand alone host and forcing you to select either suspend or power off action for any powered on VMs. If there are detected powered on VMs, it'll default to suspen and that is what you're seeing. This is added logic by VMware and again based on the assumption that this is a stand alone host versus a host in a DRS enabled cluster.
The actual method if you care allows for you to migrate VMs and you can specify a flag to do so - http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.HostSystem.html#enterMai... and you can see how it's implemented in VIExt.pm module which is located in /usr/lib/perl5/5.8.8/VMware
Any who, short story short, I actually wrote some a host operation script awhile back that not only allows you to put a host into maintenance mode and migrate any existing VMs if it's part of a DRS enable cluster, it allows you to specify a given set of operations against a list of hosts, take a look at the script here and samples on how to use it - http://communities.vmware.com/docs/DOC-11435
Thanks lamw,
Your script works great, I setup a cron job from VMA 4.1 and works like a charm.
Cheers,
vmotioner
Glad to hear
Do you know if there is a way to run the cron job on VMA 4.1 without having to use the --password option?
I have all the hosts and the virtual Center added via vifp addserver. When I set the vifptarget vcentername I can run your script without have to provide username and password.....my problem is that I can't get this going via the cron job. Any Idea
Thanks