vcd.getVmAffinityRule
Explore with Pulumi AI
Provides a VMware Cloud Director VM affinity rule data source. This can be used to read VM affinity and anti-affinity rules.
Supported in provider v2.9+
Note: The vCD UI defines two different entities (Affinity Rules and Anti-Affinity Rules). This data source combines both entities: they are differentiated by the
polarity
property (See below).
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as vcd from "@pulumi/vcd";
const tf_rule_by_name = vcd.getVmAffinityRule({
name: "my-rule",
});
const tf_rule_by_id = vcd.getVmAffinityRule({
ruleId: "eda9011c-6841-4060-9336-d2f609c110c3",
});
import pulumi
import pulumi_vcd as vcd
tf_rule_by_name = vcd.get_vm_affinity_rule(name="my-rule")
tf_rule_by_id = vcd.get_vm_affinity_rule(rule_id="eda9011c-6841-4060-9336-d2f609c110c3")
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/vcd/v3/vcd"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := vcd.LookupVmAffinityRule(ctx, &vcd.LookupVmAffinityRuleArgs{
Name: pulumi.StringRef("my-rule"),
}, nil)
if err != nil {
return err
}
_, err = vcd.LookupVmAffinityRule(ctx, &vcd.LookupVmAffinityRuleArgs{
RuleId: pulumi.StringRef("eda9011c-6841-4060-9336-d2f609c110c3"),
}, nil)
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Vcd = Pulumi.Vcd;
return await Deployment.RunAsync(() =>
{
var tf_rule_by_name = Vcd.GetVmAffinityRule.Invoke(new()
{
Name = "my-rule",
});
var tf_rule_by_id = Vcd.GetVmAffinityRule.Invoke(new()
{
RuleId = "eda9011c-6841-4060-9336-d2f609c110c3",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.vcd.VcdFunctions;
import com.pulumi.vcd.inputs.GetVmAffinityRuleArgs;
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 tf-rule-by-name = VcdFunctions.getVmAffinityRule(GetVmAffinityRuleArgs.builder()
.name("my-rule")
.build());
final var tf-rule-by-id = VcdFunctions.getVmAffinityRule(GetVmAffinityRuleArgs.builder()
.ruleId("eda9011c-6841-4060-9336-d2f609c110c3")
.build());
}
}
variables:
tf-rule-by-name:
fn::invoke:
function: vcd:getVmAffinityRule
arguments:
name: my-rule
tf-rule-by-id:
fn::invoke:
function: vcd:getVmAffinityRule
arguments:
ruleId: eda9011c-6841-4060-9336-d2f609c110c3
Using getVmAffinityRule
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 getVmAffinityRule(args: GetVmAffinityRuleArgs, opts?: InvokeOptions): Promise<GetVmAffinityRuleResult>
function getVmAffinityRuleOutput(args: GetVmAffinityRuleOutputArgs, opts?: InvokeOptions): Output<GetVmAffinityRuleResult>
def get_vm_affinity_rule(id: Optional[str] = None,
name: Optional[str] = None,
org: Optional[str] = None,
rule_id: Optional[str] = None,
vdc: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetVmAffinityRuleResult
def get_vm_affinity_rule_output(id: Optional[pulumi.Input[str]] = None,
name: Optional[pulumi.Input[str]] = None,
org: Optional[pulumi.Input[str]] = None,
rule_id: Optional[pulumi.Input[str]] = None,
vdc: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetVmAffinityRuleResult]
func LookupVmAffinityRule(ctx *Context, args *LookupVmAffinityRuleArgs, opts ...InvokeOption) (*LookupVmAffinityRuleResult, error)
func LookupVmAffinityRuleOutput(ctx *Context, args *LookupVmAffinityRuleOutputArgs, opts ...InvokeOption) LookupVmAffinityRuleResultOutput
> Note: This function is named LookupVmAffinityRule
in the Go SDK.
public static class GetVmAffinityRule
{
public static Task<GetVmAffinityRuleResult> InvokeAsync(GetVmAffinityRuleArgs args, InvokeOptions? opts = null)
public static Output<GetVmAffinityRuleResult> Invoke(GetVmAffinityRuleInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetVmAffinityRuleResult> getVmAffinityRule(GetVmAffinityRuleArgs args, InvokeOptions options)
public static Output<GetVmAffinityRuleResult> getVmAffinityRule(GetVmAffinityRuleArgs args, InvokeOptions options)
fn::invoke:
function: vcd:index/getVmAffinityRule:getVmAffinityRule
arguments:
# arguments dictionary
The following arguments are supported:
- Id string
- Name string
- The name of VM affinity rule. Needed if we don't provide
rule_id
- Org string
- The name of organization to use, optional if defined at provider level. Useful when connected as sysadmin working across different organisations
- Rule
Id string - Is the ID of the affinity rule. It's the preferred way to retrieve the affinity rule, especially if the rule name could have duplicates
- Vdc string
- The name of VDC to use, optional if defined at provider level
- Id string
- Name string
- The name of VM affinity rule. Needed if we don't provide
rule_id
- Org string
- The name of organization to use, optional if defined at provider level. Useful when connected as sysadmin working across different organisations
- Rule
Id string - Is the ID of the affinity rule. It's the preferred way to retrieve the affinity rule, especially if the rule name could have duplicates
- Vdc string
- The name of VDC to use, optional if defined at provider level
- id String
- name String
- The name of VM affinity rule. Needed if we don't provide
rule_id
- org String
- The name of organization to use, optional if defined at provider level. Useful when connected as sysadmin working across different organisations
- rule
Id String - Is the ID of the affinity rule. It's the preferred way to retrieve the affinity rule, especially if the rule name could have duplicates
- vdc String
- The name of VDC to use, optional if defined at provider level
- id string
- name string
- The name of VM affinity rule. Needed if we don't provide
rule_id
- org string
- The name of organization to use, optional if defined at provider level. Useful when connected as sysadmin working across different organisations
- rule
Id string - Is the ID of the affinity rule. It's the preferred way to retrieve the affinity rule, especially if the rule name could have duplicates
- vdc string
- The name of VDC to use, optional if defined at provider level
- id str
- name str
- The name of VM affinity rule. Needed if we don't provide
rule_id
- org str
- The name of organization to use, optional if defined at provider level. Useful when connected as sysadmin working across different organisations
- rule_
id str - Is the ID of the affinity rule. It's the preferred way to retrieve the affinity rule, especially if the rule name could have duplicates
- vdc str
- The name of VDC to use, optional if defined at provider level
- id String
- name String
- The name of VM affinity rule. Needed if we don't provide
rule_id
- org String
- The name of organization to use, optional if defined at provider level. Useful when connected as sysadmin working across different organisations
- rule
Id String - Is the ID of the affinity rule. It's the preferred way to retrieve the affinity rule, especially if the rule name could have duplicates
- vdc String
- The name of VDC to use, optional if defined at provider level
getVmAffinityRule Result
The following output properties are available:
- Enabled bool
- True if this affinity rule is enabled.
- Id string
- Polarity string
- One of
Affinity
orAnti-Affinity
. This property cannot be changed. Once created, if we need to change polarity, we need to remove the rule and create a new one. - Required bool
- True if this affinity rule is required. When a rule is mandatory, a host failover will not power on the VM if doing so would violate the rule.
- Vm
Ids List<string> - A set of virtual machine IDs that compose this rule.
- Name string
- Org string
- Rule
Id string - Vdc string
- Enabled bool
- True if this affinity rule is enabled.
- Id string
- Polarity string
- One of
Affinity
orAnti-Affinity
. This property cannot be changed. Once created, if we need to change polarity, we need to remove the rule and create a new one. - Required bool
- True if this affinity rule is required. When a rule is mandatory, a host failover will not power on the VM if doing so would violate the rule.
- Vm
Ids []string - A set of virtual machine IDs that compose this rule.
- Name string
- Org string
- Rule
Id string - Vdc string
- enabled Boolean
- True if this affinity rule is enabled.
- id String
- polarity String
- One of
Affinity
orAnti-Affinity
. This property cannot be changed. Once created, if we need to change polarity, we need to remove the rule and create a new one. - required Boolean
- True if this affinity rule is required. When a rule is mandatory, a host failover will not power on the VM if doing so would violate the rule.
- vm
Ids List<String> - A set of virtual machine IDs that compose this rule.
- name String
- org String
- rule
Id String - vdc String
- enabled boolean
- True if this affinity rule is enabled.
- id string
- polarity string
- One of
Affinity
orAnti-Affinity
. This property cannot be changed. Once created, if we need to change polarity, we need to remove the rule and create a new one. - required boolean
- True if this affinity rule is required. When a rule is mandatory, a host failover will not power on the VM if doing so would violate the rule.
- vm
Ids string[] - A set of virtual machine IDs that compose this rule.
- name string
- org string
- rule
Id string - vdc string
- enabled bool
- True if this affinity rule is enabled.
- id str
- polarity str
- One of
Affinity
orAnti-Affinity
. This property cannot be changed. Once created, if we need to change polarity, we need to remove the rule and create a new one. - required bool
- True if this affinity rule is required. When a rule is mandatory, a host failover will not power on the VM if doing so would violate the rule.
- vm_
ids Sequence[str] - A set of virtual machine IDs that compose this rule.
- name str
- org str
- rule_
id str - vdc str
- enabled Boolean
- True if this affinity rule is enabled.
- id String
- polarity String
- One of
Affinity
orAnti-Affinity
. This property cannot be changed. Once created, if we need to change polarity, we need to remove the rule and create a new one. - required Boolean
- True if this affinity rule is required. When a rule is mandatory, a host failover will not power on the VM if doing so would violate the rule.
- vm
Ids List<String> - A set of virtual machine IDs that compose this rule.
- name String
- org String
- rule
Id String - vdc String
Package Details
- Repository
- vcd vmware/terraform-provider-vcd
- License
- Notes
- This Pulumi package is based on the
vcd
Terraform Provider.