@pulumi/vsphere
Version:
A Pulumi package for creating vsphere resources
185 lines • 7.89 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.HostPortGroup = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* The `vsphere.HostPortGroup` resource can be used to manage port groups on
* ESXi hosts. These port groups are connected to standard switches, which
* can be managed by the `vsphere.HostVirtualSwitch`
* resource.
*
* For an overview on vSphere networking concepts, see [the product documentation][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 and Bind a Port Group:**
*
* ```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 hostVirtualSwitch = new vsphere.HostVirtualSwitch("host_virtual_switch", {
* name: "switch-01",
* hostSystemId: host.then(host => host.id),
* networkAdapters: [
* "vmnic0",
* "vmnic1",
* ],
* activeNics: ["vmnic0"],
* standbyNics: ["vmnic1"],
* });
* const pg = new vsphere.HostPortGroup("pg", {
* name: "portgroup-01",
* hostSystemId: host.then(host => host.id),
* virtualSwitchName: hostVirtualSwitch.name,
* });
* ```
*
* **Create a Port Group with a VLAN and ab Override:**
*
* This example sets the trunk mode VLAN (`4095`, which passes through all tags)
* and sets
* `allowPromiscuous`
* to ensure that all traffic is seen on the port. The setting overrides
* the implicit default of `false` set on the standard switch.
*
* ```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 hostVirtualSwitch = new vsphere.HostVirtualSwitch("host_virtual_switch", {
* name: "switch-01",
* hostSystemId: host.then(host => host.id),
* networkAdapters: [
* "vmnic0",
* "vmnic1",
* ],
* activeNics: ["vmnic0"],
* standbyNics: ["vmnic1"],
* });
* const pg = new vsphere.HostPortGroup("pg", {
* name: "portgroup-01",
* hostSystemId: host.then(host => host.id),
* virtualSwitchName: hostVirtualSwitch.name,
* vlanId: 4095,
* allowPromiscuous: true,
* });
* ```
*
* ## Import
*
* An existing host port group can be imported into this resource
*
* using the host port group's ID. An example is below:
*
* ```sh
* $ pulumi import vsphere:index/hostPortGroup:HostPortGroup management tf-HostPortGroup:host-123:management
* ```
*
* The above would import the `management` host port group from host with ID `host-123`.
*/
class HostPortGroup extends pulumi.CustomResource {
/**
* Get an existing HostPortGroup 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 HostPortGroup(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of HostPortGroup. 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'] === HostPortGroup.__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["checkBeacon"] = state?.checkBeacon;
resourceInputs["computedPolicy"] = state?.computedPolicy;
resourceInputs["failback"] = state?.failback;
resourceInputs["hostSystemId"] = state?.hostSystemId;
resourceInputs["key"] = state?.key;
resourceInputs["name"] = state?.name;
resourceInputs["notifySwitches"] = state?.notifySwitches;
resourceInputs["ports"] = state?.ports;
resourceInputs["shapingAverageBandwidth"] = state?.shapingAverageBandwidth;
resourceInputs["shapingBurstSize"] = state?.shapingBurstSize;
resourceInputs["shapingEnabled"] = state?.shapingEnabled;
resourceInputs["shapingPeakBandwidth"] = state?.shapingPeakBandwidth;
resourceInputs["standbyNics"] = state?.standbyNics;
resourceInputs["teamingPolicy"] = state?.teamingPolicy;
resourceInputs["virtualSwitchName"] = state?.virtualSwitchName;
resourceInputs["vlanId"] = state?.vlanId;
}
else {
const args = argsOrState;
if (args?.hostSystemId === undefined && !opts.urn) {
throw new Error("Missing required property 'hostSystemId'");
}
if (args?.virtualSwitchName === undefined && !opts.urn) {
throw new Error("Missing required property 'virtualSwitchName'");
}
resourceInputs["activeNics"] = args?.activeNics;
resourceInputs["allowForgedTransmits"] = args?.allowForgedTransmits;
resourceInputs["allowMacChanges"] = args?.allowMacChanges;
resourceInputs["allowPromiscuous"] = args?.allowPromiscuous;
resourceInputs["checkBeacon"] = args?.checkBeacon;
resourceInputs["failback"] = args?.failback;
resourceInputs["hostSystemId"] = args?.hostSystemId;
resourceInputs["name"] = args?.name;
resourceInputs["notifySwitches"] = args?.notifySwitches;
resourceInputs["shapingAverageBandwidth"] = args?.shapingAverageBandwidth;
resourceInputs["shapingBurstSize"] = args?.shapingBurstSize;
resourceInputs["shapingEnabled"] = args?.shapingEnabled;
resourceInputs["shapingPeakBandwidth"] = args?.shapingPeakBandwidth;
resourceInputs["standbyNics"] = args?.standbyNics;
resourceInputs["teamingPolicy"] = args?.teamingPolicy;
resourceInputs["virtualSwitchName"] = args?.virtualSwitchName;
resourceInputs["vlanId"] = args?.vlanId;
resourceInputs["computedPolicy"] = undefined /*out*/;
resourceInputs["key"] = undefined /*out*/;
resourceInputs["ports"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(HostPortGroup.__pulumiType, name, resourceInputs, opts);
}
}
exports.HostPortGroup = HostPortGroup;
/** @internal */
HostPortGroup.__pulumiType = 'vsphere:index/hostPortGroup:HostPortGroup';
//# sourceMappingURL=hostPortGroup.js.map