1. Packages
  2. Vsphere Provider
  3. API Docs
  4. getComputeClusterHostGroup
vSphere v4.12.1 published on Tuesday, Oct 22, 2024 by Pulumi

vsphere.getComputeClusterHostGroup

Explore with Pulumi AI

vsphere logo
vSphere v4.12.1 published on Tuesday, Oct 22, 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: "dc-01",
    });
    const cluster = datacenter.then(datacenter => vsphere.getComputeCluster({
        name: "cluster-01",
        datacenterId: datacenter.id,
    }));
    const hostGroup = cluster.then(cluster => vsphere.getComputeClusterHostGroup({
        name: "hostgroup-01",
        computeClusterId: cluster.id,
    }));
    const hostRule = new vsphere.ComputeClusterVmHostRule("host_rule", {
        computeClusterId: cluster.then(cluster => cluster.id),
        name: "pulumi-host-rule1",
        vmGroupName: "vmgroup-01",
        affinityHostGroupName: hostGroup.then(hostGroup => hostGroup.name),
    });
    
    import pulumi
    import pulumi_vsphere as vsphere
    
    datacenter = vsphere.get_datacenter(name="dc-01")
    cluster = vsphere.get_compute_cluster(name="cluster-01",
        datacenter_id=datacenter.id)
    host_group = vsphere.get_compute_cluster_host_group(name="hostgroup-01",
        compute_cluster_id=cluster.id)
    host_rule = vsphere.ComputeClusterVmHostRule("host_rule",
        compute_cluster_id=cluster.id,
        name="pulumi-host-rule1",
        vm_group_name="vmgroup-01",
        affinity_host_group_name=host_group.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("dc-01"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		cluster, err := vsphere.LookupComputeCluster(ctx, &vsphere.LookupComputeClusterArgs{
    			Name:         "cluster-01",
    			DatacenterId: pulumi.StringRef(datacenter.Id),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		hostGroup, err := vsphere.LookupComputeClusterHostGroup(ctx, &vsphere.LookupComputeClusterHostGroupArgs{
    			Name:             "hostgroup-01",
    			ComputeClusterId: cluster.Id,
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = vsphere.NewComputeClusterVmHostRule(ctx, "host_rule", &vsphere.ComputeClusterVmHostRuleArgs{
    			ComputeClusterId:      pulumi.String(cluster.Id),
    			Name:                  pulumi.String("pulumi-host-rule1"),
    			VmGroupName:           pulumi.String("vmgroup-01"),
    			AffinityHostGroupName: pulumi.String(hostGroup.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 = "dc-01",
        });
    
        var cluster = VSphere.GetComputeCluster.Invoke(new()
        {
            Name = "cluster-01",
            DatacenterId = datacenter.Apply(getDatacenterResult => getDatacenterResult.Id),
        });
    
        var hostGroup = VSphere.GetComputeClusterHostGroup.Invoke(new()
        {
            Name = "hostgroup-01",
            ComputeClusterId = cluster.Apply(getComputeClusterResult => getComputeClusterResult.Id),
        });
    
        var hostRule = new VSphere.ComputeClusterVmHostRule("host_rule", new()
        {
            ComputeClusterId = cluster.Apply(getComputeClusterResult => getComputeClusterResult.Id),
            Name = "pulumi-host-rule1",
            VmGroupName = "vmgroup-01",
            AffinityHostGroupName = hostGroup.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("dc-01")
                .build());
    
            final var cluster = VsphereFunctions.getComputeCluster(GetComputeClusterArgs.builder()
                .name("cluster-01")
                .datacenterId(datacenter.applyValue(getDatacenterResult -> getDatacenterResult.id()))
                .build());
    
            final var hostGroup = VsphereFunctions.getComputeClusterHostGroup(GetComputeClusterHostGroupArgs.builder()
                .name("hostgroup-01")
                .computeClusterId(cluster.applyValue(getComputeClusterResult -> getComputeClusterResult.id()))
                .build());
    
            var hostRule = new ComputeClusterVmHostRule("hostRule", ComputeClusterVmHostRuleArgs.builder()
                .computeClusterId(cluster.applyValue(getComputeClusterResult -> getComputeClusterResult.id()))
                .name("pulumi-host-rule1")
                .vmGroupName("vmgroup-01")
                .affinityHostGroupName(hostGroup.applyValue(getComputeClusterHostGroupResult -> getComputeClusterHostGroupResult.name()))
                .build());
    
        }
    }
    
    resources:
      hostRule:
        type: vsphere:ComputeClusterVmHostRule
        name: host_rule
        properties:
          computeClusterId: ${cluster.id}
          name: pulumi-host-rule1
          vmGroupName: vmgroup-01
          affinityHostGroupName: ${hostGroup.name}
    variables:
      datacenter:
        fn::invoke:
          Function: vsphere:getDatacenter
          Arguments:
            name: dc-01
      cluster:
        fn::invoke:
          Function: vsphere:getComputeCluster
          Arguments:
            name: cluster-01
            datacenterId: ${datacenter.id}
      hostGroup:
        fn::invoke:
          Function: vsphere:getComputeClusterHostGroup
          Arguments:
            name: hostgroup-01
            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.12.1 published on Tuesday, Oct 22, 2024 by Pulumi