Configuring a VM to VM Anti-Affinity Rule on Nutanix AHV Running AOS 5.0
This how-to will show you how to configure a VM to VM anti-affinity rule on Nutanix AOS 5.0.
For reference, the official documentation on this feature is found at: https://portal.nutanix.com/#/page/docs/details?targetId=Web-Console-Guide-Prism-v50:ahv-ahv-vm-anti-affinity-t.html
Currently, on AOS 5.0, you can set a VM to Host affinity rule right within Prism by editing the VM properties. However, setting up a VM to VM anti-affinity rule will need to be done via the Acropolis CLI (ACLI). To configure VM to VM anti-affinity policies, you must first define a group and then add all the VMs on which you want to define the VM to VM anti-affinity policy.
Creating the VM Group
Log into one of the Controller VM (CVM) for your Nutanix cluster.
Then, to create a group entity for VM’s, issue the following command:
acli vm_group.create group-name
Replace "group-name" with a name that you would like to use.

Getting a List of All VM’s
For the next step, you’ll need to know the name of the VM’s that you want to put into the group. If you need a reminder of the VM’s name, you can use the following command to show all the VM’s running in the cluster:
acli vm.list
Note the VM names that you want to put into the group.

Adding VM’s to the Group
Add the VM’s that you want to the group, using the following command:
acli vm_group.add_vms group-name vm_list="name-of-vm-1","name-of-vm-2"
Replace group-name with the name of the group you created in the above step.
Replace name-of-vm-1 and name-of-vm-2 with the VM names you listed in the above step.

Configuring the VM to VM Anti-Affinity Policy
Use the following command to configure the VM to VM anti-affinity policy onto the group that was created:
acli vm_group.antiaffinity_set group-name
Replace group-name with the name of the group you created in the above step.

After you configure the group and then power on the VMs, the VMs that are part of the group are attempted to be started on the different hosts. However, this is a preferential policy. This policy does not limit the Acropolis Dynamic Scheduling (ADS) feature to take necessary action in case of resource constraints.