UNPKG

@pulumi/vsphere

Version:

A Pulumi package for creating vsphere resources

227 lines • 9.37 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.VmfsDatastore = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * The `vsphere.VmfsDatastore` resource can be used to create and manage VMFS * datastores on an ESXi host or a set of hosts. The resource supports using any * SCSI device that can generally be used in a datastore, such as local disks, or * disks presented to a host or multiple hosts over Fibre Channel or iSCSI. * Devices can be specified manually, or discovered using the * [`vsphere.getVmfsDisks`][data-source-vmfs-disks] data source. * * [data-source-vmfs-disks]: /docs/providers/vsphere/d/vmfs_disks.html * * ## Auto-Mounting of Datastores Within vCenter * * Note that the current behavior of this resource will auto-mount any created * datastores to any other host within vCenter that has access to the same disk. * * Example: You want to create a datastore with a iSCSI LUN that is visible on 3 * hosts in a single vSphere cluster (`esxi1`, `esxi2` and `esxi3`). When you * create the datastore on `esxi1`, the datastore will be automatically mounted on * `esxi2` and `esxi3`, without the need to configure the resource on either of * those two hosts. * * Future versions of this resource may allow you to control the hosts that a * datastore is mounted to, but currently, this automatic behavior cannot be * changed, so keep this in mind when writing your configurations and deploying * your disks. * * ## Increasing Datastore Size * * To increase the size of a datastore, you must add additional disks to the * `disks` attribute. Expanding the size of a datastore by increasing the size of * an already provisioned disk is currently not supported (but may be in future * versions of this resource). * * > **NOTE:** You cannot decrease the size of a datastore. If the resource * detects disks removed from the configuration, the provider will give an error. * * [cmd-taint]: /docs/commands/taint.html * * ## Example Usage * * ### Addition of local disks on a single host * * The following example uses the default datacenter and default host to add a * datastore with local disks to a single ESXi server. * * > **NOTE:** There are some situations where datastore creation will not work * when working through vCenter (usually when trying to create a datastore on a * single host with local disks). If you experience trouble creating the datastore * you need through vCenter, break the datastore off into a different configuration * and deploy it using the ESXi server as the provider endpoint, using a similar * configuration to what is below. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as vsphere from "@pulumi/vsphere"; * * const datacenter = vsphere.getDatacenter({}); * const host = datacenter.then(datacenter => vsphere.getHost({ * datacenterId: datacenter.id, * })); * const datastore = new vsphere.VmfsDatastore("datastore", { * name: "test", * hostSystemId: esxiHost.id, * disks: [ * "mpx.vmhba1:C0:T1:L0", * "mpx.vmhba1:C0:T2:L0", * "mpx.vmhba1:C0:T2:L0", * ], * }); * ``` * * ### Auto-detection of disks via `vsphere.getVmfsDisks` * * The following example makes use of the * `vsphere.getVmfsDisks` data source to auto-detect * exported iSCSI LUNS matching a certain NAA vendor ID (in this case, LUNs * exported from a [NetApp][ext-netapp]). These discovered disks are then loaded * into `vsphere.VmfsDatastore`. The datastore is also placed in the * `datastore-folder` folder afterwards. * * [ext-netapp]: https://kb.netapp.com/support/s/article/ka31A0000000rLRQAY/how-to-match-a-lun-s-naa-number-to-its-serial-number?language=en_US * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as vsphere from "@pulumi/vsphere"; * * const datacenter = vsphere.getDatacenter({ * name: "dc-01", * }); * const host = datacenter.then(datacenter => vsphere.getHost({ * name: "esxi-01.example.com", * datacenterId: datacenter.id, * })); * const available = host.then(host => vsphere.getVmfsDisks({ * hostSystemId: host.id, * rescan: true, * filter: "naa.60a98000", * })); * const datastore = new vsphere.VmfsDatastore("datastore", { * name: "test", * hostSystemId: esxiHost.id, * folder: "datastore-folder", * disks: [available.then(available => available.disks)], * }); * ``` * * ## Import * * An existing VMFS datastore can be imported into this resource * * via its managed object ID, via the command below. You also need the host system * * ID. * * [docs-import]: https://developer.hashicorp.com/terraform/cli/import * * ```sh * $ pulumi import vsphere:index/vmfsDatastore:VmfsDatastore datastore datastore-123:host-10 * ``` * * You need a tool like [`govc`][ext-govc] that can display managed object IDs. * * [ext-govc]: https://github.com/vmware/govmomi/tree/master/govc * * In the case of govc, you can locate a managed object ID from an inventory path * * by doing the following: * * $ govc ls -i /dc/datastore/terraform-test * * Datastore:datastore-123 * * To locate host IDs, it might be a good idea to supply the `-l` flag as well so * * that you can line up the names with the IDs: * * $ govc ls -l -i /dc/host/cluster1 * * ResourcePool:resgroup-10 /dc/host/cluster1/Resources * * HostSystem:host-10 /dc/host/cluster1/esxi1 * * HostSystem:host-11 /dc/host/cluster1/esxi2 * * HostSystem:host-12 /dc/host/cluster1/esxi3 */ class VmfsDatastore extends pulumi.CustomResource { /** * Get an existing VmfsDatastore 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 VmfsDatastore(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of VmfsDatastore. 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'] === VmfsDatastore.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["accessible"] = state?.accessible; resourceInputs["capacity"] = state?.capacity; resourceInputs["customAttributes"] = state?.customAttributes; resourceInputs["datastoreClusterId"] = state?.datastoreClusterId; resourceInputs["disks"] = state?.disks; resourceInputs["folder"] = state?.folder; resourceInputs["freeSpace"] = state?.freeSpace; resourceInputs["hostSystemId"] = state?.hostSystemId; resourceInputs["maintenanceMode"] = state?.maintenanceMode; resourceInputs["multipleHostAccess"] = state?.multipleHostAccess; resourceInputs["name"] = state?.name; resourceInputs["tags"] = state?.tags; resourceInputs["uncommittedSpace"] = state?.uncommittedSpace; resourceInputs["url"] = state?.url; } else { const args = argsOrState; if (args?.disks === undefined && !opts.urn) { throw new Error("Missing required property 'disks'"); } if (args?.hostSystemId === undefined && !opts.urn) { throw new Error("Missing required property 'hostSystemId'"); } resourceInputs["customAttributes"] = args?.customAttributes; resourceInputs["datastoreClusterId"] = args?.datastoreClusterId; resourceInputs["disks"] = args?.disks; resourceInputs["folder"] = args?.folder; resourceInputs["hostSystemId"] = args?.hostSystemId; resourceInputs["name"] = args?.name; resourceInputs["tags"] = args?.tags; resourceInputs["accessible"] = undefined /*out*/; resourceInputs["capacity"] = undefined /*out*/; resourceInputs["freeSpace"] = undefined /*out*/; resourceInputs["maintenanceMode"] = undefined /*out*/; resourceInputs["multipleHostAccess"] = undefined /*out*/; resourceInputs["uncommittedSpace"] = undefined /*out*/; resourceInputs["url"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(VmfsDatastore.__pulumiType, name, resourceInputs, opts); } } exports.VmfsDatastore = VmfsDatastore; /** @internal */ VmfsDatastore.__pulumiType = 'vsphere:index/vmfsDatastore:VmfsDatastore'; //# sourceMappingURL=vmfsDatastore.js.map