@pulumi/libvirt
Version:
A Pulumi package for creating and managing libvirt cloud resources.
101 lines • 4.65 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.Volume = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* Manages a storage volume in libvirt. For more information see
* [the official documentation](https://libvirt.org/formatstorage.html).
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as libvirt from "@pulumi/libvirt";
*
* // Base OS image to use to create a cluster of different
* // nodes
* const opensuseLeap = new libvirt.Volume("opensuse_leap", {
* name: "opensuse_leap",
* source: "http://download.opensuse.org/repositories/Cloud:/Images:/Leap_42.1/images/openSUSE-Leap-42.1-OpenStack.x86_64.qcow2",
* });
* // volume to attach to the "master" domain as main disk
* const master = new libvirt.Volume("master", {
* name: "master.qcow2",
* baseVolumeId: opensuseLeap.id,
* });
* // volumes to attach to the "workers" domains as main disk
* const worker: libvirt.Volume[] = [];
* for (const range = {value: 0}; range.value < workersCount; range.value++) {
* worker.push(new libvirt.Volume(`worker-${range.value}`, {
* name: `worker_${range.value}.qcow2`,
* baseVolumeId: opensuseLeap.id,
* }));
* }
* ```
*
* > **Tip:** when provisioning multiple domains using the same base image, create
* a `libvirt.Volume` for the base image and then define the domain specific ones
* as based on it. This way the image will not be modified and no extra disk space
* is going to be used for the base image.
*/
class Volume extends pulumi.CustomResource {
/**
* Get an existing Volume 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 Volume(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of Volume. 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'] === Volume.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["baseVolumeId"] = state ? state.baseVolumeId : undefined;
resourceInputs["baseVolumeName"] = state ? state.baseVolumeName : undefined;
resourceInputs["baseVolumePool"] = state ? state.baseVolumePool : undefined;
resourceInputs["format"] = state ? state.format : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["pool"] = state ? state.pool : undefined;
resourceInputs["size"] = state ? state.size : undefined;
resourceInputs["source"] = state ? state.source : undefined;
resourceInputs["xml"] = state ? state.xml : undefined;
}
else {
const args = argsOrState;
resourceInputs["baseVolumeId"] = args ? args.baseVolumeId : undefined;
resourceInputs["baseVolumeName"] = args ? args.baseVolumeName : undefined;
resourceInputs["baseVolumePool"] = args ? args.baseVolumePool : undefined;
resourceInputs["format"] = args ? args.format : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["pool"] = args ? args.pool : undefined;
resourceInputs["size"] = args ? args.size : undefined;
resourceInputs["source"] = args ? args.source : undefined;
resourceInputs["xml"] = args ? args.xml : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Volume.__pulumiType, name, resourceInputs, opts);
}
}
exports.Volume = Volume;
/** @internal */
Volume.__pulumiType = 'libvirt:index/volume:Volume';
//# sourceMappingURL=volume.js.map