-
Notifications
You must be signed in to change notification settings - Fork 6
/
computeClusterVmDependencyRule.ts
294 lines (285 loc) · 11.7 KB
/
computeClusterVmDependencyRule.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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
// *** 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..ComputeClusterVmDependencyRule` resource can be used to manage
* VM dependency rules in a cluster, either created by the
* [`vsphere..ComputeCluster`][tf-vsphere-cluster-resource] resource or looked up
* by the [`vsphere..ComputeCluster`][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
*
* A virtual machine dependency rule applies to vSphere HA, and allows
* user-defined startup orders for virtual machines in the case of host failure.
* Virtual machines are supplied via groups, which can be managed via the
* [`vsphere..ComputeClusterVmGroup`][tf-vsphere-cluster-vm-group-resource]
* resource.
*
* [tf-vsphere-cluster-vm-group-resource]: /docs/providers/vsphere/r/compute_cluster_vm_group.html
*
* > **NOTE:** This resource requires vCenter and is not available on direct ESXi
* connections.
*
* ## Example Usage
*
* The example below creates two virtual machine in a cluster using the
* [`vsphere..VirtualMachine`][tf-vsphere-vm-resource] resource in a cluster
* looked up by the [`vsphere..ComputeCluster`][tf-vsphere-cluster-data-source]
* data source. It then creates a group with this virtual machine. Two groups are created, each with one of the created VMs. Finally, a rule is created to ensure that `vm1` starts before `vm2`.
*
* [tf-vsphere-vm-resource]: /docs/providers/vsphere/r/virtual_machine.html
*
* > Note how `dependencyVmGroupName` and
* `vmGroupName` are sourced off of the `name` attributes from
* the [`vsphere..ComputeClusterVmGroup`][tf-vsphere-cluster-vm-group-resource]
* resource. This is to ensure that the rule is not created before the groups
* exist, which may not possibly happen in the event that the names came from a
* "static" source such as a variable.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as vsphere from "@pulumi/vsphere";
*
* const dc = vsphere.getDatacenter({
* name: "dc1",
* });
* const datastore = vsphere.getDatastore({
* datacenterId: dc.id,
* name: "datastore1",
* });
* const cluster = vsphere.getComputeCluster({
* datacenterId: dc.id,
* name: "cluster1",
* });
* const network = vsphere.getNetwork({
* datacenterId: dc.id,
* name: "network1",
* });
* const vm1 = new vsphere.VirtualMachine("vm1", {
* datastoreId: datastore.id,
* disks: [{
* label: "disk0",
* size: 20,
* }],
* guestId: "other3xLinux64Guest",
* memory: 2048,
* networkInterfaces: [{
* networkId: network.id,
* }],
* numCpus: 2,
* resourcePoolId: cluster.resourcePoolId,
* });
* const vm2 = new vsphere.VirtualMachine("vm2", {
* datastoreId: datastore.id,
* disks: [{
* label: "disk0",
* size: 20,
* }],
* guestId: "other3xLinux64Guest",
* memory: 2048,
* networkInterfaces: [{
* networkId: network.id,
* }],
* numCpus: 2,
* resourcePoolId: cluster.resourcePoolId,
* });
* const clusterVmGroup1 = new vsphere.ComputeClusterVmGroup("clusterVmGroup1", {
* computeClusterId: cluster.id,
* virtualMachineIds: [vm1.id],
* });
* const clusterVmGroup2 = new vsphere.ComputeClusterVmGroup("clusterVmGroup2", {
* computeClusterId: cluster.id,
* virtualMachineIds: [vm2.id],
* });
* const clusterVmDependencyRule = new vsphere.ComputeClusterVmDependencyRule("clusterVmDependencyRule", {
* computeClusterId: cluster.id,
* dependencyVmGroupName: clusterVmGroup1.name,
* vmGroupName: clusterVmGroup2.name,
* });
* ```
*
* > This content is derived from https://github.com/terraform-providers/terraform-provider-vsphere/blob/master/website/docs/r/compute_cluster_vm_dependency_rule.html.markdown.
*/
export class ComputeClusterVmDependencyRule extends pulumi.CustomResource {
/**
* Get an existing ComputeClusterVmDependencyRule 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?: ComputeClusterVmDependencyRuleState, opts?: pulumi.CustomResourceOptions): ComputeClusterVmDependencyRule {
return new ComputeClusterVmDependencyRule(name, <any>state, { ...opts, id: id });
}
/** @internal */
public static readonly __pulumiType = 'vsphere:index/computeClusterVmDependencyRule:ComputeClusterVmDependencyRule';
/**
* Returns true if the given object is an instance of ComputeClusterVmDependencyRule. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
public static isInstance(obj: any): obj is ComputeClusterVmDependencyRule {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === ComputeClusterVmDependencyRule.__pulumiType;
}
/**
* 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>;
/**
* The name of the VM group that this
* rule depends on. The VMs defined in the group specified by
* `vmGroupName` will not be started until the VMs in this
* group are started.
*/
public readonly dependencyVmGroupName!: 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 name of the VM group that is the subject of
* this rule. The VMs defined in this group will not be started until the VMs in
* the group specified by
* `dependencyVmGroupName` are started.
*/
public readonly vmGroupName!: pulumi.Output<string>;
/**
* Create a ComputeClusterVmDependencyRule 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: ComputeClusterVmDependencyRuleArgs, opts?: pulumi.CustomResourceOptions)
constructor(name: string, argsOrState?: ComputeClusterVmDependencyRuleArgs | ComputeClusterVmDependencyRuleState, opts?: pulumi.CustomResourceOptions) {
let inputs: pulumi.Inputs = {};
if (opts && opts.id) {
const state = argsOrState as ComputeClusterVmDependencyRuleState | undefined;
inputs["computeClusterId"] = state ? state.computeClusterId : undefined;
inputs["dependencyVmGroupName"] = state ? state.dependencyVmGroupName : undefined;
inputs["enabled"] = state ? state.enabled : undefined;
inputs["mandatory"] = state ? state.mandatory : undefined;
inputs["name"] = state ? state.name : undefined;
inputs["vmGroupName"] = state ? state.vmGroupName : undefined;
} else {
const args = argsOrState as ComputeClusterVmDependencyRuleArgs | undefined;
if (!args || args.computeClusterId === undefined) {
throw new Error("Missing required property 'computeClusterId'");
}
if (!args || args.dependencyVmGroupName === undefined) {
throw new Error("Missing required property 'dependencyVmGroupName'");
}
if (!args || args.vmGroupName === undefined) {
throw new Error("Missing required property 'vmGroupName'");
}
inputs["computeClusterId"] = args ? args.computeClusterId : undefined;
inputs["dependencyVmGroupName"] = args ? args.dependencyVmGroupName : undefined;
inputs["enabled"] = args ? args.enabled : undefined;
inputs["mandatory"] = args ? args.mandatory : undefined;
inputs["name"] = args ? args.name : undefined;
inputs["vmGroupName"] = args ? args.vmGroupName : undefined;
}
if (!opts) {
opts = {}
}
if (!opts.version) {
opts.version = utilities.getVersion();
}
super(ComputeClusterVmDependencyRule.__pulumiType, name, inputs, opts);
}
}
/**
* Input properties used for looking up and filtering ComputeClusterVmDependencyRule resources.
*/
export interface ComputeClusterVmDependencyRuleState {
/**
* 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>;
/**
* The name of the VM group that this
* rule depends on. The VMs defined in the group specified by
* `vmGroupName` will not be started until the VMs in this
* group are started.
*/
readonly dependencyVmGroupName?: 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 name of the VM group that is the subject of
* this rule. The VMs defined in this group will not be started until the VMs in
* the group specified by
* `dependencyVmGroupName` are started.
*/
readonly vmGroupName?: pulumi.Input<string>;
}
/**
* The set of arguments for constructing a ComputeClusterVmDependencyRule resource.
*/
export interface ComputeClusterVmDependencyRuleArgs {
/**
* 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>;
/**
* The name of the VM group that this
* rule depends on. The VMs defined in the group specified by
* `vmGroupName` will not be started until the VMs in this
* group are started.
*/
readonly dependencyVmGroupName: 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 name of the VM group that is the subject of
* this rule. The VMs defined in this group will not be started until the VMs in
* the group specified by
* `dependencyVmGroupName` are started.
*/
readonly vmGroupName: pulumi.Input<string>;
}