-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wifi): Add new resources
routeros_interface_w60g
, `routeros_in…
…terface_w60g_station` Closes #618
- Loading branch information
Showing
9 changed files
with
258 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#The ID can be found via API or the terminal | ||
#The command for the terminal is -> :put [/interface/w60g get [print show-ids]] | ||
terraform import routeros_interface_w60g.test *3 | ||
#Or you can import a resource using one of its attributes | ||
terraform import routeros_interface_w60g.test "name=xxx" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
resource "routeros_interface_w60g" "test" { | ||
make = "wlan60-1" | ||
password = "put_your_safe_password_here" | ||
ssid = "put_your_new_ssid_here" | ||
disabled = false | ||
mode = "ap-bridge" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#The ID can be found via API or the terminal | ||
#The command for the terminal is -> :put [/interface/w60g/station get [print show-ids]] | ||
terraform import routeros_interface_w60g_station.test *3 | ||
#Or you can import a resource using one of its attributes | ||
terraform import routeros_interface_w60g_station.test "name=xxx" |
6 changes: 6 additions & 0 deletions
6
examples/resources/routeros_interface_w60g_station/resource.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
resource "routeros_interface_w60g_station" "test" { | ||
name = "wlan60-station-1" | ||
parent = "wlan60-1" | ||
remote-address = "AA:AA:AA:AA:AA:AA" | ||
put-in-bridge = "parent" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
package routeros | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" | ||
) | ||
|
||
/* | ||
{ | ||
".id":"*2", | ||
"arp":"enabled", | ||
"arp-timeout":"auto", | ||
"beamforming-event":"1858", | ||
"default-scan-list":"58320,60480,62640,64800", | ||
"disabled":"false", | ||
"frequency":"60480", | ||
"isolate-stations":"false", | ||
"l2mtu":"1600", | ||
"mac-address":"48:8F:5A:F3:34:E0", | ||
"mode":"ap-bridge", | ||
"mtu":"1500", | ||
"name":"wlan60-1", | ||
"password":"password", | ||
"put-stations-in-bridge":"bridge", | ||
"region":"eu", | ||
"running":"false", | ||
"rx-mpdu-crc-err":"20354232", | ||
"rx-mpdu-crc-ok":"1401642596", | ||
"rx-ppdu":"1403448812", | ||
"ssid":"ptmp01", | ||
"tx-fw-msdu":"52", | ||
"tx-io-msdu":"0", | ||
"tx-mpdu-new":"202533008", | ||
"tx-mpdu-retry":"3570458", | ||
"tx-mpdu-total":"206103466", | ||
"tx-ppdu":"3230579961", | ||
"tx-ppdu-from-q":"2031518609", | ||
"tx-sector":"auto", | ||
"tx-sw-msdu":"202533128" | ||
} | ||
*/ | ||
|
||
// https://help.mikrotik.com/docs/spaces/ROS/pages/39059501/W60G#W60G-Generalinterfaceproperties | ||
func ResourceInterfaceW60g() *schema.Resource { | ||
resSchema := map[string]*schema.Schema{ | ||
MetaResourcePath: PropResourcePath("/interface/w60g"), | ||
MetaId: PropId(Id), | ||
MetaSkipFields: PropSkipFields("beamforming_event", "rx_mpdu_crc_err", "rx_mpdu_crc_ok", "rx_ppdu", "tx_fw_msdu", | ||
"tx_io_msdu", "tx_mpdu_new", "tx_mpdu_retry", "tx_mpdu_total", "tx_ppdu", "tx_ppdu_from_q", "tx_sector", | ||
"tx_sw_msdu"), | ||
|
||
KeyArp: PropArpRw, | ||
KeyArpTimeout: PropArpTimeoutRw, | ||
KeyComment: PropCommentRw, | ||
KeyDisabled: PropDisabledRw, | ||
"frequency": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "Frequency used in communication (Only active on bridge device).", | ||
ValidateFunc: validation.StringInSlice([]string{"58320", "60480", "62640", "64800", "66000", "auto"}, false), | ||
DiffSuppressFunc: AlwaysPresentNotUserProvided, | ||
}, | ||
"isolate_stations": { | ||
Type: schema.TypeBool, | ||
Optional: true, | ||
Description: "Don't allow communication between connected clients (from RouterOS 6.41).", | ||
DiffSuppressFunc: AlwaysPresentNotUserProvided, | ||
}, | ||
KeyL2Mtu: PropL2MtuRw, | ||
KeyMacAddress: PropMacAddressRw("MAC address of the radio interface.", false), | ||
"mdmg_fix": { | ||
Type: schema.TypeBool, | ||
Optional: true, | ||
Description: "Experimental feature working only on wAP60Gx3 devices, providing better point to multi point " + | ||
"stability in some cases.", | ||
}, | ||
"mode": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "Operation mode.", | ||
ValidateFunc: validation.StringInSlice([]string{"ap-bridge", "bridge", "sniff", "station-bridge"}, false), | ||
DiffSuppressFunc: AlwaysPresentNotUserProvided, | ||
}, | ||
KeyMtu: PropMtuRw(), | ||
KeyName: PropName("Name of the interface."), | ||
"password": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Sensitive: true, | ||
Description: "Password used for AES encryption.", | ||
DiffSuppressFunc: AlwaysPresentNotUserProvided, | ||
}, | ||
"put_stations_in_bridge": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "Put newly created station device interfaces in this bridge.", | ||
DiffSuppressFunc: AlwaysPresentNotUserProvided, | ||
}, | ||
"region": { | ||
Type: schema.TypeBool, | ||
Optional: true, | ||
Description: "Parameter to limit frequency use.", | ||
ValidateFunc: validation.StringInSlice([]string{"asia", "australia", "canada", "china", "eu", "japan", "no-region-set", "usa"}, false), | ||
DiffSuppressFunc: AlwaysPresentNotUserProvided, | ||
}, | ||
KeyRunning: PropRunningRo, | ||
"scan_list": { | ||
Type: schema.TypeSet, | ||
Optional: true, | ||
Description: "Scan list to limit connectivity over frequencies in station mode.", | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
ValidateFunc: validation.StringInSlice([]string{"58320", "60480", "62640", "64800", "66000", "auto"}, false), | ||
}, | ||
DiffSuppressFunc: AlwaysPresentNotUserProvided, | ||
}, | ||
"ssid": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "SSID (service set identifier) is a name that identifies wireless network (0..32 char).", | ||
ValidateFunc: validation.StringLenBetween(0, 32), | ||
DiffSuppressFunc: AlwaysPresentNotUserProvided, | ||
}, | ||
"tx_sector": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
Description: "Disables beamforming and locks to selected radiation pattern.", | ||
ValidateFunc: validation.IntBetween(0, 63), | ||
DiffSuppressFunc: AlwaysPresentNotUserProvided, | ||
}, | ||
} | ||
|
||
return &schema.Resource{ | ||
CreateContext: DefaultCreate(resSchema), | ||
ReadContext: DefaultRead(resSchema), | ||
UpdateContext: DefaultUpdate(resSchema), | ||
DeleteContext: DefaultDelete(resSchema), | ||
|
||
Importer: &schema.ResourceImporter{ | ||
StateContext: ImportStateCustomContext(resSchema), | ||
}, | ||
|
||
Schema: resSchema, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package routeros | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
/* | ||
{ | ||
".id":"*8", | ||
"arp":"enabled", | ||
"arp-timeout":"auto", | ||
"beamforming-event":"3042", | ||
"disabled":"false", | ||
"mac-address":"48:8F:5A:F3:34:E0", | ||
"mtu":"1500", | ||
"name":"ptp01", | ||
"parent":"wlan60-1", | ||
"put-in-bridge":"parent", | ||
"remote-address":"48:8F:5A:47:81:9E", | ||
"running":"true" | ||
} | ||
*/ | ||
|
||
// https://help.mikrotik.com/docs/spaces/ROS/pages/39059501/W60G | ||
func ResourceInterfaceW60gStation() *schema.Resource { | ||
resSchema := map[string]*schema.Schema{ | ||
MetaResourcePath: PropResourcePath("/interface/w60g/station"), | ||
MetaId: PropId(Id), | ||
MetaSkipFields: PropSkipFields("beamforming_event"), | ||
|
||
KeyArp: PropArpRw, | ||
KeyArpTimeout: PropArpTimeoutRw, | ||
KeyDisabled: PropDisabledRw, | ||
KeyMacAddress: PropMacAddressRw("MAC address of the station interface.", false), | ||
KeyMtu: PropMtuRw(), | ||
KeyName: PropName("Name of the interface."), | ||
"parent": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "Parent interface name.", | ||
DiffSuppressFunc: AlwaysPresentNotUserProvided, | ||
}, | ||
"put_in_bridge": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "Add station device interface to specific bridge.", | ||
DiffSuppressFunc: AlwaysPresentNotUserProvided, | ||
}, | ||
"remote_address": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "MAC address of bridge interface, station is connecting to.", | ||
DiffSuppressFunc: AlwaysPresentNotUserProvided, | ||
}, | ||
KeyRunning: PropRunningRo, | ||
} | ||
|
||
return &schema.Resource{ | ||
CreateContext: DefaultCreate(resSchema), | ||
ReadContext: DefaultRead(resSchema), | ||
UpdateContext: DefaultUpdate(resSchema), | ||
DeleteContext: DefaultDelete(resSchema), | ||
|
||
Importer: &schema.ResourceImporter{ | ||
StateContext: ImportStateCustomContext(resSchema), | ||
}, | ||
|
||
Schema: resSchema, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package routeros | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestAccInterfaceW60gStationTest_basic(t *testing.T) { | ||
t.Log("The test is skipped, the resource is only available on real hardware.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package routeros | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestAccInterfaceW60gTest_basic(t *testing.T) { | ||
t.Log("The test is skipped, the resource is only available on real hardware.") | ||
} |