-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ipv6): Add new resource
routeros_interface_6to4
Fixes #593
- Loading branch information
Showing
5 changed files
with
113 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/6to4 get [print show-ids]] | ||
terraform import routeros_interface_6to4.test *3 | ||
#Or you can import a resource using one of its attributes | ||
terraform import routeros_interface_6to4.test "name=6to4-tunnel1" |
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_6to4" "test" { | ||
name = "6to4-tunnel1" | ||
keepalive = "10,10" | ||
} |
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,56 @@ | ||
package routeros | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
/* | ||
{ | ||
".id": "*3", | ||
"actual-mtu": "1480", | ||
"clamp-tcp-mss": "true", | ||
"disabled": "false", | ||
"dont-fragment": "no", | ||
"dscp": "inherit", | ||
"local-address": "0.0.0.0", | ||
"mtu": "auto", | ||
"name": "6to4-tunnel1", | ||
"remote-address": "unspecified", | ||
"running": "true" | ||
} | ||
*/ | ||
|
||
// https://help.mikrotik.com/docs/spaces/ROS/pages/135004174/6to4 | ||
func ResourceInterface6to4() *schema.Resource { | ||
resSchema := map[string]*schema.Schema{ | ||
MetaResourcePath: PropResourcePath("/interface/6to4"), | ||
MetaId: PropId(Id), | ||
|
||
KeyActualMtu: PropActualMtuRo, | ||
KeyClampTcpMss: PropClampTcpMssRw, | ||
KeyComment: PropCommentRw, | ||
KeyDisabled: PropDisabledRw, | ||
KeyDontFragment: PropDontFragmentRw, | ||
KeyDscp: PropDscpRw, | ||
KeyIpsecSecret: PropIpsecSecretRw, | ||
KeyKeepalive: PropKeepaliveRw, | ||
KeyLocalAddress: PropLocalAddressRw, | ||
KeyMtu: PropMtuRw(), | ||
KeyName: PropName("Interface name."), | ||
KeyRemoteAddress: PropRemoteAddressRw, | ||
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,47 @@ | ||
package routeros | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
) | ||
|
||
const testInterface6to4 = "routeros_interface_6to4.test" | ||
|
||
func TestAccInterface6to4Test_basic(t *testing.T) { | ||
t.Parallel() | ||
for _, name := range testNames { | ||
t.Run(name, func(t *testing.T) { | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { | ||
testAccPreCheck(t) | ||
testSetTransportEnv(t, name) | ||
}, | ||
ProviderFactories: testAccProviderFactories, | ||
CheckDestroy: testCheckResourceDestroy("/interface/6to4", "routeros_interface_6to4"), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccInterface6to4Config(), | ||
Check: resource.ComposeTestCheckFunc( | ||
testResourcePrimaryInstanceId(testInterface6to4), | ||
resource.TestCheckResourceAttr(testInterface6to4, "name", "6to4-tunnel1"), | ||
resource.TestCheckResourceAttr(testInterface6to4, "keepalive", "10s,10"), | ||
), | ||
}, | ||
}, | ||
}) | ||
|
||
}) | ||
} | ||
} | ||
|
||
func testAccInterface6to4Config() string { | ||
return fmt.Sprintf(`%v | ||
resource "routeros_interface_6to4" "test" { | ||
name = "6to4-tunnel1" | ||
keepalive = "10,10" | ||
} | ||
`, providerConfig) | ||
} |