Skip to content

Commit

Permalink
feat: Add routeros_interface_wireless_cap resource to manage CAPsMA…
Browse files Browse the repository at this point in the history
…N client
  • Loading branch information
dokmic committed Jan 21, 2024
1 parent c3130d0 commit b1558f9
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import routeros_interface_wireless_cap.settings .
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "routeros_interface_wireless_cap" "settings" {
discovery_interfaces = ["bridge1"]
enabled = true
interfaces = ["wlan1", "wlan2"]
}
1 change: 1 addition & 0 deletions routeros/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func Provider() *schema.Provider {
"routeros_interface_vrrp": ResourceInterfaceVrrp(),
"routeros_interface_wireguard": ResourceInterfaceWireguard(),
"routeros_interface_wireguard_peer": ResourceInterfaceWireguardPeer(),
"routeros_interface_wireless_cap": ResourceInterfaceWirelessCap(),
"routeros_interface_list": ResourceInterfaceList(),
"routeros_interface_list_member": ResourceInterfaceListMember(),
"routeros_interface_ovpn_server": ResourceInterfaceOpenVPNServer(),
Expand Down
117 changes: 117 additions & 0 deletions routeros/resource_interface_wireless_cap.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package routeros

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

/*
{
".about": "",
"bridge": "bridge1",
"caps-man-addresses": "",
"caps-man-certificate-common-names": "",
"caps-man-names": "",
"certificate": "CAP-000000000000",
"discovery-interfaces": "bridge1",
"enabled": "true",
"interfaces": "wlan1,wlan2",
"lock-to-caps-man": "false",
"requested-certificate": "CAP-000000000000",
"static-virtual": "false"
}
*/

// https://help.mikrotik.com/docs/pages/viewpage.action?pageId=1409149#APController(CAPsMAN)-CAPtoCAPsMANConnection
func ResourceInterfaceWirelessCap() *schema.Resource {

resSchema := map[string]*schema.Schema{
MetaResourcePath: PropResourcePath("/interface/wireless/cap"),
MetaId: PropId(Name),
MetaSkipFields: PropSkipFields(`".about"`),

"bridge": {
Type: schema.TypeString,
Optional: true,
Default: "none",
Description: "Bridge interface to add the interface as a bridge port.",
},
"caps_man_addresses": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validation.IsIPAddress,
},
Description: "List of Manager IP addresses that CAP will attempt to contact during discovery.",
},
"caps_man_certificate_common_names": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: "List of manager certificate common names that CAP will connect to.",
},
"caps_man_names": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: "An ordered list of CAPs Manager names that the CAP will connect to.",
},
"certificate": {
Type: schema.TypeString,
Optional: true,
Default: "none",
Description: "Certificate to use for authentication.",
},
"discovery_interfaces": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: "List of interfaces over which CAP should attempt to discover CAPs Manager.",
},
"enabled": {
Type: schema.TypeBool,
Optional: true,
Description: "Disable or enable the CAP functionality.",
},
"interfaces": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: "List of interfaces managed by CAPs Manager.",
},
"lock_to_caps_man": {
Type: schema.TypeBool,
Optional: true,
Description: "Lock CAP to the first CAPsMAN it connects to.",
},
"locked_caps_man_common_name": {
Type: schema.TypeString,
Computed: true,
Description: "Common name of the CAPsMAN that the CAP is locked to.",
},
"requested_certificate": {
Type: schema.TypeString,
Computed: true,
Description: "Requested certificate.",
},
"static_virtual": {
Type: schema.TypeBool,
Optional: true,
Description: "An option that creates static virtual interfaces.",
},
}

return &schema.Resource{
CreateContext: DefaultSystemCreate(resSchema),
ReadContext: DefaultSystemRead(resSchema),
UpdateContext: DefaultSystemUpdate(resSchema),
DeleteContext: DefaultSystemDelete(resSchema),

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

Schema: resSchema,
}
}

0 comments on commit b1558f9

Please sign in to comment.