1. Packages
  2. Packages
  3. Nutanix
  4. API Docs
  5. getVmHostAffinityPolicyV2
Viewing docs for Nutanix v0.16.0
published on Tuesday, May 26, 2026 by Piers Karsenbarg
nutanix logo
Viewing docs for Nutanix v0.16.0
published on Tuesday, May 26, 2026 by Piers Karsenbarg

    Retrieve the VM-Host Affinity policy details for the provided external identifier (ext_id).

    Example

    import * as pulumi from "@pulumi/pulumi";
    import * as nutanix from "@pierskarsenbarg/nutanix";
    
    const policy = nutanix.getVmHostAffinityPolicyV2({
        extId: "12345678-1234-1234-1234-123456789012",
    });
    export const policyName = policy.then(policy => policy.name);
    
    import pulumi
    import pulumi_nutanix as nutanix
    
    policy = nutanix.get_vm_host_affinity_policy_v2(ext_id="12345678-1234-1234-1234-123456789012")
    pulumi.export("policyName", policy.name)
    
    package main
    
    import (
    	"github.com/pierskarsenbarg/pulumi-nutanix/sdk/go/nutanix"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		policy, err := nutanix.GetVmHostAffinityPolicyV2(ctx, &nutanix.LookupVmHostAffinityPolicyV2Args{
    			ExtId: "12345678-1234-1234-1234-123456789012",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("policyName", policy.Name)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Nutanix = PiersKarsenbarg.Nutanix;
    
    return await Deployment.RunAsync(() => 
    {
        var policy = Nutanix.GetVmHostAffinityPolicyV2.Invoke(new()
        {
            ExtId = "12345678-1234-1234-1234-123456789012",
        });
    
        return new Dictionary<string, object?>
        {
            ["policyName"] = policy.Apply(getVmHostAffinityPolicyV2Result => getVmHostAffinityPolicyV2Result.Name),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.nutanix.NutanixFunctions;
    import com.pulumi.nutanix.inputs.GetVmHostAffinityPolicyV2Args;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var policy = NutanixFunctions.getVmHostAffinityPolicyV2(GetVmHostAffinityPolicyV2Args.builder()
                .extId("12345678-1234-1234-1234-123456789012")
                .build());
    
            ctx.export("policyName", policy.name());
        }
    }
    
    variables:
      policy:
        fn::invoke:
          function: nutanix:getVmHostAffinityPolicyV2
          arguments:
            extId: 12345678-1234-1234-1234-123456789012
    outputs:
      policyName: ${policy.name}
    
    pulumi {
      required_providers {
        nutanix = {
          source = "pulumi/nutanix"
        }
      }
    }
    
    data "nutanix_getvmhostaffinitypolicyv2" "policy" {
      ext_id = "12345678-1234-1234-1234-123456789012"
    }
    
    output "policyName" {
      value = data.nutanix_getvmhostaffinitypolicyv2.policy.name
    }
    

    Using getVmHostAffinityPolicyV2

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getVmHostAffinityPolicyV2(args: GetVmHostAffinityPolicyV2Args, opts?: InvokeOptions): Promise<GetVmHostAffinityPolicyV2Result>
    function getVmHostAffinityPolicyV2Output(args: GetVmHostAffinityPolicyV2OutputArgs, opts?: InvokeOptions): Output<GetVmHostAffinityPolicyV2Result>
    def get_vm_host_affinity_policy_v2(ext_id: Optional[str] = None,
                                       opts: Optional[InvokeOptions] = None) -> GetVmHostAffinityPolicyV2Result
    def get_vm_host_affinity_policy_v2_output(ext_id: pulumi.Input[Optional[str]] = None,
                                       opts: Optional[InvokeOptions] = None) -> Output[GetVmHostAffinityPolicyV2Result]
    func LookupVmHostAffinityPolicyV2(ctx *Context, args *LookupVmHostAffinityPolicyV2Args, opts ...InvokeOption) (*LookupVmHostAffinityPolicyV2Result, error)
    func LookupVmHostAffinityPolicyV2Output(ctx *Context, args *LookupVmHostAffinityPolicyV2OutputArgs, opts ...InvokeOption) LookupVmHostAffinityPolicyV2ResultOutput

    > Note: This function is named LookupVmHostAffinityPolicyV2 in the Go SDK.

    public static class GetVmHostAffinityPolicyV2 
    {
        public static Task<GetVmHostAffinityPolicyV2Result> InvokeAsync(GetVmHostAffinityPolicyV2Args args, InvokeOptions? opts = null)
        public static Output<GetVmHostAffinityPolicyV2Result> Invoke(GetVmHostAffinityPolicyV2InvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetVmHostAffinityPolicyV2Result> getVmHostAffinityPolicyV2(GetVmHostAffinityPolicyV2Args args, InvokeOptions options)
    public static Output<GetVmHostAffinityPolicyV2Result> getVmHostAffinityPolicyV2(GetVmHostAffinityPolicyV2Args args, InvokeOptions options)
    
    fn::invoke:
      function: nutanix:index/getVmHostAffinityPolicyV2:getVmHostAffinityPolicyV2
      arguments:
        # arguments dictionary
    data "nutanix_getvmhostaffinitypolicyv2" "name" {
        # arguments
    }

    The following arguments are supported:

    ExtId string
    The external identifier of a VM-Host Affinity policy.
    ExtId string
    The external identifier of a VM-Host Affinity policy.
    ext_id string
    The external identifier of a VM-Host Affinity policy.
    extId String
    The external identifier of a VM-Host Affinity policy.
    extId string
    The external identifier of a VM-Host Affinity policy.
    ext_id str
    The external identifier of a VM-Host Affinity policy.
    extId String
    The external identifier of a VM-Host Affinity policy.

    getVmHostAffinityPolicyV2 Result

    The following output properties are available:

    CreateTime string
    The timestamp when the policy was created.
    CreatedBy Dictionary<string, string>
    Information about the entity that created the policy.
    Description string
    A description of the VM-Host Affinity policy.
    ExtId string
    HostCategories List<string>
    List of host category external IDs that define where the VMs can be placed.
    Id string
    The provider-assigned unique ID for this managed resource.
    LastUpdatedBy Dictionary<string, string>
    Information about the entity that last updated the policy.
    Name string
    The name of the VM-Host Affinity policy.
    NumCompliantVms int
    Number of VMs which are compliant with the VM-host affinity policy.
    NumHosts int
    Number of hosts associated with the VM-host affinity policy.
    NumNonCompliantVms int
    Number of VMs which are not compliant with the VM-host affinity policy.
    NumVms int
    Number of VMs associated with the VM-host affinity policy.
    UpdateTime string
    The timestamp when the policy was last updated.
    VmCategories List<string>
    List of VM category external IDs that this policy applies to.
    CreateTime string
    The timestamp when the policy was created.
    CreatedBy map[string]string
    Information about the entity that created the policy.
    Description string
    A description of the VM-Host Affinity policy.
    ExtId string
    HostCategories []string
    List of host category external IDs that define where the VMs can be placed.
    Id string
    The provider-assigned unique ID for this managed resource.
    LastUpdatedBy map[string]string
    Information about the entity that last updated the policy.
    Name string
    The name of the VM-Host Affinity policy.
    NumCompliantVms int
    Number of VMs which are compliant with the VM-host affinity policy.
    NumHosts int
    Number of hosts associated with the VM-host affinity policy.
    NumNonCompliantVms int
    Number of VMs which are not compliant with the VM-host affinity policy.
    NumVms int
    Number of VMs associated with the VM-host affinity policy.
    UpdateTime string
    The timestamp when the policy was last updated.
    VmCategories []string
    List of VM category external IDs that this policy applies to.
    create_time string
    The timestamp when the policy was created.
    created_by map(string)
    Information about the entity that created the policy.
    description string
    A description of the VM-Host Affinity policy.
    ext_id string
    host_categories list(string)
    List of host category external IDs that define where the VMs can be placed.
    id string
    The provider-assigned unique ID for this managed resource.
    last_updated_by map(string)
    Information about the entity that last updated the policy.
    name string
    The name of the VM-Host Affinity policy.
    num_compliant_vms number
    Number of VMs which are compliant with the VM-host affinity policy.
    num_hosts number
    Number of hosts associated with the VM-host affinity policy.
    num_non_compliant_vms number
    Number of VMs which are not compliant with the VM-host affinity policy.
    num_vms number
    Number of VMs associated with the VM-host affinity policy.
    update_time string
    The timestamp when the policy was last updated.
    vm_categories list(string)
    List of VM category external IDs that this policy applies to.
    createTime String
    The timestamp when the policy was created.
    createdBy Map<String,String>
    Information about the entity that created the policy.
    description String
    A description of the VM-Host Affinity policy.
    extId String
    hostCategories List<String>
    List of host category external IDs that define where the VMs can be placed.
    id String
    The provider-assigned unique ID for this managed resource.
    lastUpdatedBy Map<String,String>
    Information about the entity that last updated the policy.
    name String
    The name of the VM-Host Affinity policy.
    numCompliantVms Integer
    Number of VMs which are compliant with the VM-host affinity policy.
    numHosts Integer
    Number of hosts associated with the VM-host affinity policy.
    numNonCompliantVms Integer
    Number of VMs which are not compliant with the VM-host affinity policy.
    numVms Integer
    Number of VMs associated with the VM-host affinity policy.
    updateTime String
    The timestamp when the policy was last updated.
    vmCategories List<String>
    List of VM category external IDs that this policy applies to.
    createTime string
    The timestamp when the policy was created.
    createdBy {[key: string]: string}
    Information about the entity that created the policy.
    description string
    A description of the VM-Host Affinity policy.
    extId string
    hostCategories string[]
    List of host category external IDs that define where the VMs can be placed.
    id string
    The provider-assigned unique ID for this managed resource.
    lastUpdatedBy {[key: string]: string}
    Information about the entity that last updated the policy.
    name string
    The name of the VM-Host Affinity policy.
    numCompliantVms number
    Number of VMs which are compliant with the VM-host affinity policy.
    numHosts number
    Number of hosts associated with the VM-host affinity policy.
    numNonCompliantVms number
    Number of VMs which are not compliant with the VM-host affinity policy.
    numVms number
    Number of VMs associated with the VM-host affinity policy.
    updateTime string
    The timestamp when the policy was last updated.
    vmCategories string[]
    List of VM category external IDs that this policy applies to.
    create_time str
    The timestamp when the policy was created.
    created_by Mapping[str, str]
    Information about the entity that created the policy.
    description str
    A description of the VM-Host Affinity policy.
    ext_id str
    host_categories Sequence[str]
    List of host category external IDs that define where the VMs can be placed.
    id str
    The provider-assigned unique ID for this managed resource.
    last_updated_by Mapping[str, str]
    Information about the entity that last updated the policy.
    name str
    The name of the VM-Host Affinity policy.
    num_compliant_vms int
    Number of VMs which are compliant with the VM-host affinity policy.
    num_hosts int
    Number of hosts associated with the VM-host affinity policy.
    num_non_compliant_vms int
    Number of VMs which are not compliant with the VM-host affinity policy.
    num_vms int
    Number of VMs associated with the VM-host affinity policy.
    update_time str
    The timestamp when the policy was last updated.
    vm_categories Sequence[str]
    List of VM category external IDs that this policy applies to.
    createTime String
    The timestamp when the policy was created.
    createdBy Map<String>
    Information about the entity that created the policy.
    description String
    A description of the VM-Host Affinity policy.
    extId String
    hostCategories List<String>
    List of host category external IDs that define where the VMs can be placed.
    id String
    The provider-assigned unique ID for this managed resource.
    lastUpdatedBy Map<String>
    Information about the entity that last updated the policy.
    name String
    The name of the VM-Host Affinity policy.
    numCompliantVms Number
    Number of VMs which are compliant with the VM-host affinity policy.
    numHosts Number
    Number of hosts associated with the VM-host affinity policy.
    numNonCompliantVms Number
    Number of VMs which are not compliant with the VM-host affinity policy.
    numVms Number
    Number of VMs associated with the VM-host affinity policy.
    updateTime String
    The timestamp when the policy was last updated.
    vmCategories List<String>
    List of VM category external IDs that this policy applies to.

    Package Details

    Repository
    nutanix pierskarsenbarg/pulumi-nutanix
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the nutanix Terraform Provider.
    nutanix logo
    Viewing docs for Nutanix v0.16.0
    published on Tuesday, May 26, 2026 by Piers Karsenbarg

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial