@pulumi/vsphere
Version:
A Pulumi package for creating vsphere resources
137 lines • 5.93 kB
JavaScript
;
// *** 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.DpmHostOverride = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* The `vsphere.DpmHostOverride` resource can be used to add a DPM override to a
* cluster for a particular host. This allows you to control the power management
* settings for individual hosts in the cluster while leaving any unspecified ones
* at the default power management settings.
*
* For more information on DPM within vSphere clusters, see [this
* page][ref-vsphere-cluster-dpm].
*
* [ref-vsphere-cluster-dpm]: https://techdocs.broadcom.com/us/en/vmware-cis/vsphere/vsphere/8-0/vsphere-resource-management-8-0/using-drs-clusters-to-manage-resources/managing-power-resources.html
*
* > **NOTE:** This resource requires vCenter and is not available on direct ESXi
* connections.
*
* ## Example Usage
*
* The following example creates a compute cluster comprised of three hosts,
* making use of the
* `vsphere.ComputeCluster` resource. DPM
* will be disabled in the cluster as it is the default setting, but we override
* the setting of the first host referenced by the
* `vsphere.Host` data source (`esxi1`) by using
* the `vsphere.DpmHostOverride` resource so it will be powered off when the
* cluster does not need it to service virtual machines.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as vsphere from "@pulumi/vsphere";
*
* const config = new pulumi.Config();
* const datacenter = config.get("datacenter") || "dc-01";
* const hosts = config.getObject<any>("hosts") || [
* "esxi-01.example.com",
* "esxi-02.example.com",
* "esxi-03.example.com",
* ];
* const datacenterGetDatacenter = vsphere.getDatacenter({
* name: datacenter,
* });
* const hostsGetHost = (new Array(hosts.length)).map((_, i) => i).map(__index => (vsphere.getHost({
* name: hosts[__index],
* datacenterId: _arg0_.id,
* })));
* const computeCluster = new vsphere.ComputeCluster("compute_cluster", {
* name: "compute-cluster-test",
* datacenterId: dc.id,
* hostSystemIds: [hostsGetHost.map(__item => __item.id)],
* drsEnabled: true,
* drsAutomationLevel: "fullyAutomated",
* });
* const dpmHostOverride = new vsphere.DpmHostOverride("dpm_host_override", {
* computeClusterId: computeCluster.id,
* hostSystemId: hostsGetHost[0].then(hostsGetHost => hostsGetHost.id),
* dpmEnabled: true,
* dpmAutomationLevel: "automated",
* });
* ```
*
* ## Import
*
* An existing override can be imported into this resource by
*
* supplying both the path to the cluster, and the path to the host, to `terraform
*
* 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/dpmHostOverride:DpmHostOverride dpm_host_override \
* ```
*
* '{"compute_cluster_path": "/dc1/host/cluster1", \
*
* "host_path": "/dc1/host/esxi1"}'
*/
class DpmHostOverride extends pulumi.CustomResource {
/**
* Get an existing DpmHostOverride 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 DpmHostOverride(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of DpmHostOverride. 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'] === DpmHostOverride.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["computeClusterId"] = state ? state.computeClusterId : undefined;
resourceInputs["dpmAutomationLevel"] = state ? state.dpmAutomationLevel : undefined;
resourceInputs["dpmEnabled"] = state ? state.dpmEnabled : undefined;
resourceInputs["hostSystemId"] = state ? state.hostSystemId : undefined;
}
else {
const args = argsOrState;
if ((!args || args.computeClusterId === undefined) && !opts.urn) {
throw new Error("Missing required property 'computeClusterId'");
}
if ((!args || args.hostSystemId === undefined) && !opts.urn) {
throw new Error("Missing required property 'hostSystemId'");
}
resourceInputs["computeClusterId"] = args ? args.computeClusterId : undefined;
resourceInputs["dpmAutomationLevel"] = args ? args.dpmAutomationLevel : undefined;
resourceInputs["dpmEnabled"] = args ? args.dpmEnabled : undefined;
resourceInputs["hostSystemId"] = args ? args.hostSystemId : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(DpmHostOverride.__pulumiType, name, resourceInputs, opts);
}
}
exports.DpmHostOverride = DpmHostOverride;
/** @internal */
DpmHostOverride.__pulumiType = 'vsphere:index/dpmHostOverride:DpmHostOverride';
//# sourceMappingURL=dpmHostOverride.js.map