Show / Hide Table of Contents

Class ComputeClusterVmAffinityRule

The vsphere..ComputeClusterVmAffinityRule resource can be used to manage VM 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 together on a single host within a cluster. When configured, DRS will make a best effort to ensure that the virtual machines run on the same host, 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 together on a non-specific host - it can't be used to pin VMs to a host. For that, see the vsphere..ComputeClusterVmHostRule resource.

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 clusterVmAffinityRule = new VSphere.ComputeClusterVmAffinityRule("clusterVmAffinityRule", new VSphere.ComputeClusterVmAffinityRuleArgs
    {
        ComputeClusterId = cluster.Apply(cluster => cluster.Id),
        VirtualMachineIds = vm.Select(__item => __item.Id).ToList(),
    });
}

}
Inheritance
System.Object
Resource
CustomResource
ComputeClusterVmAffinityRule
Inherited Members
CustomResource.Id
Resource.GetResourceType()
Resource.GetResourceName()
Resource.Urn
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.VSphere
Assembly: Pulumi.VSphere.dll
Syntax
public class ComputeClusterVmAffinityRule : CustomResource

Constructors

View Source

ComputeClusterVmAffinityRule(String, ComputeClusterVmAffinityRuleArgs, CustomResourceOptions)

Create a ComputeClusterVmAffinityRule resource with the given unique name, arguments, and options.

Declaration
public ComputeClusterVmAffinityRule(string name, ComputeClusterVmAffinityRuleArgs args, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resource

ComputeClusterVmAffinityRuleArgs args

The arguments used to populate this resource's properties

CustomResourceOptions options

A bag of options that control this resource's behavior

Properties

View Source

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>
View Source

Enabled

Enable this rule in the cluster. Default: true.

Declaration
public Output<bool?> Enabled { get; }
Property Value
Type Description
Output<System.Nullable<System.Boolean>>
View Source

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>>
View Source

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>
View Source

VirtualMachineIds

The UUIDs of the virtual machines to run on the same host together.

Declaration
public Output<ImmutableArray<string>> VirtualMachineIds { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<System.String>>

Methods

View Source

Get(String, Input<String>, ComputeClusterVmAffinityRuleState, CustomResourceOptions)

Get an existing ComputeClusterVmAffinityRule resource's state with the given name, ID, and optional extra properties used to qualify the lookup.

Declaration
public static ComputeClusterVmAffinityRule Get(string name, Input<string> id, ComputeClusterVmAffinityRuleState 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.

ComputeClusterVmAffinityRuleState state

Any extra arguments used during the lookup.

CustomResourceOptions options

A bag of options that control this resource's behavior

Returns
Type Description
ComputeClusterVmAffinityRule
  • View Source
Back to top Copyright 2016-2020, Pulumi Corporation.