You can list capabilities, retrieve details about a specific capability, and use the details to create a compute policy.

The capabilities service provides operations to manage compute policy capabilities. The description of the capability provides information about the intent of a policy based on this capability. A capability provides a type to create a policy. A capability also provides a type that describes the information returned when retrieving information about a policy.

Procedure

  1. List all available compute policy capabilities.
    GET https://<vcenter_ip_address_or_fqdn>/api/vcenter/compute/policies/capabilities

    The following is an example response that contains details about the capabilities.

    [
        {
            "capability": "com.vmware.vcenter.compute.policies.capabilities.vm.placement.anti_affinity_with_vcls",
            "name": "Anti-affinity with vSphere Cluster Services (vCLS) VMs",
            "description": "vSphere Cluster Services (vCLS) VMs will not be placed on hosts with virtual machines that share the tag."
        }
    ]
  2. Retrieve details about a specific compute policy.
    GET https://<vcenter_ip_address_or_fqdn>/api/vcenter/compute/policies/capabilities/com.vmware.vcenter.compute.policies.capabilities.vm.placement.anti_affinity_with_vcls

    The following is an example response that contains details about the capability.

    {
        "info_type": "com.vmware.vcenter.compute.policies.capabilities.vm.placement.anti_affinity_with_vcls.info",
        "name": "Anti-affinity with vSphere Cluster Services (vCLS) VMs",
        "description": "vSphere Cluster Services (vCLS) VMs will not be placed on hosts with virtual machines that share the tag.",
        "create_spec_type": "com.vmware.vcenter.compute.policies.capabilities.vm.placement.anti_affinity_with_vcls.create_spec"
    }
  3. Use the details to construct a create_spec_type for a policy.
    GET https://<vcenter_ip_address_or_fqdn>/api/com/vmware/vapi/metadata/metamodel/structure/id:com.vmware.vcenter.compute.policies.capabilities.anti_affinity_with_vcls.create_spec

What to do next

You can create tags to identify inventory objects on which a compute policy should be enforced. See Create Tags and Associations.