@pulumi/vsphere
Version:
A Pulumi package for creating vsphere resources
154 lines • 6.13 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.DrsVmOverride = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* The `vsphere.DrsVmOverride` resource can be used to add a DRS override to a
* cluster for a specific virtual machine. With this resource, one can enable or
* disable DRS and control the automation level for a single virtual machine
* without affecting the rest of the cluster.
*
* For more information on vSphere clusters and DRS, see [this
* page][ref-vsphere-drs-clusters].
*
* [ref-vsphere-drs-clusters]: https://techdocs.broadcom.com/us/en/vmware-cis/vsphere/vsphere/8-0/vsphere-resource-management-8-0/creating-a-drs-cluster.html
*
* > **NOTE:** This resource requires vCenter and is not available on direct ESXi
* connections.
*
* ## Example Usage
*
* The example below creates a virtual machine in a cluster using the
* `vsphere.VirtualMachine` resource, creating the
* virtual machine in the cluster looked up by the
* `vsphere.ComputeCluster` data source, but also
* pinning the VM to a host defined by the
* `vsphere.Host` data source, which is assumed to
* be a host within the cluster. To ensure that the VM stays on this host and does
* not need to be migrated back at any point in time, an override is entered using
* the `vsphere.DrsVmOverride` resource that disables DRS for this virtual
* machine, ensuring that it does not move.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as vsphere from "@pulumi/vsphere";
*
* const datacenter = vsphere.getDatacenter({
* name: "dc-01",
* });
* const datastore = datacenter.then(datacenter => vsphere.getDatastore({
* name: "datastore1",
* datacenterId: datacenter.id,
* }));
* const cluster = datacenter.then(datacenter => vsphere.getComputeCluster({
* name: "cluster-01",
* datacenterId: datacenter.id,
* }));
* const host = datacenter.then(datacenter => vsphere.getHost({
* name: "esxi-01.example.com",
* datacenterId: datacenter.id,
* }));
* const network = datacenter.then(datacenter => vsphere.getNetwork({
* name: "network1",
* datacenterId: datacenter.id,
* }));
* const vm = new vsphere.VirtualMachine("vm", {
* name: "test",
* resourcePoolId: cluster.then(cluster => cluster.resourcePoolId),
* hostSystemId: host.then(host => host.id),
* datastoreId: datastore.then(datastore => datastore.id),
* numCpus: 2,
* memory: 2048,
* guestId: "otherLinux64Guest",
* networkInterfaces: [{
* networkId: network.then(network => network.id),
* }],
* disks: [{
* label: "disk0",
* size: 20,
* }],
* });
* const drsVmOverride = new vsphere.DrsVmOverride("drs_vm_override", {
* computeClusterId: cluster.then(cluster => cluster.id),
* virtualMachineId: vm.id,
* drsEnabled: false,
* });
* ```
*
* ## Import
*
* An existing override can be imported into this resource by
*
* supplying both the path to the cluster, and the path to the virtual machine, to
*
* `pulumi import`. If no override exists, an error will be given. An example
*
* is below:
*
* [docs-import]: https://developer.hashicorp.com/terraform/cli/import
*
* ```sh
* $ pulumi import vsphere:index/drsVmOverride:DrsVmOverride drs_vm_override \
* ```
*
* '{"compute_cluster_path": "/dc1/host/cluster1", \
*
* "virtual_machine_path": "/dc1/vm/srv1"}'
*/
class DrsVmOverride extends pulumi.CustomResource {
/**
* Get an existing DrsVmOverride 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 DrsVmOverride(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of DrsVmOverride. 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'] === DrsVmOverride.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["computeClusterId"] = state?.computeClusterId;
resourceInputs["drsAutomationLevel"] = state?.drsAutomationLevel;
resourceInputs["drsEnabled"] = state?.drsEnabled;
resourceInputs["virtualMachineId"] = state?.virtualMachineId;
}
else {
const args = argsOrState;
if (args?.computeClusterId === undefined && !opts.urn) {
throw new Error("Missing required property 'computeClusterId'");
}
if (args?.virtualMachineId === undefined && !opts.urn) {
throw new Error("Missing required property 'virtualMachineId'");
}
resourceInputs["computeClusterId"] = args?.computeClusterId;
resourceInputs["drsAutomationLevel"] = args?.drsAutomationLevel;
resourceInputs["drsEnabled"] = args?.drsEnabled;
resourceInputs["virtualMachineId"] = args?.virtualMachineId;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(DrsVmOverride.__pulumiType, name, resourceInputs, opts);
}
}
exports.DrsVmOverride = DrsVmOverride;
/** @internal */
DrsVmOverride.__pulumiType = 'vsphere:index/drsVmOverride:DrsVmOverride';
//# sourceMappingURL=drsVmOverride.js.map