UNPKG

@pulumi/vsphere

Version:

A Pulumi package for creating vsphere resources

167 lines 6.13 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.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, Object.assign(Object.assign({}, 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 ? state.distributedPortGroup : undefined; resourceInputs["distributedSwitchPort"] = state ? state.distributedSwitchPort : undefined; resourceInputs["host"] = state ? state.host : undefined; resourceInputs["ipv4"] = state ? state.ipv4 : undefined; resourceInputs["ipv6"] = state ? state.ipv6 : undefined; resourceInputs["mac"] = state ? state.mac : undefined; resourceInputs["mtu"] = state ? state.mtu : undefined; resourceInputs["netstack"] = state ? state.netstack : undefined; resourceInputs["portgroup"] = state ? state.portgroup : undefined; resourceInputs["services"] = state ? state.services : undefined; } else { const args = argsOrState; if ((!args || args.host === undefined) && !opts.urn) { throw new Error("Missing required property 'host'"); } resourceInputs["distributedPortGroup"] = args ? args.distributedPortGroup : undefined; resourceInputs["distributedSwitchPort"] = args ? args.distributedSwitchPort : undefined; resourceInputs["host"] = args ? args.host : undefined; resourceInputs["ipv4"] = args ? args.ipv4 : undefined; resourceInputs["ipv6"] = args ? args.ipv6 : undefined; resourceInputs["mac"] = args ? args.mac : undefined; resourceInputs["mtu"] = args ? args.mtu : undefined; resourceInputs["netstack"] = args ? args.netstack : undefined; resourceInputs["portgroup"] = args ? args.portgroup : undefined; resourceInputs["services"] = args ? args.services : undefined; } 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