UNPKG

@pulumi/vsphere

Version:

A Pulumi package for creating vsphere resources

293 lines • 16.3 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.DistributedPortGroup = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * The `vsphere.DistributedPortGroup` resource can be used to manage * distributed port groups connected to vSphere Distributed Switches (VDS). * A vSphere Distributed Switch can be managed by the * `vsphere.DistributedVirtualSwitch` resource. * * Distributed port groups can be used as networks for virtual machines, allowing * the virtual machines to use the networking supplied by a vSphere Distributed * Switch, with a set of policies that apply to that individual network, if * desired. * * * For an overview on vSphere networking concepts, refer to the vSphere * [product documentation][ref-vsphere-net-concepts]. * * * For more information on distributed port groups, refer to the vSphere * [product documentation][ref-vsphere-dvportgroup]. * * [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 * [ref-vsphere-dvportgroup]: https://techdocs.broadcom.com/us/en/vmware-cis/vsphere/vsphere/8-0/vsphere-networking-8-0/basic-networking-with-vnetwork-distributed-switches/dvport-groups.html * * > **NOTE:** This resource requires vCenter and is not available on * direct ESXi host connections. * * ## Example Usage * * The configuration below builds on the example given in the * `vsphere.DistributedVirtualSwitch` resource by * adding the `vsphere.DistributedPortGroup` resource, attaching itself to the * vSphere Distributed Switch and assigning VLAN ID 1000. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as vsphere from "@pulumi/vsphere"; * * const config = new pulumi.Config(); * const hosts = config.getObject<any>("hosts") || [ * "esxi-01.example.com", * "esxi-02.example.com", * "esxi-03.example.com", * ]; * const networkInterfaces = config.getObject<any>("networkInterfaces") || [ * "vmnic0", * "vmnic1", * "vmnic2", * "vmnic3", * ]; * const datacenter = vsphere.getDatacenter({ * name: "dc-01", * }); * const host = (new Array(hosts.length)).map((_, i) => i).map(__index => (vsphere.getHost({ * name: hosts[__index], * datacenterId: _arg0_.id, * }))); * const vds = new vsphere.DistributedVirtualSwitch("vds", { * name: "vds-01", * datacenterId: datacenter.then(datacenter => datacenter.id), * uplinks: [ * "uplink1", * "uplink2", * "uplink3", * "uplink4", * ], * activeUplinks: [ * "uplink1", * "uplink2", * ], * standbyUplinks: [ * "uplink3", * "uplink4", * ], * hosts: [ * { * hostSystemId: host[0].then(host => host.id), * devices: [networkInterfaces], * }, * { * hostSystemId: host[1].then(host => host.id), * devices: [networkInterfaces], * }, * { * hostSystemId: host[2].then(host => host.id), * devices: [networkInterfaces], * }, * ], * }); * const pg = new vsphere.DistributedPortGroup("pg", { * name: "pg-01", * distributedVirtualSwitchUuid: vds.id, * vlanId: 1000, * }); * ``` * * ### Overriding VDS policies * * All of the default port policies available in the * `vsphere.DistributedVirtualSwitch` resource can be overridden on the port * group level by specifying new settings for them. * * As an example, we also take this example from the * `vsphere.DistributedVirtualSwitch` resource where we manually specify our * uplink count and uplink order. While the vSphere Distributed Switch has a * default policy of using the first uplink as an active uplink and the second * one as a standby, the overridden port group policy means that both uplinks * will be used as active uplinks in this specific port group. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as vsphere from "@pulumi/vsphere"; * * const vds = new vsphere.DistributedVirtualSwitch("vds", { * name: "vds-01", * datacenterId: datacenter.id, * uplinks: [ * "uplink1", * "uplink2", * ], * activeUplinks: ["uplink1"], * standbyUplinks: ["uplink2"], * }); * const pg = new vsphere.DistributedPortGroup("pg", { * name: "pg-01", * distributedVirtualSwitchUuid: vds.id, * vlanId: 1000, * activeUplinks: [ * "uplink1", * "uplink2", * ], * standbyUplinks: [], * }); * ``` * * ## Import * * An existing port group can be imported into this resource using * * the managed object id of the port group, via the following command: * * [docs-import]: https://developer.hashicorp.com/terraform/cli/import * * ```sh * $ pulumi import vsphere:index/distributedPortGroup:DistributedPortGroup pg /dc-01/network/pg-01 * ``` * * The above would import the port group named `pg-01` that is located in the `dc-01` * * datacenter. */ class DistributedPortGroup extends pulumi.CustomResource { /** * Get an existing DistributedPortGroup 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 DistributedPortGroup(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of DistributedPortGroup. 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'] === DistributedPortGroup.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["activeUplinks"] = state ? state.activeUplinks : undefined; resourceInputs["allowForgedTransmits"] = state ? state.allowForgedTransmits : undefined; resourceInputs["allowMacChanges"] = state ? state.allowMacChanges : undefined; resourceInputs["allowPromiscuous"] = state ? state.allowPromiscuous : undefined; resourceInputs["autoExpand"] = state ? state.autoExpand : undefined; resourceInputs["blockAllPorts"] = state ? state.blockAllPorts : undefined; resourceInputs["blockOverrideAllowed"] = state ? state.blockOverrideAllowed : undefined; resourceInputs["checkBeacon"] = state ? state.checkBeacon : undefined; resourceInputs["configVersion"] = state ? state.configVersion : undefined; resourceInputs["customAttributes"] = state ? state.customAttributes : undefined; resourceInputs["description"] = state ? state.description : undefined; resourceInputs["directpathGen2Allowed"] = state ? state.directpathGen2Allowed : undefined; resourceInputs["distributedVirtualSwitchUuid"] = state ? state.distributedVirtualSwitchUuid : undefined; resourceInputs["egressShapingAverageBandwidth"] = state ? state.egressShapingAverageBandwidth : undefined; resourceInputs["egressShapingBurstSize"] = state ? state.egressShapingBurstSize : undefined; resourceInputs["egressShapingEnabled"] = state ? state.egressShapingEnabled : undefined; resourceInputs["egressShapingPeakBandwidth"] = state ? state.egressShapingPeakBandwidth : undefined; resourceInputs["failback"] = state ? state.failback : undefined; resourceInputs["ingressShapingAverageBandwidth"] = state ? state.ingressShapingAverageBandwidth : undefined; resourceInputs["ingressShapingBurstSize"] = state ? state.ingressShapingBurstSize : undefined; resourceInputs["ingressShapingEnabled"] = state ? state.ingressShapingEnabled : undefined; resourceInputs["ingressShapingPeakBandwidth"] = state ? state.ingressShapingPeakBandwidth : undefined; resourceInputs["key"] = state ? state.key : undefined; resourceInputs["lacpEnabled"] = state ? state.lacpEnabled : undefined; resourceInputs["lacpMode"] = state ? state.lacpMode : undefined; resourceInputs["livePortMovingAllowed"] = state ? state.livePortMovingAllowed : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["netflowEnabled"] = state ? state.netflowEnabled : undefined; resourceInputs["netflowOverrideAllowed"] = state ? state.netflowOverrideAllowed : undefined; resourceInputs["networkResourcePoolKey"] = state ? state.networkResourcePoolKey : undefined; resourceInputs["networkResourcePoolOverrideAllowed"] = state ? state.networkResourcePoolOverrideAllowed : undefined; resourceInputs["notifySwitches"] = state ? state.notifySwitches : undefined; resourceInputs["numberOfPorts"] = state ? state.numberOfPorts : undefined; resourceInputs["portConfigResetAtDisconnect"] = state ? state.portConfigResetAtDisconnect : undefined; resourceInputs["portNameFormat"] = state ? state.portNameFormat : undefined; resourceInputs["portPrivateSecondaryVlanId"] = state ? state.portPrivateSecondaryVlanId : undefined; resourceInputs["securityPolicyOverrideAllowed"] = state ? state.securityPolicyOverrideAllowed : undefined; resourceInputs["shapingOverrideAllowed"] = state ? state.shapingOverrideAllowed : undefined; resourceInputs["standbyUplinks"] = state ? state.standbyUplinks : undefined; resourceInputs["tags"] = state ? state.tags : undefined; resourceInputs["teamingPolicy"] = state ? state.teamingPolicy : undefined; resourceInputs["trafficFilterOverrideAllowed"] = state ? state.trafficFilterOverrideAllowed : undefined; resourceInputs["txUplink"] = state ? state.txUplink : undefined; resourceInputs["type"] = state ? state.type : undefined; resourceInputs["uplinkTeamingOverrideAllowed"] = state ? state.uplinkTeamingOverrideAllowed : undefined; resourceInputs["vlanId"] = state ? state.vlanId : undefined; resourceInputs["vlanOverrideAllowed"] = state ? state.vlanOverrideAllowed : undefined; resourceInputs["vlanRanges"] = state ? state.vlanRanges : undefined; } else { const args = argsOrState; if ((!args || args.distributedVirtualSwitchUuid === undefined) && !opts.urn) { throw new Error("Missing required property 'distributedVirtualSwitchUuid'"); } resourceInputs["activeUplinks"] = args ? args.activeUplinks : undefined; resourceInputs["allowForgedTransmits"] = args ? args.allowForgedTransmits : undefined; resourceInputs["allowMacChanges"] = args ? args.allowMacChanges : undefined; resourceInputs["allowPromiscuous"] = args ? args.allowPromiscuous : undefined; resourceInputs["autoExpand"] = args ? args.autoExpand : undefined; resourceInputs["blockAllPorts"] = args ? args.blockAllPorts : undefined; resourceInputs["blockOverrideAllowed"] = args ? args.blockOverrideAllowed : undefined; resourceInputs["checkBeacon"] = args ? args.checkBeacon : undefined; resourceInputs["customAttributes"] = args ? args.customAttributes : undefined; resourceInputs["description"] = args ? args.description : undefined; resourceInputs["directpathGen2Allowed"] = args ? args.directpathGen2Allowed : undefined; resourceInputs["distributedVirtualSwitchUuid"] = args ? args.distributedVirtualSwitchUuid : undefined; resourceInputs["egressShapingAverageBandwidth"] = args ? args.egressShapingAverageBandwidth : undefined; resourceInputs["egressShapingBurstSize"] = args ? args.egressShapingBurstSize : undefined; resourceInputs["egressShapingEnabled"] = args ? args.egressShapingEnabled : undefined; resourceInputs["egressShapingPeakBandwidth"] = args ? args.egressShapingPeakBandwidth : undefined; resourceInputs["failback"] = args ? args.failback : undefined; resourceInputs["ingressShapingAverageBandwidth"] = args ? args.ingressShapingAverageBandwidth : undefined; resourceInputs["ingressShapingBurstSize"] = args ? args.ingressShapingBurstSize : undefined; resourceInputs["ingressShapingEnabled"] = args ? args.ingressShapingEnabled : undefined; resourceInputs["ingressShapingPeakBandwidth"] = args ? args.ingressShapingPeakBandwidth : undefined; resourceInputs["lacpEnabled"] = args ? args.lacpEnabled : undefined; resourceInputs["lacpMode"] = args ? args.lacpMode : undefined; resourceInputs["livePortMovingAllowed"] = args ? args.livePortMovingAllowed : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["netflowEnabled"] = args ? args.netflowEnabled : undefined; resourceInputs["netflowOverrideAllowed"] = args ? args.netflowOverrideAllowed : undefined; resourceInputs["networkResourcePoolKey"] = args ? args.networkResourcePoolKey : undefined; resourceInputs["networkResourcePoolOverrideAllowed"] = args ? args.networkResourcePoolOverrideAllowed : undefined; resourceInputs["notifySwitches"] = args ? args.notifySwitches : undefined; resourceInputs["numberOfPorts"] = args ? args.numberOfPorts : undefined; resourceInputs["portConfigResetAtDisconnect"] = args ? args.portConfigResetAtDisconnect : undefined; resourceInputs["portNameFormat"] = args ? args.portNameFormat : undefined; resourceInputs["portPrivateSecondaryVlanId"] = args ? args.portPrivateSecondaryVlanId : undefined; resourceInputs["securityPolicyOverrideAllowed"] = args ? args.securityPolicyOverrideAllowed : undefined; resourceInputs["shapingOverrideAllowed"] = args ? args.shapingOverrideAllowed : undefined; resourceInputs["standbyUplinks"] = args ? args.standbyUplinks : undefined; resourceInputs["tags"] = args ? args.tags : undefined; resourceInputs["teamingPolicy"] = args ? args.teamingPolicy : undefined; resourceInputs["trafficFilterOverrideAllowed"] = args ? args.trafficFilterOverrideAllowed : undefined; resourceInputs["txUplink"] = args ? args.txUplink : undefined; resourceInputs["type"] = args ? args.type : undefined; resourceInputs["uplinkTeamingOverrideAllowed"] = args ? args.uplinkTeamingOverrideAllowed : undefined; resourceInputs["vlanId"] = args ? args.vlanId : undefined; resourceInputs["vlanOverrideAllowed"] = args ? args.vlanOverrideAllowed : undefined; resourceInputs["vlanRanges"] = args ? args.vlanRanges : undefined; resourceInputs["configVersion"] = undefined /*out*/; resourceInputs["key"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(DistributedPortGroup.__pulumiType, name, resourceInputs, opts); } } exports.DistributedPortGroup = DistributedPortGroup; /** @internal */ DistributedPortGroup.__pulumiType = 'vsphere:index/distributedPortGroup:DistributedPortGroup'; //# sourceMappingURL=distributedPortGroup.js.map