Skip to content

Commit

Permalink
feat: Add WiFi datapath resource
Browse files Browse the repository at this point in the history
  • Loading branch information
dokmic authored and vaerh committed Jan 15, 2024
1 parent edd8299 commit 4193151
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/resources/routeros_wifi_datapath/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#The ID can be found via API or the terminal
#The command for the terminal is -> :put [/interface/wifi/datapath get [print show-ids]]
terraform import routeros_wifi_datapath.datapath1 '*1'
5 changes: 5 additions & 0 deletions examples/resources/routeros_wifi_datapath/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "routeros_wifi_datapath" "datapath1" {
name = "datapath1"
bridge = "bridge1"
client_isolation = false
}
1 change: 1 addition & 0 deletions routeros/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ func Provider() *schema.Provider {
// WiFi
"routeros_wifi_aaa": ResourceWifiAaa(),
"routeros_wifi_channel": ResourceWifiChannel(),
"routeros_wifi_datapath": ResourceWifiDatapath(),
"routeros_wifi_security": ResourceWifiSecurity(),
},
DataSourcesMap: map[string]*schema.Resource{
Expand Down
75 changes: 75 additions & 0 deletions routeros/resource_wifi_datapath.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package routeros

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

/*
{
".id": "*1",
"bridge": "lan",
"bridge-cost": "1",
"bridge-horizon": "none",
"client-isolation": "true",
"disabled": "false",
"interface-list": "LAN",
"name": "datapath1",
"vlan-id": "1"
}
*/

// https://help.mikrotik.com/docs/display/ROS/WiFi#WiFi-Datapathproperties
func ResourceWifiDatapath() *schema.Resource {
resSchema := map[string]*schema.Schema{
MetaResourcePath: PropResourcePath("/interface/wifi/datapath"),
MetaId: PropId(Id),

"bridge": {
Type: schema.TypeString,
Optional: true,
Description: "Bridge interface to add the interface as a bridge port.",
},
"bridge_cost": {
Type: schema.TypeString,
Optional: true,
Description: "Spanning tree protocol cost of the bridge port.",
},
"bridge_horizon": {
Type: schema.TypeString,
Optional: true,
Description: "Bridge horizon to use when adding as a bridge port.",
},
"client_isolation": {
Type: schema.TypeBool,
Optional: true,
Description: "An option to toggle communication between clients connected to the same AP.",
},
KeyComment: PropCommentRw,
KeyDisabled: PropDisabledRw,
"interface_list": {
Type: schema.TypeString,
Optional: true,
Description: "List to which add the interface as a member.",
},
KeyName: PropName("Name of the datapath."),
"vlan_id": {
Type: schema.TypeString,
Optional: true,
Description: "Default VLAN ID to assign to client devices connecting to this interface.",
},
}

return &schema.Resource{
Description: `*<span style="color:red">This resource requires a minimum version of RouterOS 7.13.</span>*`,
CreateContext: DefaultCreate(resSchema),
ReadContext: DefaultRead(resSchema),
UpdateContext: DefaultUpdate(resSchema),
DeleteContext: DefaultDelete(resSchema),

Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},

Schema: resSchema,
}
}

0 comments on commit 4193151

Please sign in to comment.