UNPKG

@pulumi/vsphere

Version:

A Pulumi package for creating vsphere resources

175 lines 8.1 kB
"use strict"; // *** 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.HaVmOverride = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * The `vsphere.HaVmOverride` resource can be used to add an override for * vSphere HA settings on a cluster for a specific virtual machine. With this * resource, one can control specific HA settings so that they are different than * the cluster default, accommodating the needs of that specific virtual machine, * while not affecting the rest of the cluster. * * For more information on vSphere HA, see [this page][ref-vsphere-ha-clusters]. * * [ref-vsphere-ha-clusters]: https://techdocs.broadcom.com/us/en/vmware-cis/vsphere/vsphere/8-0/vsphere-availability.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. * * Considering a scenario where this virtual machine is of high value to the * application or organization for which it does its work, it's been determined in * the event of a host failure, that this should be one of the first virtual * machines to be started by vSphere HA during recovery. Hence, it * `haVmRestartPriority` has been set to `highest`, * which, assuming that the default restart priority is `medium` and no other * virtual machine has been assigned the `highest` priority, will mean that this * VM will be started before any other virtual machine in the event of host * failure. * * ```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 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), * 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 haVmOverride = new vsphere.HaVmOverride("ha_vm_override", { * computeClusterId: cluster.then(cluster => cluster.id), * virtualMachineId: vm.id, * haVmRestartPriority: "highest", * }); * ``` * * ## 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/haVmOverride:HaVmOverride ha_vm_override \ * ``` * * '{"compute_cluster_path": "/dc1/host/cluster1", \ * * "virtual_machine_path": "/dc1/vm/srv1"}' */ class HaVmOverride extends pulumi.CustomResource { /** * Get an existing HaVmOverride 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 HaVmOverride(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of HaVmOverride. 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'] === HaVmOverride.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["computeClusterId"] = state?.computeClusterId; resourceInputs["haDatastoreApdRecoveryAction"] = state?.haDatastoreApdRecoveryAction; resourceInputs["haDatastoreApdResponse"] = state?.haDatastoreApdResponse; resourceInputs["haDatastoreApdResponseDelay"] = state?.haDatastoreApdResponseDelay; resourceInputs["haDatastorePdlResponse"] = state?.haDatastorePdlResponse; resourceInputs["haHostIsolationResponse"] = state?.haHostIsolationResponse; resourceInputs["haVmFailureInterval"] = state?.haVmFailureInterval; resourceInputs["haVmMaximumFailureWindow"] = state?.haVmMaximumFailureWindow; resourceInputs["haVmMaximumResets"] = state?.haVmMaximumResets; resourceInputs["haVmMinimumUptime"] = state?.haVmMinimumUptime; resourceInputs["haVmMonitoring"] = state?.haVmMonitoring; resourceInputs["haVmMonitoringUseClusterDefaults"] = state?.haVmMonitoringUseClusterDefaults; resourceInputs["haVmRestartPriority"] = state?.haVmRestartPriority; resourceInputs["haVmRestartTimeout"] = state?.haVmRestartTimeout; 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["haDatastoreApdRecoveryAction"] = args?.haDatastoreApdRecoveryAction; resourceInputs["haDatastoreApdResponse"] = args?.haDatastoreApdResponse; resourceInputs["haDatastoreApdResponseDelay"] = args?.haDatastoreApdResponseDelay; resourceInputs["haDatastorePdlResponse"] = args?.haDatastorePdlResponse; resourceInputs["haHostIsolationResponse"] = args?.haHostIsolationResponse; resourceInputs["haVmFailureInterval"] = args?.haVmFailureInterval; resourceInputs["haVmMaximumFailureWindow"] = args?.haVmMaximumFailureWindow; resourceInputs["haVmMaximumResets"] = args?.haVmMaximumResets; resourceInputs["haVmMinimumUptime"] = args?.haVmMinimumUptime; resourceInputs["haVmMonitoring"] = args?.haVmMonitoring; resourceInputs["haVmMonitoringUseClusterDefaults"] = args?.haVmMonitoringUseClusterDefaults; resourceInputs["haVmRestartPriority"] = args?.haVmRestartPriority; resourceInputs["haVmRestartTimeout"] = args?.haVmRestartTimeout; resourceInputs["virtualMachineId"] = args?.virtualMachineId; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(HaVmOverride.__pulumiType, name, resourceInputs, opts); } } exports.HaVmOverride = HaVmOverride; /** @internal */ HaVmOverride.__pulumiType = 'vsphere:index/haVmOverride:HaVmOverride'; //# sourceMappingURL=haVmOverride.js.map