1. Packages
  2. vSphere
  3. API Docs
  4. getComputeClusterHostGroup
vSphere v4.10.0 published on Tuesday, Mar 12, 2024 by Pulumi

vsphere.getComputeClusterHostGroup

Explore with Pulumi AI

vsphere logo
vSphere v4.10.0 published on Tuesday, Mar 12, 2024 by Pulumi

    The vsphere.ComputeClusterHostGroup data source can be used to discover the IDs ESXi hosts in a host group and return host group attributes to other resources.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as vsphere from "@pulumi/vsphere";
    
    const datacenter = vsphere.getDatacenter({
        name: _var.vsphere_datacenter,
    });
    const cluster = datacenter.then(datacenter => vsphere.getComputeCluster({
        name: _var.vsphere_cluster,
        datacenterId: datacenter.id,
    }));
    const hostGroup1 = cluster.then(cluster => vsphere.getComputeClusterHostGroup({
        name: "host_group1",
        computeClusterId: cluster.id,
    }));
    const hostRule1 = new vsphere.ComputeClusterVmHostRule("hostRule1", {
        computeClusterId: cluster.then(cluster => cluster.id),
        vmGroupName: "vm_group1",
        affinityHostGroupName: hostGroup1.then(hostGroup1 => hostGroup1.name),
    });
    
    import pulumi
    import pulumi_vsphere as vsphere
    
    datacenter = vsphere.get_datacenter(name=var["vsphere_datacenter"])
    cluster = vsphere.get_compute_cluster(name=var["vsphere_cluster"],
        datacenter_id=datacenter.id)
    host_group1 = vsphere.get_compute_cluster_host_group(name="host_group1",
        compute_cluster_id=cluster.id)
    host_rule1 = vsphere.ComputeClusterVmHostRule("hostRule1",
        compute_cluster_id=cluster.id,
        vm_group_name="vm_group1",
        affinity_host_group_name=host_group1.name)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-vsphere/sdk/v4/go/vsphere"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		datacenter, err := vsphere.LookupDatacenter(ctx, &vsphere.LookupDatacenterArgs{
    			Name: pulumi.StringRef(_var.Vsphere_datacenter),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		cluster, err := vsphere.LookupComputeCluster(ctx, &vsphere.LookupComputeClusterArgs{
    			Name:         _var.Vsphere_cluster,
    			DatacenterId: pulumi.StringRef(datacenter.Id),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		hostGroup1, err := vsphere.LookupComputeClusterHostGroup(ctx, &vsphere.LookupComputeClusterHostGroupArgs{
    			Name:             "host_group1",
    			ComputeClusterId: cluster.Id,
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = vsphere.NewComputeClusterVmHostRule(ctx, "hostRule1", &vsphere.ComputeClusterVmHostRuleArgs{
    			ComputeClusterId:      *pulumi.String(cluster.Id),
    			VmGroupName:           pulumi.String("vm_group1"),
    			AffinityHostGroupName: *pulumi.String(hostGroup1.Name),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using VSphere = Pulumi.VSphere;
    
    return await Deployment.RunAsync(() => 
    {
        var datacenter = VSphere.GetDatacenter.Invoke(new()
        {
            Name = @var.Vsphere_datacenter,
        });
    
        var cluster = VSphere.GetComputeCluster.Invoke(new()
        {
            Name = @var.Vsphere_cluster,
            DatacenterId = datacenter.Apply(getDatacenterResult => getDatacenterResult.Id),
        });
    
        var hostGroup1 = VSphere.GetComputeClusterHostGroup.Invoke(new()
        {
            Name = "host_group1",
            ComputeClusterId = cluster.Apply(getComputeClusterResult => getComputeClusterResult.Id),
        });
    
        var hostRule1 = new VSphere.ComputeClusterVmHostRule("hostRule1", new()
        {
            ComputeClusterId = cluster.Apply(getComputeClusterResult => getComputeClusterResult.Id),
            VmGroupName = "vm_group1",
            AffinityHostGroupName = hostGroup1.Apply(getComputeClusterHostGroupResult => getComputeClusterHostGroupResult.Name),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.vsphere.VsphereFunctions;
    import com.pulumi.vsphere.inputs.GetDatacenterArgs;
    import com.pulumi.vsphere.inputs.GetComputeClusterArgs;
    import com.pulumi.vsphere.inputs.GetComputeClusterHostGroupArgs;
    import com.pulumi.vsphere.ComputeClusterVmHostRule;
    import com.pulumi.vsphere.ComputeClusterVmHostRuleArgs;
    import java.util.List;
    import java.util.ArrayList;
    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 datacenter = VsphereFunctions.getDatacenter(GetDatacenterArgs.builder()
                .name(var_.vsphere_datacenter())
                .build());
    
            final var cluster = VsphereFunctions.getComputeCluster(GetComputeClusterArgs.builder()
                .name(var_.vsphere_cluster())
                .datacenterId(datacenter.applyValue(getDatacenterResult -> getDatacenterResult.id()))
                .build());
    
            final var hostGroup1 = VsphereFunctions.getComputeClusterHostGroup(GetComputeClusterHostGroupArgs.builder()
                .name("host_group1")
                .computeClusterId(cluster.applyValue(getComputeClusterResult -> getComputeClusterResult.id()))
                .build());
    
            var hostRule1 = new ComputeClusterVmHostRule("hostRule1", ComputeClusterVmHostRuleArgs.builder()        
                .computeClusterId(cluster.applyValue(getComputeClusterResult -> getComputeClusterResult.id()))
                .vmGroupName("vm_group1")
                .affinityHostGroupName(hostGroup1.applyValue(getComputeClusterHostGroupResult -> getComputeClusterHostGroupResult.name()))
                .build());
    
        }
    }
    
    resources:
      hostRule1:
        type: vsphere:ComputeClusterVmHostRule
        properties:
          computeClusterId: ${cluster.id}
          vmGroupName: vm_group1
          affinityHostGroupName: ${hostGroup1.name}
    variables:
      datacenter:
        fn::invoke:
          Function: vsphere:getDatacenter
          Arguments:
            name: ${var.vsphere_datacenter}
      cluster:
        fn::invoke:
          Function: vsphere:getComputeCluster
          Arguments:
            name: ${var.vsphere_cluster}
            datacenterId: ${datacenter.id}
      hostGroup1:
        fn::invoke:
          Function: vsphere:getComputeClusterHostGroup
          Arguments:
            name: host_group1
            computeClusterId: ${cluster.id}
    

    Using getComputeClusterHostGroup

    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 getComputeClusterHostGroup(args: GetComputeClusterHostGroupArgs, opts?: InvokeOptions): Promise<GetComputeClusterHostGroupResult>
    function getComputeClusterHostGroupOutput(args: GetComputeClusterHostGroupOutputArgs, opts?: InvokeOptions): Output<GetComputeClusterHostGroupResult>
    def get_compute_cluster_host_group(compute_cluster_id: Optional[str] = None,
                                       name: Optional[str] = None,
                                       opts: Optional[InvokeOptions] = None) -> GetComputeClusterHostGroupResult
    def get_compute_cluster_host_group_output(compute_cluster_id: Optional[pulumi.Input[str]] = None,
                                       name: Optional[pulumi.Input[str]] = None,
                                       opts: Optional[InvokeOptions] = None) -> Output[GetComputeClusterHostGroupResult]
    func LookupComputeClusterHostGroup(ctx *Context, args *LookupComputeClusterHostGroupArgs, opts ...InvokeOption) (*LookupComputeClusterHostGroupResult, error)
    func LookupComputeClusterHostGroupOutput(ctx *Context, args *LookupComputeClusterHostGroupOutputArgs, opts ...InvokeOption) LookupComputeClusterHostGroupResultOutput

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

    public static class GetComputeClusterHostGroup 
    {
        public static Task<GetComputeClusterHostGroupResult> InvokeAsync(GetComputeClusterHostGroupArgs args, InvokeOptions? opts = null)
        public static Output<GetComputeClusterHostGroupResult> Invoke(GetComputeClusterHostGroupInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetComputeClusterHostGroupResult> getComputeClusterHostGroup(GetComputeClusterHostGroupArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: vsphere:index/getComputeClusterHostGroup:getComputeClusterHostGroup
      arguments:
        # arguments dictionary

    The following arguments are supported:

    ComputeClusterId string
    The managed object reference ID of the compute cluster for the host group.
    Name string
    The name of the host group.
    ComputeClusterId string
    The managed object reference ID of the compute cluster for the host group.
    Name string
    The name of the host group.
    computeClusterId String
    The managed object reference ID of the compute cluster for the host group.
    name String
    The name of the host group.
    computeClusterId string
    The managed object reference ID of the compute cluster for the host group.
    name string
    The name of the host group.
    compute_cluster_id str
    The managed object reference ID of the compute cluster for the host group.
    name str
    The name of the host group.
    computeClusterId String
    The managed object reference ID of the compute cluster for the host group.
    name String
    The name of the host group.

    getComputeClusterHostGroup Result

    The following output properties are available:

    ComputeClusterId string
    HostSystemIds List<string>
    The [managed object reference ID][docs-about-morefs] of the ESXi hosts in the host group.
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    ComputeClusterId string
    HostSystemIds []string
    The [managed object reference ID][docs-about-morefs] of the ESXi hosts in the host group.
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    computeClusterId String
    hostSystemIds List<String>
    The [managed object reference ID][docs-about-morefs] of the ESXi hosts in the host group.
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    computeClusterId string
    hostSystemIds string[]
    The [managed object reference ID][docs-about-morefs] of the ESXi hosts in the host group.
    id string
    The provider-assigned unique ID for this managed resource.
    name string
    compute_cluster_id str
    host_system_ids Sequence[str]
    The [managed object reference ID][docs-about-morefs] of the ESXi hosts in the host group.
    id str
    The provider-assigned unique ID for this managed resource.
    name str
    computeClusterId String
    hostSystemIds List<String>
    The [managed object reference ID][docs-about-morefs] of the ESXi hosts in the host group.
    id String
    The provider-assigned unique ID for this managed resource.
    name String

    Package Details

    Repository
    vSphere pulumi/pulumi-vsphere
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the vsphere Terraform Provider.
    vsphere logo
    vSphere v4.10.0 published on Tuesday, Mar 12, 2024 by Pulumi