@pulumi/vsphere
Version:
A Pulumi package for creating vsphere resources
116 lines • 4.63 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.VirtualDisk = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* The `vsphere.VirtualDisk` resource can be used to create virtual disks outside
* of any given `vsphere.VirtualMachine`
* resource. These disks can be attached to a virtual machine by creating a disk
* block with the `attach` parameter.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as vsphere from "@pulumi/vsphere";
*
* const datacenter = vsphere.getDatacenter({
* name: "dc-01",
* });
* const datastore = vsphere.getDatastore({
* name: "datastore-01",
* });
* const virtualDisk = new vsphere.VirtualDisk("virtual_disk", {
* size: 40,
* type: "thin",
* vmdkPath: "/foo/foo.vmdk",
* createDirectories: true,
* datacenter: datacenter.then(datacenter => datacenter.name),
* datastore: datastore.then(datastore => datastore.name),
* });
* ```
*
* ## Import
*
* An existing virtual disk can be imported into this resource
*
* via supplying the full datastore path to the virtual disk. An example is below:
*
* [docs-import]: https://developer.hashicorp.com/terraform/cli/import
*
* ```sh
* $ pulumi import vsphere:index/virtualDisk:VirtualDisk virtual_disk \
* ```
*
* '{"virtual_disk_path": "/dc-01/[datastore-01]foo/bar.vmdk", \ "create_directories": "true"}'
*
* The above would import the virtual disk located at `foo/bar.vmdk` in the `datastore-01`
*
* datastore of the `dc-01` datacenter with `create_directories` set as `true`.
*/
class VirtualDisk extends pulumi.CustomResource {
/**
* Get an existing VirtualDisk 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 VirtualDisk(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of VirtualDisk. 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'] === VirtualDisk.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["adapterType"] = state?.adapterType;
resourceInputs["createDirectories"] = state?.createDirectories;
resourceInputs["datacenter"] = state?.datacenter;
resourceInputs["datastore"] = state?.datastore;
resourceInputs["size"] = state?.size;
resourceInputs["type"] = state?.type;
resourceInputs["vmdkPath"] = state?.vmdkPath;
}
else {
const args = argsOrState;
if (args?.datastore === undefined && !opts.urn) {
throw new Error("Missing required property 'datastore'");
}
if (args?.size === undefined && !opts.urn) {
throw new Error("Missing required property 'size'");
}
if (args?.vmdkPath === undefined && !opts.urn) {
throw new Error("Missing required property 'vmdkPath'");
}
resourceInputs["adapterType"] = args?.adapterType;
resourceInputs["createDirectories"] = args?.createDirectories;
resourceInputs["datacenter"] = args?.datacenter;
resourceInputs["datastore"] = args?.datastore;
resourceInputs["size"] = args?.size;
resourceInputs["type"] = args?.type;
resourceInputs["vmdkPath"] = args?.vmdkPath;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(VirtualDisk.__pulumiType, name, resourceInputs, opts);
}
}
exports.VirtualDisk = VirtualDisk;
/** @internal */
VirtualDisk.__pulumiType = 'vsphere:index/virtualDisk:VirtualDisk';
//# sourceMappingURL=virtualDisk.js.map