@pulumi/vsphere
Version:
A Pulumi package for creating vsphere resources
293 lines • 14.5 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.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, { ...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?.activeUplinks;
resourceInputs["allowForgedTransmits"] = state?.allowForgedTransmits;
resourceInputs["allowMacChanges"] = state?.allowMacChanges;
resourceInputs["allowPromiscuous"] = state?.allowPromiscuous;
resourceInputs["autoExpand"] = state?.autoExpand;
resourceInputs["blockAllPorts"] = state?.blockAllPorts;
resourceInputs["blockOverrideAllowed"] = state?.blockOverrideAllowed;
resourceInputs["checkBeacon"] = state?.checkBeacon;
resourceInputs["configVersion"] = state?.configVersion;
resourceInputs["customAttributes"] = state?.customAttributes;
resourceInputs["description"] = state?.description;
resourceInputs["directpathGen2Allowed"] = state?.directpathGen2Allowed;
resourceInputs["distributedVirtualSwitchUuid"] = state?.distributedVirtualSwitchUuid;
resourceInputs["egressShapingAverageBandwidth"] = state?.egressShapingAverageBandwidth;
resourceInputs["egressShapingBurstSize"] = state?.egressShapingBurstSize;
resourceInputs["egressShapingEnabled"] = state?.egressShapingEnabled;
resourceInputs["egressShapingPeakBandwidth"] = state?.egressShapingPeakBandwidth;
resourceInputs["failback"] = state?.failback;
resourceInputs["ingressShapingAverageBandwidth"] = state?.ingressShapingAverageBandwidth;
resourceInputs["ingressShapingBurstSize"] = state?.ingressShapingBurstSize;
resourceInputs["ingressShapingEnabled"] = state?.ingressShapingEnabled;
resourceInputs["ingressShapingPeakBandwidth"] = state?.ingressShapingPeakBandwidth;
resourceInputs["key"] = state?.key;
resourceInputs["lacpEnabled"] = state?.lacpEnabled;
resourceInputs["lacpMode"] = state?.lacpMode;
resourceInputs["livePortMovingAllowed"] = state?.livePortMovingAllowed;
resourceInputs["name"] = state?.name;
resourceInputs["netflowEnabled"] = state?.netflowEnabled;
resourceInputs["netflowOverrideAllowed"] = state?.netflowOverrideAllowed;
resourceInputs["networkResourcePoolKey"] = state?.networkResourcePoolKey;
resourceInputs["networkResourcePoolOverrideAllowed"] = state?.networkResourcePoolOverrideAllowed;
resourceInputs["notifySwitches"] = state?.notifySwitches;
resourceInputs["numberOfPorts"] = state?.numberOfPorts;
resourceInputs["portConfigResetAtDisconnect"] = state?.portConfigResetAtDisconnect;
resourceInputs["portNameFormat"] = state?.portNameFormat;
resourceInputs["portPrivateSecondaryVlanId"] = state?.portPrivateSecondaryVlanId;
resourceInputs["securityPolicyOverrideAllowed"] = state?.securityPolicyOverrideAllowed;
resourceInputs["shapingOverrideAllowed"] = state?.shapingOverrideAllowed;
resourceInputs["standbyUplinks"] = state?.standbyUplinks;
resourceInputs["tags"] = state?.tags;
resourceInputs["teamingPolicy"] = state?.teamingPolicy;
resourceInputs["trafficFilterOverrideAllowed"] = state?.trafficFilterOverrideAllowed;
resourceInputs["txUplink"] = state?.txUplink;
resourceInputs["type"] = state?.type;
resourceInputs["uplinkTeamingOverrideAllowed"] = state?.uplinkTeamingOverrideAllowed;
resourceInputs["vlanId"] = state?.vlanId;
resourceInputs["vlanOverrideAllowed"] = state?.vlanOverrideAllowed;
resourceInputs["vlanRanges"] = state?.vlanRanges;
}
else {
const args = argsOrState;
if (args?.distributedVirtualSwitchUuid === undefined && !opts.urn) {
throw new Error("Missing required property 'distributedVirtualSwitchUuid'");
}
resourceInputs["activeUplinks"] = args?.activeUplinks;
resourceInputs["allowForgedTransmits"] = args?.allowForgedTransmits;
resourceInputs["allowMacChanges"] = args?.allowMacChanges;
resourceInputs["allowPromiscuous"] = args?.allowPromiscuous;
resourceInputs["autoExpand"] = args?.autoExpand;
resourceInputs["blockAllPorts"] = args?.blockAllPorts;
resourceInputs["blockOverrideAllowed"] = args?.blockOverrideAllowed;
resourceInputs["checkBeacon"] = args?.checkBeacon;
resourceInputs["customAttributes"] = args?.customAttributes;
resourceInputs["description"] = args?.description;
resourceInputs["directpathGen2Allowed"] = args?.directpathGen2Allowed;
resourceInputs["distributedVirtualSwitchUuid"] = args?.distributedVirtualSwitchUuid;
resourceInputs["egressShapingAverageBandwidth"] = args?.egressShapingAverageBandwidth;
resourceInputs["egressShapingBurstSize"] = args?.egressShapingBurstSize;
resourceInputs["egressShapingEnabled"] = args?.egressShapingEnabled;
resourceInputs["egressShapingPeakBandwidth"] = args?.egressShapingPeakBandwidth;
resourceInputs["failback"] = args?.failback;
resourceInputs["ingressShapingAverageBandwidth"] = args?.ingressShapingAverageBandwidth;
resourceInputs["ingressShapingBurstSize"] = args?.ingressShapingBurstSize;
resourceInputs["ingressShapingEnabled"] = args?.ingressShapingEnabled;
resourceInputs["ingressShapingPeakBandwidth"] = args?.ingressShapingPeakBandwidth;
resourceInputs["lacpEnabled"] = args?.lacpEnabled;
resourceInputs["lacpMode"] = args?.lacpMode;
resourceInputs["livePortMovingAllowed"] = args?.livePortMovingAllowed;
resourceInputs["name"] = args?.name;
resourceInputs["netflowEnabled"] = args?.netflowEnabled;
resourceInputs["netflowOverrideAllowed"] = args?.netflowOverrideAllowed;
resourceInputs["networkResourcePoolKey"] = args?.networkResourcePoolKey;
resourceInputs["networkResourcePoolOverrideAllowed"] = args?.networkResourcePoolOverrideAllowed;
resourceInputs["notifySwitches"] = args?.notifySwitches;
resourceInputs["numberOfPorts"] = args?.numberOfPorts;
resourceInputs["portConfigResetAtDisconnect"] = args?.portConfigResetAtDisconnect;
resourceInputs["portNameFormat"] = args?.portNameFormat;
resourceInputs["portPrivateSecondaryVlanId"] = args?.portPrivateSecondaryVlanId;
resourceInputs["securityPolicyOverrideAllowed"] = args?.securityPolicyOverrideAllowed;
resourceInputs["shapingOverrideAllowed"] = args?.shapingOverrideAllowed;
resourceInputs["standbyUplinks"] = args?.standbyUplinks;
resourceInputs["tags"] = args?.tags;
resourceInputs["teamingPolicy"] = args?.teamingPolicy;
resourceInputs["trafficFilterOverrideAllowed"] = args?.trafficFilterOverrideAllowed;
resourceInputs["txUplink"] = args?.txUplink;
resourceInputs["type"] = args?.type;
resourceInputs["uplinkTeamingOverrideAllowed"] = args?.uplinkTeamingOverrideAllowed;
resourceInputs["vlanId"] = args?.vlanId;
resourceInputs["vlanOverrideAllowed"] = args?.vlanOverrideAllowed;
resourceInputs["vlanRanges"] = args?.vlanRanges;
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