@pulumi/vsphere
Version:
A Pulumi package for creating vsphere resources
253 lines • 7.78 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.Host = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* Provides a VMware vSphere host resource. This represents an ESXi host that
* can be used either as a member of a cluster or as a standalone host.
*
* ## Example Usage
*
* ### Create a standalone host
*
* ```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),
* });
* ```
*
* ### Create host in a compute cluster
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as vsphere from "@pulumi/vsphere";
*
* const datacenter = vsphere.getDatacenter({
* name: "dc-01",
* });
* const cluster = datacenter.then(datacenter => vsphere.getComputeCluster({
* name: "cluster-01",
* datacenterId: datacenter.id,
* }));
* 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),
* cluster: cluster.then(cluster => cluster.id),
* services: [{
* ntpd: {
* enabled: true,
* policy: "on",
* ntpServers: ["pool.ntp.org"],
* },
* }],
* });
* ```
*
* ## Import
*
* An existing host can be imported into this resource by supplying
*
* the host's ID.
*
* [docs-import]: /docs/import/index.html
*
* Obtain the host's ID using the data source. For example:
*
* hcl
*
* data "vsphere_datacenter" "datacenter" {
*
* name = "dc-01"
*
* }
*
* data "vsphere_host" "host" {
*
* name = "esxi-01.example.com"
*
* datacenter_id = data.vsphere_datacenter.datacenter.id
*
* }
*
* output "host_id" {
*
* value = data.vsphere_host.host.id
*
* }
*
* Next, create a resource configuration, For example:
*
* hcl
*
* data "vsphere_datacenter" "datacenter" {
*
* name = "dc-01"
*
* }
*
* data "vsphere_host_thumbprint" "thumbprint" {
*
* address = "esxi-01.example.com"
*
* insecure = true
*
* }
*
* resource "vsphere_host" "esx-01" {
*
* hostname = "esxi-01.example.com"
*
* username = "root"
*
* password = "password"
*
* thumbprint = data.vsphere_host_thumbprint.thumbprint.id
*
* datacenter = data.vsphere_datacenter.datacenter.id
*
* }
*
* hcl
*
* resource "vsphere_host" "esx-01" {
*
* hostname = "esxi-01.example.com"
*
* username = "root"
*
* password = "password"
*
* license = "00000-00000-00000-00000-00000"
*
* thumbprint = data.vsphere_host_thumbprint.thumbprint.id
*
* cluster = data.vsphere_compute_cluster.cluster.id
*
* services {
*
* ntpd {
*
* enabled = true
*
* policy = "on"
*
* ntp_servers = ["pool.ntp.org"]
*
* }
*
* }
*
* }
*
* ```sh
* $ pulumi import vsphere:index/host:Host esx-01 host-123
* ```
*
* The above would import the host `esxi-01.example.com` with the host ID `host-123`.
*/
class Host extends pulumi.CustomResource {
/**
* Get an existing Host 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 Host(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of Host. 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'] === Host.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["cluster"] = state?.cluster;
resourceInputs["clusterManaged"] = state?.clusterManaged;
resourceInputs["connected"] = state?.connected;
resourceInputs["customAttributes"] = state?.customAttributes;
resourceInputs["datacenter"] = state?.datacenter;
resourceInputs["force"] = state?.force;
resourceInputs["hostname"] = state?.hostname;
resourceInputs["license"] = state?.license;
resourceInputs["lockdown"] = state?.lockdown;
resourceInputs["maintenance"] = state?.maintenance;
resourceInputs["password"] = state?.password;
resourceInputs["services"] = state?.services;
resourceInputs["tags"] = state?.tags;
resourceInputs["thumbprint"] = state?.thumbprint;
resourceInputs["username"] = state?.username;
}
else {
const args = argsOrState;
if (args?.hostname === undefined && !opts.urn) {
throw new Error("Missing required property 'hostname'");
}
if (args?.password === undefined && !opts.urn) {
throw new Error("Missing required property 'password'");
}
if (args?.username === undefined && !opts.urn) {
throw new Error("Missing required property 'username'");
}
resourceInputs["cluster"] = args?.cluster;
resourceInputs["clusterManaged"] = args?.clusterManaged;
resourceInputs["connected"] = args?.connected;
resourceInputs["customAttributes"] = args?.customAttributes;
resourceInputs["datacenter"] = args?.datacenter;
resourceInputs["force"] = args?.force;
resourceInputs["hostname"] = args?.hostname;
resourceInputs["license"] = args?.license;
resourceInputs["lockdown"] = args?.lockdown;
resourceInputs["maintenance"] = args?.maintenance;
resourceInputs["password"] = args?.password ? pulumi.secret(args.password) : undefined;
resourceInputs["services"] = args?.services;
resourceInputs["tags"] = args?.tags;
resourceInputs["thumbprint"] = args?.thumbprint;
resourceInputs["username"] = args?.username;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const secretOpts = { additionalSecretOutputs: ["password"] };
opts = pulumi.mergeOptions(opts, secretOpts);
super(Host.__pulumiType, name, resourceInputs, opts);
}
}
exports.Host = Host;
/** @internal */
Host.__pulumiType = 'vsphere:index/host:Host';
//# sourceMappingURL=host.js.map