-
Notifications
You must be signed in to change notification settings - Fork 6
/
computeClusterVmAntiAffinityRule.ts
220 lines (214 loc) · 8.99 KB
/
computeClusterVmAntiAffinityRule.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
import * as pulumi from "@pulumi/pulumi";
import * as utilities from "./utilities";
/**
* The `vsphere_compute_cluster_vm_anti_affinity_rule` resource can be used to
* manage VM anti-affinity rules in a cluster, either created by the
* [`vsphere_compute_cluster`][tf-vsphere-cluster-resource] resource or looked up
* by the [`vsphere_compute_cluster`][tf-vsphere-cluster-data-source] data source.
*
* [tf-vsphere-cluster-resource]: /docs/providers/vsphere/r/compute_cluster.html
* [tf-vsphere-cluster-data-source]: /docs/providers/vsphere/d/compute_cluster.html
*
* 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_compute_cluster_vm_host_rule`][tf-vsphere-cluster-vm-host-rule-resource]
* resource.
*
* [tf-vsphere-cluster-vm-host-rule-resource]: /docs/providers/vsphere/r/compute_cluster_vm_host_rule.html
*
* > **NOTE:** This resource requires vCenter and is not available on direct ESXi
* connections.
*
* > **NOTE:** vSphere DRS requires a vSphere Enterprise Plus license.
*
* ## Example Usage
*
* The example below creates two virtual machines in a cluster using the
* [`vsphere_virtual_machine`][tf-vsphere-vm-resource] resource, creating the
* virtual machines in the cluster looked up by the
* [`vsphere_compute_cluster`][tf-vsphere-cluster-data-source] data source. It
* then creates an anti-affinity rule for these two virtual machines, ensuring
* they will run on different hosts whenever possible.
*
* [tf-vsphere-vm-resource]: /docs/providers/vsphere/r/virtual_machine.html
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as vsphere from "@pulumi/vsphere";
*
* const dc = pulumi.output(vsphere.getDatacenter({
* name: "dc1",
* }));
* const cluster = dc.apply(dc => vsphere.getComputeCluster({
* datacenterId: dc.id,
* name: "cluster1",
* }));
* const datastore = dc.apply(dc => vsphere.getDatastore({
* datacenterId: dc.id,
* name: "datastore1",
* }));
* const network = dc.apply(dc => vsphere.getNetwork({
* datacenterId: dc.id,
* name: "network1",
* }));
* const vm: vsphere.VirtualMachine[] = [];
* for (let i = 0; i < 2; i++) {
* vm.push(new vsphere.VirtualMachine(`vm-${i}`, {
* datastoreId: datastore.id,
* disks: [{
* label: "disk0",
* size: 20,
* }],
* guestId: "other3xLinux64Guest",
* memory: 2048,
* networkInterfaces: [{
* networkId: network.id,
* }],
* numCpus: 2,
* resourcePoolId: cluster.resourcePoolId,
* }));
* }
* const clusterVmAntiAffinityRule = new vsphere.ComputeClusterVmAntiAffinityRule("cluster_vm_anti_affinity_rule", {
* computeClusterId: cluster.id,
* virtualMachineIds: vm.map(v => v.id),
* });
* ```
*/
export class ComputeClusterVmAntiAffinityRule extends pulumi.CustomResource {
/**
* Get an existing ComputeClusterVmAntiAffinityRule resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
*/
public static get(name: string, id: pulumi.Input<pulumi.ID>, state?: ComputeClusterVmAntiAffinityRuleState, opts?: pulumi.CustomResourceOptions): ComputeClusterVmAntiAffinityRule {
return new ComputeClusterVmAntiAffinityRule(name, <any>state, { ...opts, id: id });
}
/**
* The [managed object reference
* ID][docs-about-morefs] of the cluster to put the group in. Forces a new
* resource if changed.
*/
public readonly computeClusterId!: pulumi.Output<string>;
/**
* Enable this rule in the cluster. Default: `true`.
*/
public readonly enabled!: pulumi.Output<boolean | undefined>;
/**
* When this value is `true`, prevents any virtual
* machine operations that may violate this rule. Default: `false`.
*/
public readonly mandatory!: pulumi.Output<boolean | undefined>;
/**
* The name of the rule. This must be unique in the cluster.
*/
public readonly name!: pulumi.Output<string>;
/**
* The UUIDs of the virtual machines to run
* on hosts different from each other.
*/
public readonly virtualMachineIds!: pulumi.Output<string[]>;
/**
* Create a ComputeClusterVmAntiAffinityRule resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args: ComputeClusterVmAntiAffinityRuleArgs, opts?: pulumi.CustomResourceOptions)
constructor(name: string, argsOrState?: ComputeClusterVmAntiAffinityRuleArgs | ComputeClusterVmAntiAffinityRuleState, opts?: pulumi.CustomResourceOptions) {
let inputs: pulumi.Inputs = {};
if (opts && opts.id) {
const state = argsOrState as ComputeClusterVmAntiAffinityRuleState | undefined;
inputs["computeClusterId"] = state ? state.computeClusterId : undefined;
inputs["enabled"] = state ? state.enabled : undefined;
inputs["mandatory"] = state ? state.mandatory : undefined;
inputs["name"] = state ? state.name : undefined;
inputs["virtualMachineIds"] = state ? state.virtualMachineIds : undefined;
} else {
const args = argsOrState as ComputeClusterVmAntiAffinityRuleArgs | undefined;
if (!args || args.computeClusterId === undefined) {
throw new Error("Missing required property 'computeClusterId'");
}
if (!args || args.virtualMachineIds === undefined) {
throw new Error("Missing required property 'virtualMachineIds'");
}
inputs["computeClusterId"] = args ? args.computeClusterId : undefined;
inputs["enabled"] = args ? args.enabled : undefined;
inputs["mandatory"] = args ? args.mandatory : undefined;
inputs["name"] = args ? args.name : undefined;
inputs["virtualMachineIds"] = args ? args.virtualMachineIds : undefined;
}
super("vsphere:index/computeClusterVmAntiAffinityRule:ComputeClusterVmAntiAffinityRule", name, inputs, opts);
}
}
/**
* Input properties used for looking up and filtering ComputeClusterVmAntiAffinityRule resources.
*/
export interface ComputeClusterVmAntiAffinityRuleState {
/**
* The [managed object reference
* ID][docs-about-morefs] of the cluster to put the group in. Forces a new
* resource if changed.
*/
readonly computeClusterId?: pulumi.Input<string>;
/**
* Enable this rule in the cluster. Default: `true`.
*/
readonly enabled?: pulumi.Input<boolean>;
/**
* When this value is `true`, prevents any virtual
* machine operations that may violate this rule. Default: `false`.
*/
readonly mandatory?: pulumi.Input<boolean>;
/**
* The name of the rule. This must be unique in the cluster.
*/
readonly name?: pulumi.Input<string>;
/**
* The UUIDs of the virtual machines to run
* on hosts different from each other.
*/
readonly virtualMachineIds?: pulumi.Input<pulumi.Input<string>[]>;
}
/**
* The set of arguments for constructing a ComputeClusterVmAntiAffinityRule resource.
*/
export interface ComputeClusterVmAntiAffinityRuleArgs {
/**
* The [managed object reference
* ID][docs-about-morefs] of the cluster to put the group in. Forces a new
* resource if changed.
*/
readonly computeClusterId: pulumi.Input<string>;
/**
* Enable this rule in the cluster. Default: `true`.
*/
readonly enabled?: pulumi.Input<boolean>;
/**
* When this value is `true`, prevents any virtual
* machine operations that may violate this rule. Default: `false`.
*/
readonly mandatory?: pulumi.Input<boolean>;
/**
* The name of the rule. This must be unique in the cluster.
*/
readonly name?: pulumi.Input<string>;
/**
* The UUIDs of the virtual machines to run
* on hosts different from each other.
*/
readonly virtualMachineIds: pulumi.Input<pulumi.Input<string>[]>;
}