vSphere
getNetwork
The vsphere.getNetwork
data source can be used to discover the ID of a network
in vSphere. This can be any network that can be used as the backing for a
network interface for vsphere.VirtualMachine
or any other vSphere resource
that requires a network. This includes standard (host-based) port groups, DVS
port groups, or opaque networks such as those managed by NSX.
Example Usage
using Pulumi;
using VSphere = Pulumi.VSphere;
class MyStack : Stack
{
public MyStack()
{
var datacenter = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
{
Name = "dc1",
}));
var net = datacenter.Apply(datacenter => Output.Create(VSphere.GetNetwork.InvokeAsync(new VSphere.GetNetworkArgs
{
DatacenterId = datacenter.Id,
Name = "test-net",
})));
}
}
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 {
opt0 := "dc1"
datacenter, err := vsphere.LookupDatacenter(ctx, &GetDatacenterArgs{
Name: &opt0,
}, nil)
if err != nil {
return err
}
opt1 := datacenter.Id
_, err = vsphere.GetNetwork(ctx, &GetNetworkArgs{
DatacenterId: &opt1,
Name: "test-net",
}, nil)
if err != nil {
return err
}
return nil
})
}
Coming soon!
import pulumi
import pulumi_vsphere as vsphere
datacenter = vsphere.get_datacenter(name="dc1")
net = vsphere.get_network(datacenter_id=datacenter.id,
name="test-net")
import * as pulumi from "@pulumi/pulumi";
import * as vsphere from "@pulumi/vsphere";
const datacenter = pulumi.output(vsphere.getDatacenter({
name: "dc1",
}));
const net = datacenter.apply(datacenter => vsphere.getNetwork({
datacenterId: datacenter.id,
name: "test-net",
}));
Coming soon!
Using getNetwork
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 getNetwork(args: GetNetworkArgs, opts?: InvokeOptions): Promise<GetNetworkResult>
function getNetworkOutput(args: GetNetworkOutputArgs, opts?: InvokeOptions): Output<GetNetworkResult>
def get_network(datacenter_id: Optional[str] = None,
distributed_virtual_switch_uuid: Optional[str] = None,
name: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetNetworkResult
def get_network_output(datacenter_id: Optional[pulumi.Input[str]] = None,
distributed_virtual_switch_uuid: Optional[pulumi.Input[str]] = None,
name: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetNetworkResult]
func GetNetwork(ctx *Context, args *GetNetworkArgs, opts ...InvokeOption) (*GetNetworkResult, error)
func GetNetworkOutput(ctx *Context, args *GetNetworkOutputArgs, opts ...InvokeOption) GetNetworkResultOutput
> Note: This function is named GetNetwork
in the Go SDK.
public static class GetNetwork
{
public static Task<GetNetworkResult> InvokeAsync(GetNetworkArgs args, InvokeOptions? opts = null)
public static Output<GetNetworkResult> Invoke(GetNetworkInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetNetworkResult> getNetwork(GetNetworkArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
Fn::Invoke:
Function: vsphere:index/getNetwork:getNetwork
Arguments:
# Arguments dictionary
The following arguments are supported:
- Name string
The name of the network. This can be a name or path.
- Datacenter
Id string The managed object reference ID of the datacenter the network 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 emptyvsphere.Datacenter
data source.- Distributed
Virtual stringSwitch Uuid For distributed port group type network objects, the ID of the distributed virtual switch the given port group belongs to. It is useful to differentiate port groups with same name using the Distributed virtual switch ID.
- Name string
The name of the network. This can be a name or path.
- Datacenter
Id string The managed object reference ID of the datacenter the network 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 emptyvsphere.Datacenter
data source.- Distributed
Virtual stringSwitch Uuid For distributed port group type network objects, the ID of the distributed virtual switch the given port group belongs to. It is useful to differentiate port groups with same name using the Distributed virtual switch ID.
- name String
The name of the network. This can be a name or path.
- datacenter
Id String The managed object reference ID of the datacenter the network 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 emptyvsphere.Datacenter
data source.- distributed
Virtual StringSwitch Uuid For distributed port group type network objects, the ID of the distributed virtual switch the given port group belongs to. It is useful to differentiate port groups with same name using the Distributed virtual switch ID.
- name string
The name of the network. This can be a name or path.
- datacenter
Id string The managed object reference ID of the datacenter the network 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 emptyvsphere.Datacenter
data source.- distributed
Virtual stringSwitch Uuid For distributed port group type network objects, the ID of the distributed virtual switch the given port group belongs to. It is useful to differentiate port groups with same name using the Distributed virtual switch ID.
- name str
The name of the network. This can be a name or path.
- datacenter_
id str The managed object reference ID of the datacenter the network 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 emptyvsphere.Datacenter
data source.- distributed_
virtual_ strswitch_ uuid For distributed port group type network objects, the ID of the distributed virtual switch the given port group belongs to. It is useful to differentiate port groups with same name using the Distributed virtual switch ID.
- name String
The name of the network. This can be a name or path.
- datacenter
Id String The managed object reference ID of the datacenter the network 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 emptyvsphere.Datacenter
data source.- distributed
Virtual StringSwitch Uuid For distributed port group type network objects, the ID of the distributed virtual switch the given port group belongs to. It is useful to differentiate port groups with same name using the Distributed virtual switch ID.
getNetwork Result
The following output properties are available:
- Id string
The provider-assigned unique ID for this managed resource.
- Name string
- Type string
- Datacenter
Id string - Distributed
Virtual stringSwitch Uuid
- Id string
The provider-assigned unique ID for this managed resource.
- Name string
- Type string
- Datacenter
Id string - Distributed
Virtual stringSwitch Uuid
- id String
The provider-assigned unique ID for this managed resource.
- name String
- type String
- datacenter
Id String - distributed
Virtual StringSwitch Uuid
- id string
The provider-assigned unique ID for this managed resource.
- name string
- type string
- datacenter
Id string - distributed
Virtual stringSwitch Uuid
- id str
The provider-assigned unique ID for this managed resource.
- name str
- type str
- datacenter_
id str - distributed_
virtual_ strswitch_ uuid
- id String
The provider-assigned unique ID for this managed resource.
- name String
- type String
- datacenter
Id String - distributed
Virtual StringSwitch Uuid
Package Details
- Repository
- https://github.com/pulumi/pulumi-vsphere
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
vsphere
Terraform Provider.