Question

Apply host affinity to list of VMs

  • 20 October 2020
  • 3 replies
  • 1786 views

Is there a way using PowerShell to assign a large list of VMs to run from only specific hosts within an AHV cluster?  Basically is there a way to assign host affinity to a list of VMs?  I found commands for anti-affinity using the CLI but could not find anything related to setting affinity.  


This topic has been closed for comments

3 replies

Userlevel 6
Badge +5

Hi @ebertolasio

I have no guide to share with you, I am afraid. However I found something that could be useful to you, hopefully. Please test this in a lab before using it in production.

REST API / PowerShell Mass VM Affinity Control by Michell Grauwmans.

Thank you, this may be an option in the future.

I ended up working with support and was provided ACLI commands to set/unset affinity for the VMs.

acli vm.affinity_unset <vmname>,<vmname>

acli vm.affinity_set <vmname>,<vname> host_list=<hostUID>,<hostUID>

Userlevel 6
Badge +5

I didn’t think to mention aCLI to be honest, as you asked for the PowerShell. Glad to hear you were provided with a solution :)