/
resourcePool.ts
447 lines (439 loc) · 18.9 KB
/
resourcePool.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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
// *** 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.ResourcePool` resource can be used to create and manage
* resource pools on DRS-enabled vSphere clusters or standalone ESXi hosts.
*
* For more information on vSphere resource pools, please refer to the
* [product documentation][ref-vsphere-resource_pools].
*
* [ref-vsphere-resource_pools]: https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.resmgmt.doc/GUID-60077B40-66FF-4625-934A-641703ED7601.html
*
* ## Example Usage
*
* The following example sets up a resource pool in an existing compute cluster
* with the default settings for CPU and memory reservations, shares, and limits.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as vsphere from "@pulumi/vsphere";
*
* const datacenter = vsphere.getDatacenter({
* name: "dc-01",
* });
* const computeCluster = datacenter.then(datacenter => vsphere.getComputeCluster({
* name: "cluster-01",
* datacenterId: datacenter.id,
* }));
* const resourcePool = new vsphere.ResourcePool("resource_pool", {
* name: "resource-pool-01",
* parentResourcePoolId: computeCluster.then(computeCluster => computeCluster.resourcePoolId),
* });
* ```
*
* A virtual machine resource could be targeted to use the default resource pool
* of the cluster using the following:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as vsphere from "@pulumi/vsphere";
*
* const vm = new vsphere.VirtualMachine("vm", {resourcePoolId: cluster.resourcePoolId});
* ```
*
* The following example sets up a parent resource pool in an existing compute cluster
* with a child resource pool nested below. Each resource pool is configured with
* the default settings for CPU and memory reservations, shares, and limits.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as vsphere from "@pulumi/vsphere";
*
* const datacenter = vsphere.getDatacenter({
* name: "dc-01",
* });
* const computeCluster = datacenter.then(datacenter => vsphere.getComputeCluster({
* name: "cluster-01",
* datacenterId: datacenter.id,
* }));
* const resourcePoolParent = new vsphere.ResourcePool("resource_pool_parent", {
* name: "parent",
* parentResourcePoolId: computeCluster.then(computeCluster => computeCluster.resourcePoolId),
* });
* const resourcePoolChild = new vsphere.ResourcePool("resource_pool_child", {
* name: "child",
* parentResourcePoolId: resourcePoolParent.id,
* });
* ```
*
* ## Importing
*
* An existing resource pool can be imported into this resource via
* the path to the resource pool, using the following command:
*
* The above would import the resource pool named `resource-pool-01` that is located
* in the compute cluster `cluster-01` in the `dc-01` datacenter.
*
* ### Settings that Require vSphere 7.0 or higher
*
* These settings require vSphere 7.0 or higher:
*
* * `scaleDescendantsShares`
*/
export class ResourcePool extends pulumi.CustomResource {
/**
* Get an existing ResourcePool 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.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
public static get(name: string, id: pulumi.Input<pulumi.ID>, state?: ResourcePoolState, opts?: pulumi.CustomResourceOptions): ResourcePool {
return new ResourcePool(name, <any>state, { ...opts, id: id });
}
/** @internal */
public static readonly __pulumiType = 'vsphere:index/resourcePool:ResourcePool';
/**
* Returns true if the given object is an instance of ResourcePool. 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 ResourcePool {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === ResourcePool.__pulumiType;
}
/**
* Determines if the reservation on a resource
* pool can grow beyond the specified value if the parent resource pool has
* unreserved resources. Default: `true`
*/
public readonly cpuExpandable!: pulumi.Output<boolean | undefined>;
/**
* The CPU utilization of a resource pool will not
* exceed this limit, even if there are available resources. Set to `-1` for
* unlimited. Default: `-1`
*/
public readonly cpuLimit!: pulumi.Output<number | undefined>;
/**
* Amount of CPU (MHz) that is guaranteed
* available to the resource pool. Default: `0`
*/
public readonly cpuReservation!: pulumi.Output<number | undefined>;
/**
* The CPU allocation level. The level is a
* simplified view of shares. Levels map to a pre-determined set of numeric
* values for shares. Can be one of `low`, `normal`, `high`, or `custom`. When
* `low`, `normal`, or `high` are specified values in `cpuShares` will be
* ignored. Default: `normal`
*/
public readonly cpuShareLevel!: pulumi.Output<string | undefined>;
/**
* The number of shares allocated for CPU. Used to
* determine resource allocation in case of resource contention. If this is set,
* `cpuShareLevel` must be `custom`.
*/
public readonly cpuShares!: pulumi.Output<number>;
/**
* A list of custom attributes to set on this resource.
*/
public readonly customAttributes!: pulumi.Output<{[key: string]: string} | undefined>;
/**
* Determines if the reservation on a resource
* pool can grow beyond the specified value if the parent resource pool has
* unreserved resources. Default: `true`
*/
public readonly memoryExpandable!: pulumi.Output<boolean | undefined>;
/**
* The CPU utilization of a resource pool will not
* exceed this limit, even if there are available resources. Set to `-1` for
* unlimited. Default: `-1`
*/
public readonly memoryLimit!: pulumi.Output<number | undefined>;
/**
* Amount of CPU (MHz) that is guaranteed
* available to the resource pool. Default: `0`
*/
public readonly memoryReservation!: pulumi.Output<number | undefined>;
/**
* The CPU allocation level. The level is a
* simplified view of shares. Levels map to a pre-determined set of numeric
* values for shares. Can be one of `low`, `normal`, `high`, or `custom`. When
* `low`, `normal`, or `high` are specified values in `memoryShares` will be
* ignored. Default: `normal`
*/
public readonly memoryShareLevel!: pulumi.Output<string | undefined>;
/**
* The number of shares allocated for CPU. Used to
* determine resource allocation in case of resource contention. If this is set,
* `memoryShareLevel` must be `custom`.
*/
public readonly memoryShares!: pulumi.Output<number>;
/**
* The name of the resource pool.
*/
public readonly name!: pulumi.Output<string>;
/**
* The managed object ID
* of the parent resource pool. This can be the root resource pool for a cluster
* or standalone host, or a resource pool itself. When moving a resource pool
* from one parent resource pool to another, both must share a common root
* resource pool.
*/
public readonly parentResourcePoolId!: pulumi.Output<string>;
/**
* Determines if the shares of all
* descendants of the resource pool are scaled up or down when the shares
* of the resource pool are scaled up or down. Can be one of `disabled` or
* `scaleCpuAndMemoryShares`. Default: `disabled`.
*/
public readonly scaleDescendantsShares!: pulumi.Output<string | undefined>;
/**
* The IDs of any tags to attach to this resource.
*/
public readonly tags!: pulumi.Output<string[] | undefined>;
/**
* Create a ResourcePool 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: ResourcePoolArgs, opts?: pulumi.CustomResourceOptions)
constructor(name: string, argsOrState?: ResourcePoolArgs | ResourcePoolState, opts?: pulumi.CustomResourceOptions) {
let resourceInputs: pulumi.Inputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState as ResourcePoolState | undefined;
resourceInputs["cpuExpandable"] = state ? state.cpuExpandable : undefined;
resourceInputs["cpuLimit"] = state ? state.cpuLimit : undefined;
resourceInputs["cpuReservation"] = state ? state.cpuReservation : undefined;
resourceInputs["cpuShareLevel"] = state ? state.cpuShareLevel : undefined;
resourceInputs["cpuShares"] = state ? state.cpuShares : undefined;
resourceInputs["customAttributes"] = state ? state.customAttributes : undefined;
resourceInputs["memoryExpandable"] = state ? state.memoryExpandable : undefined;
resourceInputs["memoryLimit"] = state ? state.memoryLimit : undefined;
resourceInputs["memoryReservation"] = state ? state.memoryReservation : undefined;
resourceInputs["memoryShareLevel"] = state ? state.memoryShareLevel : undefined;
resourceInputs["memoryShares"] = state ? state.memoryShares : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["parentResourcePoolId"] = state ? state.parentResourcePoolId : undefined;
resourceInputs["scaleDescendantsShares"] = state ? state.scaleDescendantsShares : undefined;
resourceInputs["tags"] = state ? state.tags : undefined;
} else {
const args = argsOrState as ResourcePoolArgs | undefined;
if ((!args || args.parentResourcePoolId === undefined) && !opts.urn) {
throw new Error("Missing required property 'parentResourcePoolId'");
}
resourceInputs["cpuExpandable"] = args ? args.cpuExpandable : undefined;
resourceInputs["cpuLimit"] = args ? args.cpuLimit : undefined;
resourceInputs["cpuReservation"] = args ? args.cpuReservation : undefined;
resourceInputs["cpuShareLevel"] = args ? args.cpuShareLevel : undefined;
resourceInputs["cpuShares"] = args ? args.cpuShares : undefined;
resourceInputs["customAttributes"] = args ? args.customAttributes : undefined;
resourceInputs["memoryExpandable"] = args ? args.memoryExpandable : undefined;
resourceInputs["memoryLimit"] = args ? args.memoryLimit : undefined;
resourceInputs["memoryReservation"] = args ? args.memoryReservation : undefined;
resourceInputs["memoryShareLevel"] = args ? args.memoryShareLevel : undefined;
resourceInputs["memoryShares"] = args ? args.memoryShares : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["parentResourcePoolId"] = args ? args.parentResourcePoolId : undefined;
resourceInputs["scaleDescendantsShares"] = args ? args.scaleDescendantsShares : undefined;
resourceInputs["tags"] = args ? args.tags : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(ResourcePool.__pulumiType, name, resourceInputs, opts);
}
}
/**
* Input properties used for looking up and filtering ResourcePool resources.
*/
export interface ResourcePoolState {
/**
* Determines if the reservation on a resource
* pool can grow beyond the specified value if the parent resource pool has
* unreserved resources. Default: `true`
*/
cpuExpandable?: pulumi.Input<boolean>;
/**
* The CPU utilization of a resource pool will not
* exceed this limit, even if there are available resources. Set to `-1` for
* unlimited. Default: `-1`
*/
cpuLimit?: pulumi.Input<number>;
/**
* Amount of CPU (MHz) that is guaranteed
* available to the resource pool. Default: `0`
*/
cpuReservation?: pulumi.Input<number>;
/**
* The CPU allocation level. The level is a
* simplified view of shares. Levels map to a pre-determined set of numeric
* values for shares. Can be one of `low`, `normal`, `high`, or `custom`. When
* `low`, `normal`, or `high` are specified values in `cpuShares` will be
* ignored. Default: `normal`
*/
cpuShareLevel?: pulumi.Input<string>;
/**
* The number of shares allocated for CPU. Used to
* determine resource allocation in case of resource contention. If this is set,
* `cpuShareLevel` must be `custom`.
*/
cpuShares?: pulumi.Input<number>;
/**
* A list of custom attributes to set on this resource.
*/
customAttributes?: pulumi.Input<{[key: string]: pulumi.Input<string>}>;
/**
* Determines if the reservation on a resource
* pool can grow beyond the specified value if the parent resource pool has
* unreserved resources. Default: `true`
*/
memoryExpandable?: pulumi.Input<boolean>;
/**
* The CPU utilization of a resource pool will not
* exceed this limit, even if there are available resources. Set to `-1` for
* unlimited. Default: `-1`
*/
memoryLimit?: pulumi.Input<number>;
/**
* Amount of CPU (MHz) that is guaranteed
* available to the resource pool. Default: `0`
*/
memoryReservation?: pulumi.Input<number>;
/**
* The CPU allocation level. The level is a
* simplified view of shares. Levels map to a pre-determined set of numeric
* values for shares. Can be one of `low`, `normal`, `high`, or `custom`. When
* `low`, `normal`, or `high` are specified values in `memoryShares` will be
* ignored. Default: `normal`
*/
memoryShareLevel?: pulumi.Input<string>;
/**
* The number of shares allocated for CPU. Used to
* determine resource allocation in case of resource contention. If this is set,
* `memoryShareLevel` must be `custom`.
*/
memoryShares?: pulumi.Input<number>;
/**
* The name of the resource pool.
*/
name?: pulumi.Input<string>;
/**
* The managed object ID
* of the parent resource pool. This can be the root resource pool for a cluster
* or standalone host, or a resource pool itself. When moving a resource pool
* from one parent resource pool to another, both must share a common root
* resource pool.
*/
parentResourcePoolId?: pulumi.Input<string>;
/**
* Determines if the shares of all
* descendants of the resource pool are scaled up or down when the shares
* of the resource pool are scaled up or down. Can be one of `disabled` or
* `scaleCpuAndMemoryShares`. Default: `disabled`.
*/
scaleDescendantsShares?: pulumi.Input<string>;
/**
* The IDs of any tags to attach to this resource.
*/
tags?: pulumi.Input<pulumi.Input<string>[]>;
}
/**
* The set of arguments for constructing a ResourcePool resource.
*/
export interface ResourcePoolArgs {
/**
* Determines if the reservation on a resource
* pool can grow beyond the specified value if the parent resource pool has
* unreserved resources. Default: `true`
*/
cpuExpandable?: pulumi.Input<boolean>;
/**
* The CPU utilization of a resource pool will not
* exceed this limit, even if there are available resources. Set to `-1` for
* unlimited. Default: `-1`
*/
cpuLimit?: pulumi.Input<number>;
/**
* Amount of CPU (MHz) that is guaranteed
* available to the resource pool. Default: `0`
*/
cpuReservation?: pulumi.Input<number>;
/**
* The CPU allocation level. The level is a
* simplified view of shares. Levels map to a pre-determined set of numeric
* values for shares. Can be one of `low`, `normal`, `high`, or `custom`. When
* `low`, `normal`, or `high` are specified values in `cpuShares` will be
* ignored. Default: `normal`
*/
cpuShareLevel?: pulumi.Input<string>;
/**
* The number of shares allocated for CPU. Used to
* determine resource allocation in case of resource contention. If this is set,
* `cpuShareLevel` must be `custom`.
*/
cpuShares?: pulumi.Input<number>;
/**
* A list of custom attributes to set on this resource.
*/
customAttributes?: pulumi.Input<{[key: string]: pulumi.Input<string>}>;
/**
* Determines if the reservation on a resource
* pool can grow beyond the specified value if the parent resource pool has
* unreserved resources. Default: `true`
*/
memoryExpandable?: pulumi.Input<boolean>;
/**
* The CPU utilization of a resource pool will not
* exceed this limit, even if there are available resources. Set to `-1` for
* unlimited. Default: `-1`
*/
memoryLimit?: pulumi.Input<number>;
/**
* Amount of CPU (MHz) that is guaranteed
* available to the resource pool. Default: `0`
*/
memoryReservation?: pulumi.Input<number>;
/**
* The CPU allocation level. The level is a
* simplified view of shares. Levels map to a pre-determined set of numeric
* values for shares. Can be one of `low`, `normal`, `high`, or `custom`. When
* `low`, `normal`, or `high` are specified values in `memoryShares` will be
* ignored. Default: `normal`
*/
memoryShareLevel?: pulumi.Input<string>;
/**
* The number of shares allocated for CPU. Used to
* determine resource allocation in case of resource contention. If this is set,
* `memoryShareLevel` must be `custom`.
*/
memoryShares?: pulumi.Input<number>;
/**
* The name of the resource pool.
*/
name?: pulumi.Input<string>;
/**
* The managed object ID
* of the parent resource pool. This can be the root resource pool for a cluster
* or standalone host, or a resource pool itself. When moving a resource pool
* from one parent resource pool to another, both must share a common root
* resource pool.
*/
parentResourcePoolId: pulumi.Input<string>;
/**
* Determines if the shares of all
* descendants of the resource pool are scaled up or down when the shares
* of the resource pool are scaled up or down. Can be one of `disabled` or
* `scaleCpuAndMemoryShares`. Default: `disabled`.
*/
scaleDescendantsShares?: pulumi.Input<string>;
/**
* The IDs of any tags to attach to this resource.
*/
tags?: pulumi.Input<pulumi.Input<string>[]>;
}