UNPKG

@pulumi/vsphere

Version:

A Pulumi package for creating vsphere resources

191 lines • 9.26 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.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, Object.assign(Object.assign({}, 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 ? state.activeNics : undefined; resourceInputs["allowForgedTransmits"] = state ? state.allowForgedTransmits : undefined; resourceInputs["allowMacChanges"] = state ? state.allowMacChanges : undefined; resourceInputs["allowPromiscuous"] = state ? state.allowPromiscuous : undefined; resourceInputs["beaconInterval"] = state ? state.beaconInterval : undefined; resourceInputs["checkBeacon"] = state ? state.checkBeacon : undefined; resourceInputs["failback"] = state ? state.failback : undefined; resourceInputs["hostSystemId"] = state ? state.hostSystemId : undefined; resourceInputs["linkDiscoveryOperation"] = state ? state.linkDiscoveryOperation : undefined; resourceInputs["linkDiscoveryProtocol"] = state ? state.linkDiscoveryProtocol : undefined; resourceInputs["mtu"] = state ? state.mtu : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["networkAdapters"] = state ? state.networkAdapters : undefined; resourceInputs["notifySwitches"] = state ? state.notifySwitches : undefined; resourceInputs["numberOfPorts"] = state ? state.numberOfPorts : undefined; resourceInputs["shapingAverageBandwidth"] = state ? state.shapingAverageBandwidth : undefined; resourceInputs["shapingBurstSize"] = state ? state.shapingBurstSize : undefined; resourceInputs["shapingEnabled"] = state ? state.shapingEnabled : undefined; resourceInputs["shapingPeakBandwidth"] = state ? state.shapingPeakBandwidth : undefined; resourceInputs["standbyNics"] = state ? state.standbyNics : undefined; resourceInputs["teamingPolicy"] = state ? state.teamingPolicy : undefined; } else { const args = argsOrState; if ((!args || args.activeNics === undefined) && !opts.urn) { throw new Error("Missing required property 'activeNics'"); } if ((!args || args.hostSystemId === undefined) && !opts.urn) { throw new Error("Missing required property 'hostSystemId'"); } if ((!args || args.networkAdapters === undefined) && !opts.urn) { throw new Error("Missing required property 'networkAdapters'"); } resourceInputs["activeNics"] = args ? args.activeNics : undefined; resourceInputs["allowForgedTransmits"] = args ? args.allowForgedTransmits : undefined; resourceInputs["allowMacChanges"] = args ? args.allowMacChanges : undefined; resourceInputs["allowPromiscuous"] = args ? args.allowPromiscuous : undefined; resourceInputs["beaconInterval"] = args ? args.beaconInterval : undefined; resourceInputs["checkBeacon"] = args ? args.checkBeacon : undefined; resourceInputs["failback"] = args ? args.failback : undefined; resourceInputs["hostSystemId"] = args ? args.hostSystemId : undefined; resourceInputs["linkDiscoveryOperation"] = args ? args.linkDiscoveryOperation : undefined; resourceInputs["linkDiscoveryProtocol"] = args ? args.linkDiscoveryProtocol : undefined; resourceInputs["mtu"] = args ? args.mtu : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["networkAdapters"] = args ? args.networkAdapters : undefined; resourceInputs["notifySwitches"] = args ? args.notifySwitches : undefined; resourceInputs["numberOfPorts"] = args ? args.numberOfPorts : undefined; resourceInputs["shapingAverageBandwidth"] = args ? args.shapingAverageBandwidth : undefined; resourceInputs["shapingBurstSize"] = args ? args.shapingBurstSize : undefined; resourceInputs["shapingEnabled"] = args ? args.shapingEnabled : undefined; resourceInputs["shapingPeakBandwidth"] = args ? args.shapingPeakBandwidth : undefined; resourceInputs["standbyNics"] = args ? args.standbyNics : undefined; resourceInputs["teamingPolicy"] = args ? args.teamingPolicy : undefined; } 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