-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #287 from terraform-routeros/vaerh/issue268
Vaerh/issue268
- Loading branch information
Showing
54 changed files
with
1,937 additions
and
43 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 @@ | ||
terraform import routeros_ip_cloud.test . |
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,4 @@ | ||
resource "routeros_bridge_mlag" "mlag" { | ||
bridge = "bridge1" | ||
peer_port = "stack-link" | ||
} |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Import with the name of the CAPsMAN channel configuration in case of the example use test-channel-config | ||
terraform import routeros_capsman_channel.test_channel test-channel-config | ||
#The ID can be found via API or the terminal | ||
#The command for the terminal is -> :put [/caps-man/channel get [print show-ids]] | ||
terraform import routeros_capsman_channel.test_channel "*1" |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Import with the name of the CAPsMAN configuration in case of the example use test_configuration_name | ||
terraform import routeros_capsman_configuration.test_configuration_2 test_configuration_name | ||
#The ID can be found via API or the terminal | ||
#The command for the terminal is -> :put [/caps-man/configuration get [print show-ids]] | ||
terraform import routeros_capsman_configuration.test_configuration_2 "*1" |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Import with the name of the CAPsMAN datapath configuration in case of the example use test-datapath-config | ||
terraform import routeros_capsman_datapath.test_datapath test-datapath-config | ||
#The ID can be found via API or the terminal | ||
#The command for the terminal is -> :put [/caps-man/datapath get [print show-ids]] | ||
terraform import routeros_capsman_datapath.test_datapath "*1" |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Import with the name of the CAPsMAN rates configuration in case of the example use test-rates-config | ||
terraform import routeros_capsman_rates.test_rates test-rates-config | ||
#The ID can be found via API or the terminal | ||
#The command for the terminal is -> :put [/caps-man/rates get [print show-ids]] | ||
terraform import routeros_capsman_rates.test_rates "*1" |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Import with the name of the CAPsMAN security profile in case of the example use test-security-config | ||
terraform import routeros_capsman_security.test_security test-security-config | ||
#The ID can be found via API or the terminal | ||
#The command for the terminal is -> :put [/caps-man/security get [print show-ids]] | ||
terraform import routeros_capsman_security.test_security "*1" |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Import with the name of the bridge in case of the example use bridge | ||
terraform import routeros_interface_bridge.bridge bridge | ||
#The ID can be found via API or the terminal | ||
#The command for the terminal is -> :put [/interface/bridge get [print show-ids]] | ||
terraform import routeros_interface_bridge.bridge "*1" |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Import with the name of the EoIP interface in case of the example, use `eoip-tunnel1` | ||
terraform import routeros_interface_eoip.eoip_tunnel1 eoip-tunnel1 | ||
#The ID can be found via API or the terminal | ||
#The command for the terminal is -> :put [/interface/eoip get [print show-ids]] | ||
terraform import routeros_interface_eoip.eoip_tunnel1 *B |
3 changes: 3 additions & 0 deletions
3
examples/resources/routeros_interface_ethernet_switch/import.sh
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,3 @@ | ||
#The ID can be found via API or the terminal | ||
#The command for the terminal is -> :put [/interface/ethernet/switch get [print show-ids]] | ||
terraform import routeros_interface_ethernet_switch.sw0 *0 |
4 changes: 4 additions & 0 deletions
4
examples/resources/routeros_interface_ethernet_switch/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,4 @@ | ||
resource "routeros_interface_ethernet_switch" "sw0" { | ||
switch_id = 0 # Optional | ||
name = "new switch" | ||
} |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Import with the name of the gre interface in case of the example use gre-hq-1 | ||
terraform import routeros_interface_gre.gre_hq gre-hq-1 | ||
#The ID can be found via API or the terminal | ||
#The command for the terminal is -> :put [/interface/gre get [print show-ids]] | ||
terraform import routeros_interface_gre.gre_hq "*1" |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Import with the name of the interface list in case of the example use my-list | ||
terraform import routeros_interface_list.list my-list | ||
#The ID can be found via API or the terminal | ||
#The command for the terminal is -> :put [/interface/list get [print show-ids]] | ||
terraform import routeros_interface_list.list "*2000010" |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Import with the name of the vlan interface in case of the example use VLAN_TEST | ||
terraform import routeros_interface_vlan.interface_vlan VLAN_TEST | ||
#The ID can be found via API or the terminal | ||
#The command for the terminal is -> :put [/interface/vlan get [print show-ids]] | ||
terraform import routeros_interface_vlan.interface_vlan "*1" |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Import with the name of the wireguard interface in case of the example use test_wg_interface | ||
terraform import routeros_interface_wireguard.test_wg_interface test_wg_interface | ||
#The ID can be found via API or the terminal | ||
#The command for the terminal is -> :put [/interface/wireguard get [print show-ids]] | ||
terraform import routeros_interface_wireguard.test_wg_interface "*1" |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Import with the name of the DHCP server in case of the example use bridge_dhcp | ||
terraform import routeros_ip_dhcp_server.server bridge_dhcp | ||
#The ID can be found via API or the terminal | ||
#The command for the terminal is -> :put [/ip/dhcp-server get [print show-ids]] | ||
terraform import routeros_ip_dhcp_server.server "*1" |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Import with the name of the ip pool in case of the example use my_ip_pool | ||
terraform import routeros_ip_pool.pool my_ip_pool | ||
#The ID can be found via API or the terminal | ||
#The command for the terminal is -> :put [/ip/pool get [print show-ids]] | ||
terraform import routeros_ip_pool.pool "*1" |
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
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,35 @@ | ||
package routeros | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func stateMigrationNameToId(resourcePath string) schema.StateUpgradeFunc { | ||
return func(ctx context.Context, rawState map[string]interface{}, m interface{}) (map[string]interface{}, error) { | ||
ColorizedMessage(ctx, INFO, fmt.Sprintf("ID attribute before migration: %#v", rawState["id"])) | ||
|
||
if rawState["id"] != nil { | ||
res, err := ReadItems(&ItemId{Name, rawState["id"].(string)}, resourcePath, m.(Client)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// Resource not found. | ||
if len(*res) == 0 { | ||
rawState["id"] = "" | ||
ColorizedMessage(ctx, WARN, "No resource found, but the scheme has been updated.", | ||
map[string]interface{}{"path": resourcePath, "id": rawState["id"]}) | ||
return rawState, nil | ||
} | ||
|
||
rawState["id"] = (*res)[0].GetID(Id) | ||
} | ||
|
||
ColorizedMessage(ctx, INFO, fmt.Sprintf("ID attribute after migration: %#v", rawState["id"])) | ||
|
||
return rawState, nil | ||
} | ||
} |
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,85 @@ | ||
package routeros | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" | ||
) | ||
|
||
func ResourceCapsManChannelV0() *schema.Resource { | ||
return &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
MetaResourcePath: PropResourcePath("/caps-man/channel"), | ||
MetaId: PropId(Name), | ||
|
||
"band": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "Define operational radio frequency band and mode taken from hardware capability of wireless card.", | ||
ValidateFunc: validation.StringInSlice([]string{"2ghz-b", "2ghz-b/g", "2ghz-b/g/n", "2ghz-g/n", "2ghz-onlyg", "2ghz-onlyn", | ||
"5ghz-a", "5ghz-a/n", "5ghz-a/n/ac", "5ghz-n/ac", "5ghz-onlyac", "5ghz-onlyn"}, false), | ||
}, | ||
KeyComment: PropCommentRw, | ||
"control_channel_width": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "Control channel width.", | ||
ValidateFunc: validation.StringInSlice([]string{"5mhz", "10mhz", "20mhz", "40mhz-turbo"}, false), | ||
}, | ||
"extension_channel": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "Extension channel configuration. (E.g. Ce = extension channel is above Control channel, " + | ||
"eC = extension channel is below Control channel)", | ||
ValidateFunc: validation.StringInSlice([]string{"Ce", "Ceee", "Ceeeeeee", "eC", "eCee", "eCeeeeee", | ||
"eeCe", "eeCeeeee", "eeeC", "eeeCeeee", "eeeeCeee", "eeeeeCee", "eeeeeeCe", "eeeeeeeC", | ||
"xx", "xxxx", "xxxxxxxx", "disabled"}, false), | ||
}, | ||
"frequency": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
Computed: true, | ||
Description: "Channel frequency value in MHz on which AP will operate. If left blank, CAPsMAN will " + | ||
"automatically determine the best frequency that is least occupied.", | ||
}, | ||
KeyName: PropNameForceNewRw, | ||
"reselect_interval": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "The interval after which the least occupied frequency is chosen, can be defined as a random " + | ||
"interval, ex. as '30m..60m'. Works only if channel.frequency is left blank.", | ||
// We may need to write a custom DiffSuppressFunc. | ||
// DiffSuppressFunc: TimeEquall, not for time ranges | ||
}, | ||
"save_selected": { | ||
Type: schema.TypeBool, | ||
Optional: true, | ||
Description: "If channel frequency is chosen automatically and channel.reselect-interval is used, then " + | ||
"saves the last picked frequency.", | ||
}, | ||
"secondary_frequency": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "Specifies the second frequency that will be used for 80+80MHz configuration. " + | ||
"Set it to Disabled in order to disable 80+80MHz capability.", | ||
}, | ||
"skip_dfs_channels": { | ||
Type: schema.TypeBool, | ||
Optional: true, | ||
Description: "If channel.frequency is left blank, the selection will skip DFS channels.", | ||
}, | ||
"tx_power": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
Description: "TX Power for CAP interface (for the whole interface not for individual chains) in dBm. " + | ||
"It is not possible to set higher than allowed by country regulations or interface. By " + | ||
"default max allowed by country or interface is used.", | ||
ValidateFunc: validation.IntBetween(-30, 40), | ||
}, | ||
"width": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "Channel Width in MHz.", | ||
}, | ||
}, | ||
} | ||
} |
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
Oops, something went wrong.