UNPKG

@muhlba91/pulumi-proxmoxve

Version:

A Pulumi package for creating and managing Proxmox Virtual Environment cloud resources.

187 lines 8.12 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.File = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Use this resource to upload files to a Proxmox VE node. The file can be a backup, an ISO image, a Disk Image, a snippet, or a container template depending on the `contentType` attribute. * * ## Example Usage * * ### Backups (`backup`) * * > The resource with this content type uses SSH access to the node. You might need to configure the `ssh` option in the `provider` section. * * > The provider currently does not support restoring backups. You can use the Proxmox VE web interface or the `qmrestore` / `pct restore` command to restore VM / Container from a backup. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as proxmoxve from "@muhlba91/pulumi-proxmoxve"; * * const backup = new proxmoxve.storage.File("backup", { * contentType: "backup", * datastoreId: "local", * nodeName: "pve", * sourceFile: { * path: "vzdump-lxc-100-2023_11_08-23_10_05.tar.zst", * }, * }); * ``` * * ### Images * * > Consider using `proxmoxve.Download.File` resource instead. Using this resource for images is less efficient (requires to transfer uploaded image to node) though still supported. * * > Importing Disks is not enabled by default in new Proxmox installations. You need to enable them in the 'Datacenter>Storage' section of the proxmox interface before first using this resource with `contentType = "import"`. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as proxmoxve from "@muhlba91/pulumi-proxmoxve"; * * const ubuntuContainerTemplate = new proxmoxve.storage.File("ubuntuContainerTemplate", { * contentType: "iso", * datastoreId: "local", * nodeName: "pve", * sourceFile: { * path: "https://cloud-images.ubuntu.com/jammy/20230929/jammy-server-cloudimg-amd64-disk-kvm.img", * }, * }); * ``` * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as proxmoxve from "@muhlba91/pulumi-proxmoxve"; * * const ubuntuContainerTemplate = new proxmoxve.storage.File("ubuntuContainerTemplate", { * contentType: "import", * datastoreId: "local", * nodeName: "pve", * sourceFile: { * path: "https://cloud-images.ubuntu.com/jammy/20230929/jammy-server-cloudimg-amd64-disk-kvm.img", * }, * }); * ``` * * ### Container Template (`vztmpl`) * * > Consider using `proxmoxve.Download.File` resource instead. Using this resource for container images is less efficient (requires to transfer uploaded image to node) though still supported. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as proxmoxve from "@muhlba91/pulumi-proxmoxve"; * * const ubuntuContainerTemplate = new proxmoxve.storage.File("ubuntuContainerTemplate", { * contentType: "vztmpl", * datastoreId: "local", * nodeName: "first-node", * sourceFile: { * path: "http://download.proxmox.com/images/system/ubuntu-20.04-standard_20.04-1_amd64.tar.gz", * }, * }); * ``` * * ## Important Notes * * The Proxmox VE API endpoint for file uploads does not support chunked transfer * encoding, which means that we must first store the source file as a temporary * file locally before uploading it. * * You must ensure that you have at least `Size-in-MB * 2 + 1` MB of storage space * available (twice the size plus overhead because a multipart payload needs to be * created as another temporary file). * * By default, if the specified file already exists, the resource will * unconditionally replace it and take ownership of the resource. On destruction, * the file will be deleted as if it did not exist before. If you want to prevent * the resource from replacing the file, set `overwrite` to `false`. * * ## Import * * Instances can be imported using the `node_name`, `datastore_id`, `content_type` * * and the `file_name` in the following format: * * text * * node_name:datastore_id/content_type/file_name * * Example: * * bash * * ```sh * $ pulumi import proxmoxve:Storage/file:File cloud_config pve/local:snippets/example.cloud-config.yaml * ``` */ class File extends pulumi.CustomResource { /** * Get an existing File 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 File(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of File. 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'] === File.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["contentType"] = state ? state.contentType : undefined; resourceInputs["datastoreId"] = state ? state.datastoreId : undefined; resourceInputs["fileMode"] = state ? state.fileMode : undefined; resourceInputs["fileModificationDate"] = state ? state.fileModificationDate : undefined; resourceInputs["fileName"] = state ? state.fileName : undefined; resourceInputs["fileSize"] = state ? state.fileSize : undefined; resourceInputs["fileTag"] = state ? state.fileTag : undefined; resourceInputs["nodeName"] = state ? state.nodeName : undefined; resourceInputs["overwrite"] = state ? state.overwrite : undefined; resourceInputs["sourceFile"] = state ? state.sourceFile : undefined; resourceInputs["sourceRaw"] = state ? state.sourceRaw : undefined; resourceInputs["timeoutUpload"] = state ? state.timeoutUpload : undefined; } else { const args = argsOrState; if ((!args || args.datastoreId === undefined) && !opts.urn) { throw new Error("Missing required property 'datastoreId'"); } if ((!args || args.nodeName === undefined) && !opts.urn) { throw new Error("Missing required property 'nodeName'"); } resourceInputs["contentType"] = args ? args.contentType : undefined; resourceInputs["datastoreId"] = args ? args.datastoreId : undefined; resourceInputs["fileMode"] = args ? args.fileMode : undefined; resourceInputs["nodeName"] = args ? args.nodeName : undefined; resourceInputs["overwrite"] = args ? args.overwrite : undefined; resourceInputs["sourceFile"] = args ? args.sourceFile : undefined; resourceInputs["sourceRaw"] = args ? args.sourceRaw : undefined; resourceInputs["timeoutUpload"] = args ? args.timeoutUpload : undefined; resourceInputs["fileModificationDate"] = undefined /*out*/; resourceInputs["fileName"] = undefined /*out*/; resourceInputs["fileSize"] = undefined /*out*/; resourceInputs["fileTag"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(File.__pulumiType, name, resourceInputs, opts); } } exports.File = File; /** @internal */ File.__pulumiType = 'proxmoxve:Storage/file:File'; //# sourceMappingURL=file.js.map