Update or Delete a VM-VM Affinity Rule
To update or remove an affinity rule, use the edit and remove links in the rule.
Prerequisites
-
This operation requires the rights included in the predefined vApp Author role or an equivalent set of rights.
-
To update or delete an affinity rule, you must be the owner of all virtual machines specified in the rule.
-
To update or remove the rule, you must know the href value of the rule. This value is returned when you create the rule (see Create a VM-VM Affinity Rule). You can retrieve a list of all your affinity rules from a VDC by making a GET request to this link in the VDC.
<Link rel="down" href="https://vcloud.example.com/api/vdc/44/vmAffinityRules/" type="application/vnd.vmware.vcloud.vmaffinityrules+xml"/>
Procedure
Example: Update a VM-VM Affinity Rule
This request updates the an affinity rule created in Create a VM-VM Affinity Rule to add a third virtual machine.
Request:
PUT https://vcloud.example.com/api/vmAffinityRule/edf7c... Content-Type: application/vnd.vmware.vcloud.vmaffinityrule+xml ... <?xml version="1.0" encoding="UTF-8"?> <VmAffinityRule xmlns="http://www.vmware.com/vcloud/v1.5"> <Name>example-affinity-rule</Name> <IsEnabled>true</IsEnabled> <Polarity>Affinity</Polarity> <VmReferences> <VmReference href="https://vcloud.example.com/api/vApp/vm-44" /> <VmReference href="https://vcloud.example.com/api/vApp/vm-200" /> <VmReference href="https://vcloud.example.com/api/vApp/vm-133" /> </VmReferences> </VmAffinityRule>
The response is a Task.
Response:
<?xml version="1.0" encoding="UTF-8"?> <Task ... operationName="affinityRuleUPdate" ... > <Owner href="https://vcloud.example.com/api/vmAffinityRule/edf7c456-a69c-48b1-89a8-4e9674448e01" name="example_name" type="application/vnd.vmware.vcloud.vmaffinityrule+xml" /> ... </Task>