A VM-Host affinity rule specifies a relationship between a host group and a VM group in the same resource pool. A system administrator can create, enable, disable or delete a VM-Host affinity rule.
- Enable the rule.
- Disable the rule.
- Delete the rule.
To make any other change (for example, to change the VM Group or Host Group), you must create a new rule.
vSphere VM-Host affinity rules that are created in resource pools that are mapped to a Provider VDC appear in each pool shown in the Resource Pools list under vSphere Properties. vSphere VM-Host affinity rules that are created in a resource pool that is mapped to a Provider VDC are listed in the VMWVmHostAffinityRules element of the VMWProviderVdc response. For more information about host DRS VM-Host affinity, see the VMware vSphere ESXi and vCenter Server Documentation.
Prerequisites
-
This operation is restricted to system administrators.
-
You cannot create VM-Host affinity rule in a resource pool that does not contain at least one host group and one VM group.
Procedure
Example: Create a VM-Host Affinity Rule
This example creates and enables a rule that binds the Host Group shown in Host Groups in a Resource Pool to the VM Group created in Create a VM Group.
POST https://vcloud.example.com/api/admin/extension/resourcePool/6/rules ... <?xml version="1.0" encoding="UTF-8"?> <vmext:VMWVmHostAffinityRule xmlns:vmext="http://www.vmware.com/vcloud/extension/v1.5" xmlns:vcloud="http://www.vmware.com/vcloud/v1.5" type="application/vnd.vmware.admin.vmwVmHostAffinityRule+xml"> <vcloud:Name>MSSQL-VMs</vcloud:Name> <vcloud:IsEnabled>true</vcloud:IsEnabled> <vcloud:IsMandatory>true</vcloud:IsMandatory> <vcloud:Polarity>Affinity</vcloud:Polarity> <vmext:HostGroupName>HostGroup-MSSQL</vmext:HostGroupName> <vmext:VmGroupName>ExampleGroup</vmext:VmGroupName> </vmext:VMWVmHostAffinityRule>
GET https://vcloud.example.com/api/admin/extension/resourcePool/6/rules ... <vmext:VMWVmHostAffinityRules ...> <vcloud:Link rel="add" href="https://vcloud.example.com/api/admin/extension/resourcePool/6/rules" type="application/vnd.vmware.admin.vmwVmHostAffinityRule+xml" /> <vmext:VmHostAffinityRule id="85" href="https://vcloud.example.com/api/admin/extension/rule/85" type="application/vnd.vmware.admin.vmwVmHostAffinityRule+xml"> <vcloud:Link rel="down" href="https://vcloud.example.com/api/admin/extension/hostGroup/5" type="application/vnd.vmware.admin.vmwHostGroupType+xml" /> <vcloud:Link rel="down" href="https://vcloud.example.com/api/admin/extension/vmGroup/34" type="application/vnd.vmware.admin.vmwVmGroupType+xml" /> <vcloud:Link rel="disable" href="https://vcloud.example.com/api/admin/extension/rule/85/action/disable" /> <vcloud:Link rel="remove" href="https://vcloud.example.com/api/admin/extension/rule/85" /> vcloud:Name>MSSQL-VMs</vcloud:Name> <vcloud:IsEnabled>true</vcloud:IsEnabled> <vcloud:IsMandatory>true</vcloud:IsMandatory> <vcloud:Polarity>Affinity</vcloud:Polarity> <vmext:HostGroupName>HostGroup-MSSQL</vmext:HostGroupName> <vmext:VmGroupName>ExampleGroup</vmext:VmGroupName> </vmext:VmHostAffinityRule> ... <vmext:VmHostAffinityRule> </vmext:VmHostAffinityRule> ... <vmext:VmHostAffinityRule> </vmext:VMWVmHostAffinityRules>