Skip to content

Commit

Permalink
feat: Add Wifi accounting and authentication 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 0c7e3af commit edd8299
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/resources/routeros_wifi_aaa/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/aaa get [print show-ids]]
terraform import routeros_wifi_aaa.aaa1 '*1'
6 changes: 6 additions & 0 deletions examples/resources/routeros_wifi_aaa/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "routeros_wifi_aaa" "aaa1" {
called_format = "S"
name = "aaa1"
password_format = ""
username_format = "AA:AA:AA:AA:AA:AA"
}
1 change: 1 addition & 0 deletions routeros/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ func Provider() *schema.Provider {
"routeros_user_manager_user_profile": ResourceUserManagerUserProfile(),

// WiFi
"routeros_wifi_aaa": ResourceWifiAaa(),
"routeros_wifi_channel": ResourceWifiChannel(),
"routeros_wifi_security": ResourceWifiSecurity(),
},
Expand Down
81 changes: 81 additions & 0 deletions routeros/resource_wifi_aaa.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package routeros

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

/*
{
".id": "*1",
"called-format": "II-II-II-II-II-II:S",
"calling-format": "AA-AA-AA-AA-AA-AA",
"disabled": "false",
"interim-update": "disabled",
"mac-caching": "disabled",
"name": "aaa1",
"nas-identifier": "router",
"password-format": "",
"username-format": "AA:AA:AA:AA:AA:AA"
}
*/

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

"called_format": {
Type: schema.TypeString,
Optional: true,
Description: "Format of the `Called-Station-Id` RADIUS attribute.",
},
"calling_format": {
Type: schema.TypeString,
Optional: true,
Description: "Format of the `Calling-Station-Id` RADIUS attribute.",
},
KeyComment: PropCommentRw,
KeyDisabled: PropDisabledRw,
"interim_update": {
Type: schema.TypeString,
Optional: true,
Description: "Interval at which to send interim updates about traffic accounting to the RADIUS server.",
},
"mac_caching": {
Type: schema.TypeString,
Optional: true,
Description: "Time to cache RADIUS server replies when MAC address authentication is enabled.",
},
KeyName: PropName("Name of the AAA profile."),
"nas_identifier": {
Type: schema.TypeString,
Optional: true,
Description: "Value of the `NAS-Identifier` RADIUS attribute.",
},
"password_format": {
Type: schema.TypeString,
Optional: true,
Description: "Format of the `User-Password` RADIUS attribute.",
},
"username_format": {
Type: schema.TypeString,
Optional: true,
Description: "Format of the `User-Name` RADIUS attribute.",
},
}

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 edd8299

Please sign in to comment.