Now, Nova can create a server group by using commands, and the VM in the server group can specify some policies. These policies include affinity and anti-affinity. Affinity indicates that all VMS should be installed on one host as much as possible, and anti-ffinity indicates that VMS should be arranged on different hosts as much as possible. The command to create a server-group is as follows: Nova server-group-create group_name anti-afffinity
Then, when creating a VM, specify the group name through hint: Nova boot -- image cirros -- flavor m1.small -- hint group = group_name so that the created VM can be placed in a specified group.
Heat also has related resource, the name is OS: Nova: servergroup related BP example: https://blueprints.launchpad.net/heat/+spec/vm-instance-group-support
Servergroup in Nova and heat