@pulumi/vsphere
Version:
A Pulumi package for creating vsphere resources
185 lines • 8.65 kB
JavaScript
;
// *** 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.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, Object.assign(Object.assign({}, 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 ? state.activeNics : undefined;
resourceInputs["allowForgedTransmits"] = state ? state.allowForgedTransmits : undefined;
resourceInputs["allowMacChanges"] = state ? state.allowMacChanges : undefined;
resourceInputs["allowPromiscuous"] = state ? state.allowPromiscuous : undefined;
resourceInputs["checkBeacon"] = state ? state.checkBeacon : undefined;
resourceInputs["computedPolicy"] = state ? state.computedPolicy : undefined;
resourceInputs["failback"] = state ? state.failback : undefined;
resourceInputs["hostSystemId"] = state ? state.hostSystemId : undefined;
resourceInputs["key"] = state ? state.key : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["notifySwitches"] = state ? state.notifySwitches : undefined;
resourceInputs["ports"] = state ? state.ports : 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;
resourceInputs["virtualSwitchName"] = state ? state.virtualSwitchName : undefined;
resourceInputs["vlanId"] = state ? state.vlanId : undefined;
}
else {
const args = argsOrState;
if ((!args || args.hostSystemId === undefined) && !opts.urn) {
throw new Error("Missing required property 'hostSystemId'");
}
if ((!args || args.virtualSwitchName === undefined) && !opts.urn) {
throw new Error("Missing required property 'virtualSwitchName'");
}
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["checkBeacon"] = args ? args.checkBeacon : undefined;
resourceInputs["failback"] = args ? args.failback : undefined;
resourceInputs["hostSystemId"] = args ? args.hostSystemId : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["notifySwitches"] = args ? args.notifySwitches : 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;
resourceInputs["virtualSwitchName"] = args ? args.virtualSwitchName : undefined;
resourceInputs["vlanId"] = args ? args.vlanId : undefined;
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