VMware Cloud Community
FJ1200
Enthusiast
Enthusiast

Script HA migration?

Fairly new to Powershell and CLi but not to scripting - is it possible to script HA so that it restarts VMs on specific hosts?  Unfortunately the cost of 10 Enterprise ESXi 5.x licenses is prohibitive just for DRS and Accessibility Control won't do what we want.  I really want the affinity and anti-affinity rules.  Really, Really badly!

0 Kudos
3 Replies
LucD
Leadership
Leadership

Everything is possible in PowerCLI :smileygrin:

For a simple simulation of affinity/anti-affinity rules, you should do all start/stop of VMs through a script.

In that script you can test on which ESXi a VM can be started, talking into account the rules you would have in a file somewhere.

A tentative start VM logic

  • read all rules
  • get the VM that needs to be started
  • is there a rule that includes this VM
    • affinity: check where the affine VM(s) are running -> that will be the target ESXi
    • anti-affinity
      • get all available ESXi hosts
      • remove the ESXi that have VMs from the anti-affinity rule running
      • select an ESXi host from the remaining ones

That should be quite simple to code in PowerCLI.

But remember that this is a very crude simulation fo what HA offers.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

FJ1200
Enthusiast
Enthusiast

Thanks Luc.  It's just the migration to other hosts I'm looking at not restarting the VM on it's normally homed host.  Don't really have lots of time but I'll have a play with it and see how it goes.  Can't do the resource checking either.

I with they'd put DRS on the Standard license. 

0 Kudos
LucD
Leadership
Leadership

Ok, I see.

In that case you could still use the external file with the rules, and then eventually use the Move-VM cmdlet to vMotion the VM to the correct ESXi host.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos