vSphere

v4.3.0 published on Monday, Jun 27, 2022 by Pulumi

getDistributedVirtualSwitch

The vsphere.DistributedVirtualSwitch data source can be used to discover the ID and uplink data of a of a vSphere distributed switch (VDS). This can then be used with resources or data sources that require a VDS, such as the vsphere.DistributedPortGroup resource, for which an example is shown below.

NOTE: This data source requires vCenter Server and is not available on direct ESXi host connections.

Example Usage

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
    public MyStack()
    {
        var datacenter = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
        {
            Name = "dc-01",
        }));
        var vds = datacenter.Apply(datacenter => Output.Create(VSphere.GetDistributedVirtualSwitch.InvokeAsync(new VSphere.GetDistributedVirtualSwitchArgs
        {
            Name = "vds-01",
            DatacenterId = datacenter.Id,
        })));
        var dvpg = new VSphere.DistributedPortGroup("dvpg", new VSphere.DistributedPortGroupArgs
        {
            DistributedVirtualSwitchUuid = vds.Apply(vds => vds.Id),
            ActiveUplinks = 
            {
                vds.Apply(vds => vds.Uplinks?[0]),
            },
            StandbyUplinks = 
            {
                vds.Apply(vds => vds.Uplinks?[1]),
            },
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-vsphere/sdk/v4/go/vsphere"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		datacenter, err := vsphere.LookupDatacenter(ctx, &GetDatacenterArgs{
			Name: pulumi.StringRef("dc-01"),
		}, nil)
		if err != nil {
			return err
		}
		vds, err := vsphere.LookupDistributedVirtualSwitch(ctx, &GetDistributedVirtualSwitchArgs{
			Name:         "vds-01",
			DatacenterId: pulumi.StringRef(datacenter.Id),
		}, nil)
		if err != nil {
			return err
		}
		_, err = vsphere.NewDistributedPortGroup(ctx, "dvpg", &vsphere.DistributedPortGroupArgs{
			DistributedVirtualSwitchUuid: pulumi.String(vds.Id),
			ActiveUplinks: pulumi.StringArray{
				pulumi.String(vds.Uplinks[0]),
			},
			StandbyUplinks: pulumi.StringArray{
				pulumi.String(vds.Uplinks[1]),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}

Coming soon!

import pulumi
import pulumi_vsphere as vsphere

datacenter = vsphere.get_datacenter(name="dc-01")
vds = vsphere.get_distributed_virtual_switch(name="vds-01",
    datacenter_id=datacenter.id)
dvpg = vsphere.DistributedPortGroup("dvpg",
    distributed_virtual_switch_uuid=vds.id,
    active_uplinks=[vds.uplinks[0]],
    standby_uplinks=[vds.uplinks[1]])
import * as pulumi from "@pulumi/pulumi";
import * as vsphere from "@pulumi/vsphere";

const datacenter = vsphere.getDatacenter({
    name: "dc-01",
});
const vds = datacenter.then(datacenter => vsphere.getDistributedVirtualSwitch({
    name: "vds-01",
    datacenterId: datacenter.id,
}));
const dvpg = new vsphere.DistributedPortGroup("dvpg", {
    distributedVirtualSwitchUuid: vds.then(vds => vds.id),
    activeUplinks: [vds.then(vds => vds.uplinks?[0])],
    standbyUplinks: [vds.then(vds => vds.uplinks?[1])],
});

Coming soon!

Using getDistributedVirtualSwitch

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getDistributedVirtualSwitch(args: GetDistributedVirtualSwitchArgs, opts?: InvokeOptions): Promise<GetDistributedVirtualSwitchResult>
function getDistributedVirtualSwitchOutput(args: GetDistributedVirtualSwitchOutputArgs, opts?: InvokeOptions): Output<GetDistributedVirtualSwitchResult>
def get_distributed_virtual_switch(datacenter_id: Optional[str] = None,
                                   name: Optional[str] = None,
                                   opts: Optional[InvokeOptions] = None) -> GetDistributedVirtualSwitchResult
def get_distributed_virtual_switch_output(datacenter_id: Optional[pulumi.Input[str]] = None,
                                   name: Optional[pulumi.Input[str]] = None,
                                   opts: Optional[InvokeOptions] = None) -> Output[GetDistributedVirtualSwitchResult]
func LookupDistributedVirtualSwitch(ctx *Context, args *LookupDistributedVirtualSwitchArgs, opts ...InvokeOption) (*LookupDistributedVirtualSwitchResult, error)
func LookupDistributedVirtualSwitchOutput(ctx *Context, args *LookupDistributedVirtualSwitchOutputArgs, opts ...InvokeOption) LookupDistributedVirtualSwitchResultOutput

> Note: This function is named LookupDistributedVirtualSwitch in the Go SDK.

public static class GetDistributedVirtualSwitch 
{
    public static Task<GetDistributedVirtualSwitchResult> InvokeAsync(GetDistributedVirtualSwitchArgs args, InvokeOptions? opts = null)
    public static Output<GetDistributedVirtualSwitchResult> Invoke(GetDistributedVirtualSwitchInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetDistributedVirtualSwitchResult> getDistributedVirtualSwitch(GetDistributedVirtualSwitchArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
Fn::Invoke:
  Function: vsphere:index/getDistributedVirtualSwitch:getDistributedVirtualSwitch
  Arguments:
    # Arguments dictionary

The following arguments are supported:

Name string

The name of the VDS. This can be a name or path.

DatacenterId string

The managed object reference ID of the datacenter the VDS is located in. This can be omitted if the search path used in name is an absolute path. For default datacenters, use the id attribute from an empty vsphere.Datacenter data source.

Name string

The name of the VDS. This can be a name or path.

DatacenterId string

The managed object reference ID of the datacenter the VDS is located in. This can be omitted if the search path used in name is an absolute path. For default datacenters, use the id attribute from an empty vsphere.Datacenter data source.

name String

The name of the VDS. This can be a name or path.

datacenterId String

The managed object reference ID of the datacenter the VDS is located in. This can be omitted if the search path used in name is an absolute path. For default datacenters, use the id attribute from an empty vsphere.Datacenter data source.

name string

The name of the VDS. This can be a name or path.

datacenterId string

The managed object reference ID of the datacenter the VDS is located in. This can be omitted if the search path used in name is an absolute path. For default datacenters, use the id attribute from an empty vsphere.Datacenter data source.

name str

The name of the VDS. This can be a name or path.

datacenter_id str

The managed object reference ID of the datacenter the VDS is located in. This can be omitted if the search path used in name is an absolute path. For default datacenters, use the id attribute from an empty vsphere.Datacenter data source.

name String

The name of the VDS. This can be a name or path.

datacenterId String

The managed object reference ID of the datacenter the VDS is located in. This can be omitted if the search path used in name is an absolute path. For default datacenters, use the id attribute from an empty vsphere.Datacenter data source.

getDistributedVirtualSwitch Result

The following output properties are available:

Id string

The provider-assigned unique ID for this managed resource.

Name string
Uplinks List<string>
DatacenterId string
Id string

The provider-assigned unique ID for this managed resource.

Name string
Uplinks []string
DatacenterId string
id String

The provider-assigned unique ID for this managed resource.

name String
uplinks List<String>
datacenterId String
id string

The provider-assigned unique ID for this managed resource.

name string
uplinks string[]
datacenterId string
id str

The provider-assigned unique ID for this managed resource.

name str
uplinks Sequence[str]
datacenter_id str
id String

The provider-assigned unique ID for this managed resource.

name String
uplinks List<String>
datacenterId String

Package Details

Repository
https://github.com/pulumi/pulumi-vsphere
License
Apache-2.0
Notes

This Pulumi package is based on the vsphere Terraform Provider.