1. Packages
  2. Openwrt Provider
  3. API Docs
  4. NetworkSwitch
openwrt 0.0.20 published on Friday, Mar 7, 2025 by joneshf

openwrt.NetworkSwitch

Explore with Pulumi AI

Legacy swconfig configuration

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as openwrt from "@pulumi/openwrt";

const testing = new openwrt.NetworkSwitch("testing", {
    enableVlan: true,
    networkSwitchId: "testing",
});
Copy
import pulumi
import pulumi_openwrt as openwrt

testing = openwrt.NetworkSwitch("testing",
    enable_vlan=True,
    network_switch_id="testing")
Copy
package main

import (
	"github.com/pulumi/pulumi-terraform-provider/sdks/go/openwrt/openwrt"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := openwrt.NewNetworkSwitch(ctx, "testing", &openwrt.NetworkSwitchArgs{
			EnableVlan:      pulumi.Bool(true),
			NetworkSwitchId: pulumi.String("testing"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Openwrt = Pulumi.Openwrt;

return await Deployment.RunAsync(() => 
{
    var testing = new Openwrt.NetworkSwitch("testing", new()
    {
        EnableVlan = true,
        NetworkSwitchId = "testing",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.openwrt.NetworkSwitch;
import com.pulumi.openwrt.NetworkSwitchArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var testing = new NetworkSwitch("testing", NetworkSwitchArgs.builder()
            .enableVlan(true)
            .networkSwitchId("testing")
            .build());

    }
}
Copy
resources:
  testing:
    type: openwrt:NetworkSwitch
    properties:
      enableVlan: true
      networkSwitchId: testing
Copy

Create NetworkSwitch Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new NetworkSwitch(name: string, args: NetworkSwitchArgs, opts?: CustomResourceOptions);
@overload
def NetworkSwitch(resource_name: str,
                  args: NetworkSwitchArgs,
                  opts: Optional[ResourceOptions] = None)

@overload
def NetworkSwitch(resource_name: str,
                  opts: Optional[ResourceOptions] = None,
                  network_switch_id: Optional[str] = None,
                  enable_mirror_rx: Optional[bool] = None,
                  enable_mirror_tx: Optional[bool] = None,
                  enable_vlan: Optional[bool] = None,
                  mirror_monitor_port: Optional[float] = None,
                  mirror_source_port: Optional[float] = None,
                  name: Optional[str] = None,
                  reset: Optional[bool] = None)
func NewNetworkSwitch(ctx *Context, name string, args NetworkSwitchArgs, opts ...ResourceOption) (*NetworkSwitch, error)
public NetworkSwitch(string name, NetworkSwitchArgs args, CustomResourceOptions? opts = null)
public NetworkSwitch(String name, NetworkSwitchArgs args)
public NetworkSwitch(String name, NetworkSwitchArgs args, CustomResourceOptions options)
type: openwrt:NetworkSwitch
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. NetworkSwitchArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. NetworkSwitchArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. NetworkSwitchArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. NetworkSwitchArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. NetworkSwitchArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var networkSwitchResource = new Openwrt.NetworkSwitch("networkSwitchResource", new()
{
    NetworkSwitchId = "string",
    EnableMirrorRx = false,
    EnableMirrorTx = false,
    EnableVlan = false,
    MirrorMonitorPort = 0,
    MirrorSourcePort = 0,
    Name = "string",
    Reset = false,
});
Copy
example, err := openwrt.NewNetworkSwitch(ctx, "networkSwitchResource", &openwrt.NetworkSwitchArgs{
	NetworkSwitchId:   pulumi.String("string"),
	EnableMirrorRx:    pulumi.Bool(false),
	EnableMirrorTx:    pulumi.Bool(false),
	EnableVlan:        pulumi.Bool(false),
	MirrorMonitorPort: pulumi.Float64(0),
	MirrorSourcePort:  pulumi.Float64(0),
	Name:              pulumi.String("string"),
	Reset:             pulumi.Bool(false),
})
Copy
var networkSwitchResource = new NetworkSwitch("networkSwitchResource", NetworkSwitchArgs.builder()
    .networkSwitchId("string")
    .enableMirrorRx(false)
    .enableMirrorTx(false)
    .enableVlan(false)
    .mirrorMonitorPort(0)
    .mirrorSourcePort(0)
    .name("string")
    .reset(false)
    .build());
Copy
network_switch_resource = openwrt.NetworkSwitch("networkSwitchResource",
    network_switch_id="string",
    enable_mirror_rx=False,
    enable_mirror_tx=False,
    enable_vlan=False,
    mirror_monitor_port=0,
    mirror_source_port=0,
    name="string",
    reset=False)
Copy
const networkSwitchResource = new openwrt.NetworkSwitch("networkSwitchResource", {
    networkSwitchId: "string",
    enableMirrorRx: false,
    enableMirrorTx: false,
    enableVlan: false,
    mirrorMonitorPort: 0,
    mirrorSourcePort: 0,
    name: "string",
    reset: false,
});
Copy
type: openwrt:NetworkSwitch
properties:
    enableMirrorRx: false
    enableMirrorTx: false
    enableVlan: false
    mirrorMonitorPort: 0
    mirrorSourcePort: 0
    name: string
    networkSwitchId: string
    reset: false
Copy

NetworkSwitch Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The NetworkSwitch resource accepts the following input properties:

NetworkSwitchId This property is required. string
Name of the section. This name is only used when interacting with UCI directly.
EnableMirrorRx bool
Mirror received packets from the mirror_source_port to the mirror_monitor_port.
EnableMirrorTx bool
Mirror transmitted packets from the mirror_source_port to the mirror_monitor_port.
EnableVlan bool
Enables VLAN functionality.
MirrorMonitorPort double
Switch port to which packets are mirrored.
MirrorSourcePort double
Switch port from which packets are mirrored.
Name string
Reset bool
Reset the switch.
NetworkSwitchId This property is required. string
Name of the section. This name is only used when interacting with UCI directly.
EnableMirrorRx bool
Mirror received packets from the mirror_source_port to the mirror_monitor_port.
EnableMirrorTx bool
Mirror transmitted packets from the mirror_source_port to the mirror_monitor_port.
EnableVlan bool
Enables VLAN functionality.
MirrorMonitorPort float64
Switch port to which packets are mirrored.
MirrorSourcePort float64
Switch port from which packets are mirrored.
Name string
Reset bool
Reset the switch.
networkSwitchId This property is required. String
Name of the section. This name is only used when interacting with UCI directly.
enableMirrorRx Boolean
Mirror received packets from the mirror_source_port to the mirror_monitor_port.
enableMirrorTx Boolean
Mirror transmitted packets from the mirror_source_port to the mirror_monitor_port.
enableVlan Boolean
Enables VLAN functionality.
mirrorMonitorPort Double
Switch port to which packets are mirrored.
mirrorSourcePort Double
Switch port from which packets are mirrored.
name String
reset Boolean
Reset the switch.
networkSwitchId This property is required. string
Name of the section. This name is only used when interacting with UCI directly.
enableMirrorRx boolean
Mirror received packets from the mirror_source_port to the mirror_monitor_port.
enableMirrorTx boolean
Mirror transmitted packets from the mirror_source_port to the mirror_monitor_port.
enableVlan boolean
Enables VLAN functionality.
mirrorMonitorPort number
Switch port to which packets are mirrored.
mirrorSourcePort number
Switch port from which packets are mirrored.
name string
reset boolean
Reset the switch.
network_switch_id This property is required. str
Name of the section. This name is only used when interacting with UCI directly.
enable_mirror_rx bool
Mirror received packets from the mirror_source_port to the mirror_monitor_port.
enable_mirror_tx bool
Mirror transmitted packets from the mirror_source_port to the mirror_monitor_port.
enable_vlan bool
Enables VLAN functionality.
mirror_monitor_port float
Switch port to which packets are mirrored.
mirror_source_port float
Switch port from which packets are mirrored.
name str
reset bool
Reset the switch.
networkSwitchId This property is required. String
Name of the section. This name is only used when interacting with UCI directly.
enableMirrorRx Boolean
Mirror received packets from the mirror_source_port to the mirror_monitor_port.
enableMirrorTx Boolean
Mirror transmitted packets from the mirror_source_port to the mirror_monitor_port.
enableVlan Boolean
Enables VLAN functionality.
mirrorMonitorPort Number
Switch port to which packets are mirrored.
mirrorSourcePort Number
Switch port from which packets are mirrored.
name String
reset Boolean
Reset the switch.

Outputs

All input properties are implicitly available as output properties. Additionally, the NetworkSwitch resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing NetworkSwitch Resource

Get an existing NetworkSwitch resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: NetworkSwitchState, opts?: CustomResourceOptions): NetworkSwitch
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        enable_mirror_rx: Optional[bool] = None,
        enable_mirror_tx: Optional[bool] = None,
        enable_vlan: Optional[bool] = None,
        mirror_monitor_port: Optional[float] = None,
        mirror_source_port: Optional[float] = None,
        name: Optional[str] = None,
        network_switch_id: Optional[str] = None,
        reset: Optional[bool] = None) -> NetworkSwitch
func GetNetworkSwitch(ctx *Context, name string, id IDInput, state *NetworkSwitchState, opts ...ResourceOption) (*NetworkSwitch, error)
public static NetworkSwitch Get(string name, Input<string> id, NetworkSwitchState? state, CustomResourceOptions? opts = null)
public static NetworkSwitch get(String name, Output<String> id, NetworkSwitchState state, CustomResourceOptions options)
resources:  _:    type: openwrt:NetworkSwitch    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
EnableMirrorRx bool
Mirror received packets from the mirror_source_port to the mirror_monitor_port.
EnableMirrorTx bool
Mirror transmitted packets from the mirror_source_port to the mirror_monitor_port.
EnableVlan bool
Enables VLAN functionality.
MirrorMonitorPort double
Switch port to which packets are mirrored.
MirrorSourcePort double
Switch port from which packets are mirrored.
Name string
NetworkSwitchId string
Name of the section. This name is only used when interacting with UCI directly.
Reset bool
Reset the switch.
EnableMirrorRx bool
Mirror received packets from the mirror_source_port to the mirror_monitor_port.
EnableMirrorTx bool
Mirror transmitted packets from the mirror_source_port to the mirror_monitor_port.
EnableVlan bool
Enables VLAN functionality.
MirrorMonitorPort float64
Switch port to which packets are mirrored.
MirrorSourcePort float64
Switch port from which packets are mirrored.
Name string
NetworkSwitchId string
Name of the section. This name is only used when interacting with UCI directly.
Reset bool
Reset the switch.
enableMirrorRx Boolean
Mirror received packets from the mirror_source_port to the mirror_monitor_port.
enableMirrorTx Boolean
Mirror transmitted packets from the mirror_source_port to the mirror_monitor_port.
enableVlan Boolean
Enables VLAN functionality.
mirrorMonitorPort Double
Switch port to which packets are mirrored.
mirrorSourcePort Double
Switch port from which packets are mirrored.
name String
networkSwitchId String
Name of the section. This name is only used when interacting with UCI directly.
reset Boolean
Reset the switch.
enableMirrorRx boolean
Mirror received packets from the mirror_source_port to the mirror_monitor_port.
enableMirrorTx boolean
Mirror transmitted packets from the mirror_source_port to the mirror_monitor_port.
enableVlan boolean
Enables VLAN functionality.
mirrorMonitorPort number
Switch port to which packets are mirrored.
mirrorSourcePort number
Switch port from which packets are mirrored.
name string
networkSwitchId string
Name of the section. This name is only used when interacting with UCI directly.
reset boolean
Reset the switch.
enable_mirror_rx bool
Mirror received packets from the mirror_source_port to the mirror_monitor_port.
enable_mirror_tx bool
Mirror transmitted packets from the mirror_source_port to the mirror_monitor_port.
enable_vlan bool
Enables VLAN functionality.
mirror_monitor_port float
Switch port to which packets are mirrored.
mirror_source_port float
Switch port from which packets are mirrored.
name str
network_switch_id str
Name of the section. This name is only used when interacting with UCI directly.
reset bool
Reset the switch.
enableMirrorRx Boolean
Mirror received packets from the mirror_source_port to the mirror_monitor_port.
enableMirrorTx Boolean
Mirror transmitted packets from the mirror_source_port to the mirror_monitor_port.
enableVlan Boolean
Enables VLAN functionality.
mirrorMonitorPort Number
Switch port to which packets are mirrored.
mirrorSourcePort Number
Switch port from which packets are mirrored.
name String
networkSwitchId String
Name of the section. This name is only used when interacting with UCI directly.
reset Boolean
Reset the switch.

Import

The name can be found through LuCI’s web UI.

It will be in quotes on /cgi-bin/luci/admin/network/switch.

The page might say:

Switch "switch0"

The “switch0” is the name.

The name can also be found from LuCI’s JSON-RPC API.

Find the Terraform id and UCI name from LuCI’s JSON-RPC API.

One way to find this information is with curl and jq:

curl \

--data '{"id": 0, "method": "foreach", "params": ["network", "switch"]}' \

http://192.168.1.1/cgi-bin/luci/rpc/uci?auth=$AUTH_TOKEN \

| jq '.result | map({terraformId: .[".name"], uciName: .name})'

This command will output something like:

[

{

"terraformId": "cfg123456",

"uciName": "switch0"

}

]

We’d then use the information to import the appropriate resource:

$ pulumi import openwrt:index/networkSwitch:NetworkSwitch switch0 cfg123456
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
openwrt joneshf/terraform-provider-openwrt
License
Notes
This Pulumi package is based on the openwrt Terraform Provider.