@pulumi/vsphere
Version:
A Pulumi package for creating vsphere resources
184 lines • 7.71 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.ComputeClusterVmDependencyRule = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* The `vsphere.ComputeClusterVmDependencyRule` resource can be used to manage
* VM dependency rules in a cluster, either created by the
* `vsphere.ComputeCluster` resource or looked up
* by the `vsphere.ComputeCluster` data source.
*
* A virtual machine dependency rule applies to vSphere HA, and allows
* user-defined startup orders for virtual machines in the case of host failure.
* Virtual machines are supplied via groups, which can be managed via the
* `vsphere.ComputeClusterVmGroup`
* resource.
*
* > **NOTE:** This resource requires vCenter and is not available on direct ESXi
* connections.
*
* ## Example Usage
*
* The example below creates two virtual machine in a cluster using the
* `vsphere.VirtualMachine` resource in a cluster
* looked up by the `vsphere.ComputeCluster`
* data source. It then creates a group with this virtual machine. Two groups are created, each with one of the created VMs. Finally, a rule is created to ensure that `vm1` starts before `vm2`.
*
* > Note how `dependencyVmGroupName` and
* `vmGroupName` are sourced off of the `name` attributes from
* the `vsphere.ComputeClusterVmGroup`
* resource. This is to ensure that the rule is not created before the groups
* exist, which may not possibly happen in the event that the names came from a
* "static" source such as a variable.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as vsphere from "@pulumi/vsphere";
*
* const datacenter = vsphere.getDatacenter({
* name: "dc-01",
* });
* const datastore = datacenter.then(datacenter => vsphere.getDatastore({
* name: "datastore1",
* datacenterId: datacenter.id,
* }));
* const cluster = datacenter.then(datacenter => vsphere.getComputeCluster({
* name: "cluster-01",
* datacenterId: datacenter.id,
* }));
* const network = datacenter.then(datacenter => vsphere.getNetwork({
* name: "network1",
* datacenterId: datacenter.id,
* }));
* const vm1 = new vsphere.VirtualMachine("vm1", {
* name: "test1",
* resourcePoolId: cluster.then(cluster => cluster.resourcePoolId),
* datastoreId: datastore.then(datastore => datastore.id),
* numCpus: 2,
* memory: 2048,
* guestId: "otherLinux64Guest",
* networkInterfaces: [{
* networkId: network.then(network => network.id),
* }],
* disks: [{
* label: "disk0",
* size: 20,
* }],
* });
* const vm2 = new vsphere.VirtualMachine("vm2", {
* name: "test2",
* resourcePoolId: cluster.then(cluster => cluster.resourcePoolId),
* datastoreId: datastore.then(datastore => datastore.id),
* numCpus: 2,
* memory: 2048,
* guestId: "otherLinux64Guest",
* networkInterfaces: [{
* networkId: network.then(network => network.id),
* }],
* disks: [{
* label: "disk0",
* size: 20,
* }],
* });
* const clusterVmGroup1 = new vsphere.ComputeClusterVmGroup("cluster_vm_group1", {
* name: "test-cluster-vm-group1",
* computeClusterId: cluster.then(cluster => cluster.id),
* virtualMachineIds: [vm1.id],
* });
* const clusterVmGroup2 = new vsphere.ComputeClusterVmGroup("cluster_vm_group2", {
* name: "test-cluster-vm-group2",
* computeClusterId: cluster.then(cluster => cluster.id),
* virtualMachineIds: [vm2.id],
* });
* const clusterVmDependencyRule = new vsphere.ComputeClusterVmDependencyRule("cluster_vm_dependency_rule", {
* computeClusterId: cluster.then(cluster => cluster.id),
* name: "test-cluster-vm-dependency-rule",
* dependencyVmGroupName: clusterVmGroup1.name,
* vmGroupName: clusterVmGroup2.name,
* });
* ```
*
* ## Import
*
* An existing rule can be imported into this resource by supplying
*
* both the path to the cluster, and the name the rule. If the name or cluster is
*
* not found, or if the rule is of a different type, an error will be returned. An
*
* example is below:
*
* [docs-import]: https://developer.hashicorp.com/terraform/cli/import
*
* ```sh
* $ pulumi import vsphere:index/computeClusterVmDependencyRule:ComputeClusterVmDependencyRule cluster_vm_dependency_rule \
* ```
*
* '{"compute_cluster_path": "/dc1/host/cluster1", \
*
* "name": "pulumi-test-cluster-vm-dependency-rule"}'
*/
class ComputeClusterVmDependencyRule extends pulumi.CustomResource {
/**
* Get an existing ComputeClusterVmDependencyRule 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 ComputeClusterVmDependencyRule(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of ComputeClusterVmDependencyRule. 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'] === ComputeClusterVmDependencyRule.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["computeClusterId"] = state?.computeClusterId;
resourceInputs["dependencyVmGroupName"] = state?.dependencyVmGroupName;
resourceInputs["enabled"] = state?.enabled;
resourceInputs["mandatory"] = state?.mandatory;
resourceInputs["name"] = state?.name;
resourceInputs["vmGroupName"] = state?.vmGroupName;
}
else {
const args = argsOrState;
if (args?.computeClusterId === undefined && !opts.urn) {
throw new Error("Missing required property 'computeClusterId'");
}
if (args?.dependencyVmGroupName === undefined && !opts.urn) {
throw new Error("Missing required property 'dependencyVmGroupName'");
}
if (args?.vmGroupName === undefined && !opts.urn) {
throw new Error("Missing required property 'vmGroupName'");
}
resourceInputs["computeClusterId"] = args?.computeClusterId;
resourceInputs["dependencyVmGroupName"] = args?.dependencyVmGroupName;
resourceInputs["enabled"] = args?.enabled;
resourceInputs["mandatory"] = args?.mandatory;
resourceInputs["name"] = args?.name;
resourceInputs["vmGroupName"] = args?.vmGroupName;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(ComputeClusterVmDependencyRule.__pulumiType, name, resourceInputs, opts);
}
}
exports.ComputeClusterVmDependencyRule = ComputeClusterVmDependencyRule;
/** @internal */
ComputeClusterVmDependencyRule.__pulumiType = 'vsphere:index/computeClusterVmDependencyRule:ComputeClusterVmDependencyRule';
//# sourceMappingURL=computeClusterVmDependencyRule.js.map