UNPKG

@pulumi/vsphere

Version:

A Pulumi package for creating vsphere resources

190 lines 7.41 kB
"use strict"; // *** 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.VmStoragePolicy = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * The `vsphere.VmStoragePolicy` resource can be used to create and manage storage * policies. Using this resource, tag based placement rules can be created to * place virtual machines on a datastore with matching tags. If storage requirements for the applications on the virtual machine change, you can modify the storage policy that was originally applied to the virtual machine. * * ## Example Usage * * The following example creates storage policies with `tagRules` base on sets of environment, service level, and replication attributes. * * In this example, tags are first applied to datastores. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as vsphere from "@pulumi/vsphere"; * * const environment = vsphere.getTagCategory({ * name: "environment", * }); * const serviceLevel = vsphere.getTagCategory({ * name: "service_level", * }); * const replication = vsphere.getTagCategory({ * name: "replication", * }); * const production = vsphere.getTag({ * name: "production", * categoryId: "data.vsphere_tag_category.environment.id", * }); * const development = vsphere.getTag({ * name: "development", * categoryId: "data.vsphere_tag_category.environment.id", * }); * const platinum = vsphere.getTag({ * name: "platinum", * categoryId: "data.vsphere_tag_category.service_level.id", * }); * const gold = vsphere.getTag({ * name: "platinum", * categoryId: "data.vsphere_tag_category.service_level.id", * }); * const silver = vsphere.getTag({ * name: "silver", * categoryId: "data.vsphere_tag_category.service_level.id", * }); * const bronze = vsphere.getTag({ * name: "bronze", * categoryId: "data.vsphere_tag_category.service_level.id", * }); * const replicated = vsphere.getTag({ * name: "replicated", * categoryId: "data.vsphere_tag_category.replication.id", * }); * const nonReplicated = vsphere.getTag({ * name: "non_replicated", * categoryId: "data.vsphere_tag_category.replication.id", * }); * const prodDatastore = new vsphere.VmfsDatastore("prod_datastore", {tags: [ * "data.vsphere_tag.production.id", * "data.vsphere_tag.platinum.id", * "data.vsphere_tag.replicated.id", * ]}); * const devDatastore = new vsphere.NasDatastore("dev_datastore", {tags: [ * "data.vsphere_tag.development.id", * "data.vsphere_tag.silver.id", * "data.vsphere_tag.non_replicated.id", * ]}); * ``` * * Next, storage policies are created and `tagRules` are applied. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as vsphere from "@pulumi/vsphere"; * * const prodPlatinumReplicated = new vsphere.VmStoragePolicy("prod_platinum_replicated", { * name: "prod_platinum_replicated", * description: "prod_platinum_replicated", * tagRules: [ * { * tagCategory: environment.name, * tags: [production.name], * includeDatastoresWithTags: true, * }, * { * tagCategory: serviceLevel.name, * tags: [platinum.name], * includeDatastoresWithTags: true, * }, * { * tagCategory: replication.name, * tags: [replicated.name], * includeDatastoresWithTags: true, * }, * ], * }); * const devSilverNonreplicated = new vsphere.VmStoragePolicy("dev_silver_nonreplicated", { * name: "dev_silver_nonreplicated", * description: "dev_silver_nonreplicated", * tagRules: [ * { * tagCategory: environment.name, * tags: [development.name], * includeDatastoresWithTags: true, * }, * { * tagCategory: serviceLevel.name, * tags: [silver.name], * includeDatastoresWithTags: true, * }, * { * tagCategory: replication.name, * tags: [nonReplicated.name], * includeDatastoresWithTags: true, * }, * ], * }); * ``` * * Lastly, when creating a virtual machine resource, a storage policy can be specified to direct virtual machine placement to a datastore which matches the policy's `tagsRules`. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as vsphere from "@pulumi/vsphere"; * * const prodPlatinumReplicated = vsphere.getPolicy({ * name: "prod_platinum_replicated", * }); * const devSilverNonreplicated = vsphere.getPolicy({ * name: "dev_silver_nonreplicated", * }); * const prodVm = new vsphere.VirtualMachine("prod_vm", {storagePolicyId: storagePolicy.prodPlatinumReplicated.id}); * const devVm = new vsphere.VirtualMachine("dev_vm", {storagePolicyId: storagePolicy.devSilverNonreplicated.id}); * ``` */ class VmStoragePolicy extends pulumi.CustomResource { /** * Get an existing VmStoragePolicy 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 VmStoragePolicy(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of VmStoragePolicy. 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'] === VmStoragePolicy.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["description"] = state ? state.description : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["tagRules"] = state ? state.tagRules : undefined; } else { const args = argsOrState; if ((!args || args.tagRules === undefined) && !opts.urn) { throw new Error("Missing required property 'tagRules'"); } resourceInputs["description"] = args ? args.description : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["tagRules"] = args ? args.tagRules : undefined; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(VmStoragePolicy.__pulumiType, name, resourceInputs, opts); } } exports.VmStoragePolicy = VmStoragePolicy; /** @internal */ VmStoragePolicy.__pulumiType = 'vsphere:index/vmStoragePolicy:VmStoragePolicy'; //# sourceMappingURL=vmStoragePolicy.js.map