UNPKG

@pulumi/vsphere

Version:

A Pulumi package for creating vsphere resources

194 lines • 8.73 kB
"use strict"; // *** 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! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.ResourcePool = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./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://techdocs.broadcom.com/us/en/vmware-cis/vsphere/vsphere/8-0/vsphere-resource-management-8-0/managing-resource-pools.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, * }); * ``` * * The following example set up a parent resource pool on a standalone ESXi host 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 thumbprint = vsphere.getHostThumbprint({ * address: "esxi-01.example.com", * insecure: true, * }); * const esx_01 = new vsphere.Host("esx-01", { * hostname: "esxi-01.example.com", * username: "root", * password: "password", * license: "00000-00000-00000-00000-00000", * thumbprint: thumbprint.then(thumbprint => thumbprint.id), * datacenter: datacenter.then(datacenter => datacenter.id), * }); * ``` * * After the hosts are added to the datacenter, a resource pool can then be created on the host. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as vsphere from "@pulumi/vsphere"; * * const host = vsphere.getHost({ * name: "esxi-01.example.com", * datacenterId: datacenter.id, * }); * const resourcePool = new vsphere.ResourcePool("resource_pool", { * name: "site1-resource-pool", * parentResourcePoolId: host.then(host => host.resourcePoolId), * }); * ``` * * ## Import * * ### Settings that Require vSphere 7.0 or higher * * These settings require vSphere 7.0 or higher: * * * [`scale_descendants_shares`](#scale_descendants_shares) */ 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. */ static get(name, id, state, opts) { return new ResourcePool(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * 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. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === ResourcePool.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; 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; 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); } } exports.ResourcePool = ResourcePool; /** @internal */ ResourcePool.__pulumiType = 'vsphere:index/resourcePool:ResourcePool'; //# sourceMappingURL=resourcePool.js.map