UNPKG

@pulumi/vsphere

Version:

A Pulumi package for creating vsphere resources

175 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.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, Object.assign(Object.assign({}, 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 ? state.computeClusterId : undefined; resourceInputs["haDatastoreApdRecoveryAction"] = state ? state.haDatastoreApdRecoveryAction : undefined; resourceInputs["haDatastoreApdResponse"] = state ? state.haDatastoreApdResponse : undefined; resourceInputs["haDatastoreApdResponseDelay"] = state ? state.haDatastoreApdResponseDelay : undefined; resourceInputs["haDatastorePdlResponse"] = state ? state.haDatastorePdlResponse : undefined; resourceInputs["haHostIsolationResponse"] = state ? state.haHostIsolationResponse : undefined; resourceInputs["haVmFailureInterval"] = state ? state.haVmFailureInterval : undefined; resourceInputs["haVmMaximumFailureWindow"] = state ? state.haVmMaximumFailureWindow : undefined; resourceInputs["haVmMaximumResets"] = state ? state.haVmMaximumResets : undefined; resourceInputs["haVmMinimumUptime"] = state ? state.haVmMinimumUptime : undefined; resourceInputs["haVmMonitoring"] = state ? state.haVmMonitoring : undefined; resourceInputs["haVmMonitoringUseClusterDefaults"] = state ? state.haVmMonitoringUseClusterDefaults : undefined; resourceInputs["haVmRestartPriority"] = state ? state.haVmRestartPriority : undefined; resourceInputs["haVmRestartTimeout"] = state ? state.haVmRestartTimeout : undefined; resourceInputs["virtualMachineId"] = state ? state.virtualMachineId : undefined; } else { const args = argsOrState; if ((!args || args.computeClusterId === undefined) && !opts.urn) { throw new Error("Missing required property 'computeClusterId'"); } if ((!args || args.virtualMachineId === undefined) && !opts.urn) { throw new Error("Missing required property 'virtualMachineId'"); } resourceInputs["computeClusterId"] = args ? args.computeClusterId : undefined; resourceInputs["haDatastoreApdRecoveryAction"] = args ? args.haDatastoreApdRecoveryAction : undefined; resourceInputs["haDatastoreApdResponse"] = args ? args.haDatastoreApdResponse : undefined; resourceInputs["haDatastoreApdResponseDelay"] = args ? args.haDatastoreApdResponseDelay : undefined; resourceInputs["haDatastorePdlResponse"] = args ? args.haDatastorePdlResponse : undefined; resourceInputs["haHostIsolationResponse"] = args ? args.haHostIsolationResponse : undefined; resourceInputs["haVmFailureInterval"] = args ? args.haVmFailureInterval : undefined; resourceInputs["haVmMaximumFailureWindow"] = args ? args.haVmMaximumFailureWindow : undefined; resourceInputs["haVmMaximumResets"] = args ? args.haVmMaximumResets : undefined; resourceInputs["haVmMinimumUptime"] = args ? args.haVmMinimumUptime : undefined; resourceInputs["haVmMonitoring"] = args ? args.haVmMonitoring : undefined; resourceInputs["haVmMonitoringUseClusterDefaults"] = args ? args.haVmMonitoringUseClusterDefaults : undefined; resourceInputs["haVmRestartPriority"] = args ? args.haVmRestartPriority : undefined; resourceInputs["haVmRestartTimeout"] = args ? args.haVmRestartTimeout : undefined; resourceInputs["virtualMachineId"] = args ? args.virtualMachineId : undefined; } 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