@pulumi/vsphere
Version:
A Pulumi package for creating vsphere resources
167 lines • 5.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.Vnic = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* Provides a VMware vSphere vnic resource.
*
* ## Example Usage
*
* ### Create a vnic attached to a distributed virtual switch using the vmotion TCP/IP stack
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as vsphere from "@pulumi/vsphere";
*
* const datacenter = vsphere.getDatacenter({
* name: "dc-01",
* });
* const host = datacenter.then(datacenter => vsphere.getHost({
* name: "esxi-01.example.com",
* datacenterId: datacenter.id,
* }));
* const vds = new vsphere.DistributedVirtualSwitch("vds", {
* name: "vds-01",
* datacenterId: datacenter.then(datacenter => datacenter.id),
* hosts: [{
* hostSystemId: host.then(host => host.id),
* devices: ["vnic3"],
* }],
* });
* const pg = new vsphere.DistributedPortGroup("pg", {
* name: "pg-01",
* vlanId: 1234,
* distributedVirtualSwitchUuid: vds.id,
* });
* const vnic = new vsphere.Vnic("vnic", {
* host: host.then(host => host.id),
* distributedSwitchPort: vds.id,
* distributedPortGroup: pg.id,
* ipv4: {
* dhcp: true,
* },
* netstack: "vmotion",
* });
* ```
*
* ### Create a vnic attached to a portgroup using the default TCP/IP stack
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as vsphere from "@pulumi/vsphere";
*
* const datacenter = vsphere.getDatacenter({
* name: "dc-01",
* });
* const host = datacenter.then(datacenter => vsphere.getHost({
* name: "esxi-01.example.com",
* datacenterId: datacenter.id,
* }));
* const hvs = new vsphere.HostVirtualSwitch("hvs", {
* name: "hvs-01",
* hostSystemId: host.then(host => host.id),
* networkAdapters: [
* "vmnic3",
* "vmnic4",
* ],
* activeNics: ["vmnic3"],
* standbyNics: ["vmnic4"],
* });
* const pg = new vsphere.HostPortGroup("pg", {
* name: "pg-01",
* virtualSwitchName: hvs.name,
* hostSystemId: host.then(host => host.id),
* });
* const vnic = new vsphere.Vnic("vnic", {
* host: host.then(host => host.id),
* portgroup: pg.name,
* ipv4: {
* dhcp: true,
* },
* services: [
* "vsan",
* "management",
* ],
* });
* ```
*
* ## Import
*
* An existing vNic can be imported into this resource
*
* via supplying the vNic's ID. An example is below:
*
* [docs-import]: /docs/import/index.html
*
* ```sh
* $ pulumi import vsphere:index/vnic:Vnic vnic host-123_vmk2
* ```
*
* The above would import the vnic `vmk2` from host with ID `host-123`.
*/
class Vnic extends pulumi.CustomResource {
/**
* Get an existing Vnic 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 Vnic(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of Vnic. 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'] === Vnic.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["distributedPortGroup"] = state?.distributedPortGroup;
resourceInputs["distributedSwitchPort"] = state?.distributedSwitchPort;
resourceInputs["host"] = state?.host;
resourceInputs["ipv4"] = state?.ipv4;
resourceInputs["ipv6"] = state?.ipv6;
resourceInputs["mac"] = state?.mac;
resourceInputs["mtu"] = state?.mtu;
resourceInputs["netstack"] = state?.netstack;
resourceInputs["portgroup"] = state?.portgroup;
resourceInputs["services"] = state?.services;
}
else {
const args = argsOrState;
if (args?.host === undefined && !opts.urn) {
throw new Error("Missing required property 'host'");
}
resourceInputs["distributedPortGroup"] = args?.distributedPortGroup;
resourceInputs["distributedSwitchPort"] = args?.distributedSwitchPort;
resourceInputs["host"] = args?.host;
resourceInputs["ipv4"] = args?.ipv4;
resourceInputs["ipv6"] = args?.ipv6;
resourceInputs["mac"] = args?.mac;
resourceInputs["mtu"] = args?.mtu;
resourceInputs["netstack"] = args?.netstack;
resourceInputs["portgroup"] = args?.portgroup;
resourceInputs["services"] = args?.services;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Vnic.__pulumiType, name, resourceInputs, opts);
}
}
exports.Vnic = Vnic;
/** @internal */
Vnic.__pulumiType = 'vsphere:index/vnic:Vnic';
//# sourceMappingURL=vnic.js.map