vSphere v4.10.1 published on Friday, May 10, 2024 by Pulumi
vsphere.getComputeClusterHostGroup
Explore with Pulumi AI
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: vsphereDatacenter,
});
const cluster = datacenter.then(datacenter => vsphere.getComputeCluster({
name: vsphereCluster,
datacenterId: datacenter.id,
}));
const hostGroup1 = cluster.then(cluster => vsphere.getComputeClusterHostGroup({
name: "host_group1",
computeClusterId: cluster.id,
}));
const hostRule1 = new vsphere.ComputeClusterVmHostRule("host_rule1", {
computeClusterId: cluster.then(cluster => cluster.id),
name: "terraform-host-rule1",
vmGroupName: "vm_group1",
affinityHostGroupName: hostGroup1.then(hostGroup1 => hostGroup1.name),
});
import pulumi
import pulumi_vsphere as vsphere
datacenter = vsphere.get_datacenter(name=vsphere_datacenter)
cluster = vsphere.get_compute_cluster(name=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("host_rule1",
compute_cluster_id=cluster.id,
name="terraform-host-rule1",
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(vsphereDatacenter),
}, nil)
if err != nil {
return err
}
cluster, err := vsphere.LookupComputeCluster(ctx, &vsphere.LookupComputeClusterArgs{
Name: vsphereCluster,
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, "host_rule1", &vsphere.ComputeClusterVmHostRuleArgs{
ComputeClusterId: pulumi.String(cluster.Id),
Name: pulumi.String("terraform-host-rule1"),
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 = vsphereDatacenter,
});
var cluster = VSphere.GetComputeCluster.Invoke(new()
{
Name = vsphereCluster,
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("host_rule1", new()
{
ComputeClusterId = cluster.Apply(getComputeClusterResult => getComputeClusterResult.Id),
Name = "terraform-host-rule1",
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(vsphereDatacenter)
.build());
final var cluster = VsphereFunctions.getComputeCluster(GetComputeClusterArgs.builder()
.name(vsphereCluster)
.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()))
.name("terraform-host-rule1")
.vmGroupName("vm_group1")
.affinityHostGroupName(hostGroup1.applyValue(getComputeClusterHostGroupResult -> getComputeClusterHostGroupResult.name()))
.build());
}
}
resources:
hostRule1:
type: vsphere:ComputeClusterVmHostRule
name: host_rule1
properties:
computeClusterId: ${cluster.id}
name: terraform-host-rule1
vmGroupName: vm_group1
affinityHostGroupName: ${hostGroup1.name}
variables:
datacenter:
fn::invoke:
Function: vsphere:getDatacenter
Arguments:
name: ${vsphereDatacenter}
cluster:
fn::invoke:
Function: vsphere:getComputeCluster
Arguments:
name: ${vsphereCluster}
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:
- Compute
Cluster stringId - The managed object reference ID of the compute cluster for the host group.
- Name string
- The name of the host group.
- Compute
Cluster stringId - The managed object reference ID of the compute cluster for the host group.
- Name string
- The name of the host group.
- compute
Cluster StringId - The managed object reference ID of the compute cluster for the host group.
- name String
- The name of the host group.
- compute
Cluster stringId - The managed object reference ID of the compute cluster for the host group.
- name string
- The name of the host group.
- compute_
cluster_ strid - The managed object reference ID of the compute cluster for the host group.
- name str
- The name of the host group.
- compute
Cluster StringId - 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:
- Compute
Cluster stringId - Host
System List<string>Ids - 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 stringId - Host
System []stringIds - 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 StringId - host
System List<String>Ids - 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 stringId - host
System string[]Ids - 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_ strid - host_
system_ Sequence[str]ids - 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
- compute
Cluster StringId - host
System List<String>Ids - 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.