Class ComputeClusterVmAntiAffinityRule
The vsphere..ComputeClusterVmAntiAffinityRule resource can be used to
manage VM anti-affinity rules in a cluster, either created by the
vsphere..ComputeCluster resource or looked up
by the vsphere..ComputeCluster data source.
This rule can be used to tell a set to virtual machines to run on different
hosts within a cluster, useful for preventing single points of failure in
application cluster scenarios. When configured, DRS will make a best effort to
ensure that the virtual machines run on different hosts, or prevent any
operation that would keep that from happening, depending on the value of the
mandatory flag.
Keep in mind that this rule can only be used to tell VMs to run separately on non-specific hosts - specific hosts cannot be specified with this rule. For that, see the
vsphere..ComputeClusterVmHostRuleresource.
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 System.Collections.Generic;
using System.Linq;
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 network = dc.Apply(dc => Output.Create(VSphere.GetNetwork.InvokeAsync(new VSphere.GetNetworkArgs
{
DatacenterId = dc.Id,
Name = "network1",
})));
var vm = new List<VSphere.VirtualMachine>();
for (var rangeIndex = 0; rangeIndex < 2; rangeIndex++)
{
var range = new { Value = rangeIndex };
vm.Add(new VSphere.VirtualMachine($"vm-{range.Value}", 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 clusterVmAntiAffinityRule = new VSphere.ComputeClusterVmAntiAffinityRule("clusterVmAntiAffinityRule", new VSphere.ComputeClusterVmAntiAffinityRuleArgs
{
ComputeClusterId = cluster.Apply(cluster => cluster.Id),
VirtualMachineIds = vm.Select(__item => __item.Id).ToList(),
});
}
}
Inherited Members
Namespace: Pulumi.VSphere
Assembly: Pulumi.VSphere.dll
Syntax
public class ComputeClusterVmAntiAffinityRule : CustomResource
Constructors
View SourceComputeClusterVmAntiAffinityRule(String, ComputeClusterVmAntiAffinityRuleArgs, CustomResourceOptions)
Create a ComputeClusterVmAntiAffinityRule resource with the given unique name, arguments, and options.
Declaration
public ComputeClusterVmAntiAffinityRule(string name, ComputeClusterVmAntiAffinityRuleArgs args, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resource |
| ComputeClusterVmAntiAffinityRuleArgs | args | The arguments used to populate this resource's properties |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Properties
View SourceComputeClusterId
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> |
VirtualMachineIds
The UUIDs of the virtual machines to run on hosts different from each other.
Declaration
public Output<ImmutableArray<string>> VirtualMachineIds { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<System.String>> |
Methods
View SourceGet(String, Input<String>, ComputeClusterVmAntiAffinityRuleState, CustomResourceOptions)
Get an existing ComputeClusterVmAntiAffinityRule resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
Declaration
public static ComputeClusterVmAntiAffinityRule Get(string name, Input<string> id, ComputeClusterVmAntiAffinityRuleState 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. |
| ComputeClusterVmAntiAffinityRuleState | state | Any extra arguments used during the lookup. |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Returns
| Type | Description |
|---|---|
| ComputeClusterVmAntiAffinityRule |