Skip to main content
Question

Apply host affinity to list of VMs

  • October 20, 2020
  • 3 replies
  • 2031 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 replies.

3 replies

Alona
Nutanix Employee
Forum|alt.badge.img+5
  • Nutanix Employee
  • 426 replies
  • October 21, 2020

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.


  • Author
  • Voyager
  • 1 reply
  • October 21, 2020

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>


Alona
Nutanix Employee
Forum|alt.badge.img+5
  • Nutanix Employee
  • 426 replies
  • October 21, 2020

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 :)