@pulumi/vsphere
Version:
A Pulumi package for creating vsphere resources
191 lines • 8.4 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.HostVirtualSwitch = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* The `vsphere.HostVirtualSwitch` resource can be used to manage vSphere
* standard switches on an ESXi host. These switches can be used as a backing for
* standard port groups, which can be managed by the
* `vsphere.HostPortGroup` resource.
*
* For an overview on vSphere networking concepts, see [this
* page][ref-vsphere-net-concepts].
*
* [ref-vsphere-net-concepts]: https://techdocs.broadcom.com/us/en/vmware-cis/vsphere/vsphere/8-0/vsphere-networking-8-0/introduction-to-vsphere-networking.html
*
* ## Example Usage
*
* ### Create a virtual switch with one active and one standby NIC
*
* ```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 _switch = new vsphere.HostVirtualSwitch("switch", {
* name: "vSwitchTest",
* hostSystemId: host.then(host => host.id),
* networkAdapters: [
* "vmnic0",
* "vmnic1",
* ],
* activeNics: ["vmnic0"],
* standbyNics: ["vmnic1"],
* });
* ```
*
* ### Create a virtual switch with extra networking policy options
*
* ```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 _switch = new vsphere.HostVirtualSwitch("switch", {
* name: "vSwitchTest",
* hostSystemId: host.then(host => host.id),
* networkAdapters: [
* "vmnic0",
* "vmnic1",
* ],
* activeNics: ["vmnic0"],
* standbyNics: ["vmnic1"],
* teamingPolicy: "failover_explicit",
* allowPromiscuous: false,
* allowForgedTransmits: false,
* allowMacChanges: false,
* shapingEnabled: true,
* shapingAverageBandwidth: 50000000,
* shapingPeakBandwidth: 100000000,
* shapingBurstSize: 1000000000,
* });
* ```
*
* ## Import
*
* An existing vSwitch can be imported into this resource by its ID.
*
* The convention of the id is a prefix, the host system [managed objectID][docs-about-morefs], and the virtual switch
*
* name. An example would be `tf-HostVirtualSwitch:host-10:vSwitchTerraformTest`.
*
* Import can the be done via the following command:
*
* [docs-import]: https://developer.hashicorp.com/terraform/cli/import
*
* [docs-about-morefs]: /docs/providers/vsphere/index.html#use-of-managed-object-references-by-the-vsphere-provider
*
* ```sh
* $ pulumi import vsphere:index/hostVirtualSwitch:HostVirtualSwitch switch tf-HostVirtualSwitch:host-10:vSwitchTerraformTest
* ```
*
* The above would import the vSwitch named `vSwitchTerraformTest` that is located in the `host-10`
*
* vSphere host.
*/
class HostVirtualSwitch extends pulumi.CustomResource {
/**
* Get an existing HostVirtualSwitch 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 HostVirtualSwitch(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of HostVirtualSwitch. 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'] === HostVirtualSwitch.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["activeNics"] = state?.activeNics;
resourceInputs["allowForgedTransmits"] = state?.allowForgedTransmits;
resourceInputs["allowMacChanges"] = state?.allowMacChanges;
resourceInputs["allowPromiscuous"] = state?.allowPromiscuous;
resourceInputs["beaconInterval"] = state?.beaconInterval;
resourceInputs["checkBeacon"] = state?.checkBeacon;
resourceInputs["failback"] = state?.failback;
resourceInputs["hostSystemId"] = state?.hostSystemId;
resourceInputs["linkDiscoveryOperation"] = state?.linkDiscoveryOperation;
resourceInputs["linkDiscoveryProtocol"] = state?.linkDiscoveryProtocol;
resourceInputs["mtu"] = state?.mtu;
resourceInputs["name"] = state?.name;
resourceInputs["networkAdapters"] = state?.networkAdapters;
resourceInputs["notifySwitches"] = state?.notifySwitches;
resourceInputs["numberOfPorts"] = state?.numberOfPorts;
resourceInputs["shapingAverageBandwidth"] = state?.shapingAverageBandwidth;
resourceInputs["shapingBurstSize"] = state?.shapingBurstSize;
resourceInputs["shapingEnabled"] = state?.shapingEnabled;
resourceInputs["shapingPeakBandwidth"] = state?.shapingPeakBandwidth;
resourceInputs["standbyNics"] = state?.standbyNics;
resourceInputs["teamingPolicy"] = state?.teamingPolicy;
}
else {
const args = argsOrState;
if (args?.activeNics === undefined && !opts.urn) {
throw new Error("Missing required property 'activeNics'");
}
if (args?.hostSystemId === undefined && !opts.urn) {
throw new Error("Missing required property 'hostSystemId'");
}
if (args?.networkAdapters === undefined && !opts.urn) {
throw new Error("Missing required property 'networkAdapters'");
}
resourceInputs["activeNics"] = args?.activeNics;
resourceInputs["allowForgedTransmits"] = args?.allowForgedTransmits;
resourceInputs["allowMacChanges"] = args?.allowMacChanges;
resourceInputs["allowPromiscuous"] = args?.allowPromiscuous;
resourceInputs["beaconInterval"] = args?.beaconInterval;
resourceInputs["checkBeacon"] = args?.checkBeacon;
resourceInputs["failback"] = args?.failback;
resourceInputs["hostSystemId"] = args?.hostSystemId;
resourceInputs["linkDiscoveryOperation"] = args?.linkDiscoveryOperation;
resourceInputs["linkDiscoveryProtocol"] = args?.linkDiscoveryProtocol;
resourceInputs["mtu"] = args?.mtu;
resourceInputs["name"] = args?.name;
resourceInputs["networkAdapters"] = args?.networkAdapters;
resourceInputs["notifySwitches"] = args?.notifySwitches;
resourceInputs["numberOfPorts"] = args?.numberOfPorts;
resourceInputs["shapingAverageBandwidth"] = args?.shapingAverageBandwidth;
resourceInputs["shapingBurstSize"] = args?.shapingBurstSize;
resourceInputs["shapingEnabled"] = args?.shapingEnabled;
resourceInputs["shapingPeakBandwidth"] = args?.shapingPeakBandwidth;
resourceInputs["standbyNics"] = args?.standbyNics;
resourceInputs["teamingPolicy"] = args?.teamingPolicy;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(HostVirtualSwitch.__pulumiType, name, resourceInputs, opts);
}
}
exports.HostVirtualSwitch = HostVirtualSwitch;
/** @internal */
HostVirtualSwitch.__pulumiType = 'vsphere:index/hostVirtualSwitch:HostVirtualSwitch';
//# sourceMappingURL=hostVirtualSwitch.js.map