Class ComputeClusterVmHostRule
The vsphere..ComputeClusterVmHostRule resource can be used to manage
VM-to-host rules in a cluster, either created by the
vsphere..ComputeCluster resource or looked up
by the vsphere..ComputeCluster data source.
This resource can create both affinity rules, where virtual machines run on
specified hosts, or anti-affinity rules, where virtual machines run on hosts
outside of the ones specified in the rule. Virtual machines and hosts are
supplied via groups, which can be managed via the
vsphere..ComputeClusterVmGroup and
vsphere..ComputeClusterHostGroup
resources.
NOTE: This resource requires vCenter and is not available on direct ESXi connections.
NOTE: vSphere DRS requires a vSphere Enterprise Plus license.
Example Usage
using Pulumi;
using VSphere = Pulumi.VSphere;
class MyStack : Stack
{
public MyStack()
{
var dc = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
{
Name = "dc1",
}));
var datastore = dc.Apply(dc => Output.Create(VSphere.GetDatastore.InvokeAsync(new VSphere.GetDatastoreArgs
{
DatacenterId = dc.Id,
Name = "datastore1",
})));
var cluster = dc.Apply(dc => Output.Create(VSphere.GetComputeCluster.InvokeAsync(new VSphere.GetComputeClusterArgs
{
DatacenterId = dc.Id,
Name = "cluster1",
})));
var host = dc.Apply(dc => Output.Create(VSphere.GetHost.InvokeAsync(new VSphere.GetHostArgs
{
DatacenterId = dc.Id,
Name = "esxi1",
})));
var network = dc.Apply(dc => Output.Create(VSphere.GetNetwork.InvokeAsync(new VSphere.GetNetworkArgs
{
DatacenterId = dc.Id,
Name = "network1",
})));
var vm = new VSphere.VirtualMachine("vm", new VSphere.VirtualMachineArgs
{
DatastoreId = datastore.Apply(datastore => datastore.Id),
Disks =
{
new VSphere.Inputs.VirtualMachineDiskArgs
{
Label = "disk0",
Size = 20,
},
},
GuestId = "other3xLinux64Guest",
Memory = 2048,
NetworkInterfaces =
{
new VSphere.Inputs.VirtualMachineNetworkInterfaceArgs
{
NetworkId = network.Apply(network => network.Id),
},
},
NumCpus = 2,
ResourcePoolId = cluster.Apply(cluster => cluster.ResourcePoolId),
});
var clusterVmGroup = new VSphere.ComputeClusterVmGroup("clusterVmGroup", new VSphere.ComputeClusterVmGroupArgs
{
ComputeClusterId = cluster.Apply(cluster => cluster.Id),
VirtualMachineIds =
{
vm.Id,
},
});
var clusterHostGroup = new VSphere.ComputeClusterHostGroup("clusterHostGroup", new VSphere.ComputeClusterHostGroupArgs
{
ComputeClusterId = cluster.Apply(cluster => cluster.Id),
HostSystemIds =
{
host.Apply(host => host.Id),
},
});
var clusterVmHostRule = new VSphere.ComputeClusterVmHostRule("clusterVmHostRule", new VSphere.ComputeClusterVmHostRuleArgs
{
AffinityHostGroupName = clusterHostGroup.Name,
ComputeClusterId = cluster.Apply(cluster => cluster.Id),
VmGroupName = clusterVmGroup.Name,
});
}
}
Inherited Members
Namespace: Pulumi.VSphere
Assembly: Pulumi.VSphere.dll
Syntax
public class ComputeClusterVmHostRule : CustomResource
Constructors
View SourceComputeClusterVmHostRule(String, ComputeClusterVmHostRuleArgs, CustomResourceOptions)
Create a ComputeClusterVmHostRule resource with the given unique name, arguments, and options.
Declaration
public ComputeClusterVmHostRule(string name, ComputeClusterVmHostRuleArgs args, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resource |
| ComputeClusterVmHostRuleArgs | args | The arguments used to populate this resource's properties |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Properties
View SourceAffinityHostGroupName
When this field is used, the virtual
machines defined in vm_group_name will be run on the
hosts defined in this host group.
Declaration
public Output<string> AffinityHostGroupName { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
AntiAffinityHostGroupName
When this field is used, the
virtual machines defined in vm_group_name will not be
run on the hosts defined in this host group.
Declaration
public Output<string> AntiAffinityHostGroupName { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
ComputeClusterId
The managed object reference ID of the cluster to put the group in. Forces a new resource if changed.
Declaration
public Output<string> ComputeClusterId { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Enabled
Enable this rule in the cluster. Default: true.
Declaration
public Output<bool?> Enabled { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
Mandatory
When this value is true, prevents any virtual
machine operations that may violate this rule. Default: false.
Declaration
public Output<bool?> Mandatory { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
Name
The name of the rule. This must be unique in the cluster.
Declaration
public Output<string> Name { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
VmGroupName
The name of the virtual machine group to use with this rule.
Declaration
public Output<string> VmGroupName { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Methods
View SourceGet(String, Input<String>, ComputeClusterVmHostRuleState, CustomResourceOptions)
Get an existing ComputeClusterVmHostRule resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
Declaration
public static ComputeClusterVmHostRule Get(string name, Input<string> id, ComputeClusterVmHostRuleState state = null, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resulting resource. |
| Input<System.String> | id | The unique provider ID of the resource to lookup. |
| ComputeClusterVmHostRuleState | state | Any extra arguments used during the lookup. |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Returns
| Type | Description |
|---|---|
| ComputeClusterVmHostRule |