-
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): New resource
routeros_ipv6_dhcp_server_option_sets
- Loading branch information
Showing
5 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
examples/resources/routeros_ipv6_dhcp_server_option_sets/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,5 @@ | ||
#The ID can be found via API or the terminal | ||
#The command for the terminal is -> :put [/ipv6/dhcp/server/option/sets get [print show-ids]] | ||
terraform import routeros_ipv6_dhcp_server_option_sets.test *3 | ||
#Or you can import a resource using one of its attributes | ||
terraform import routeros_ipv6_dhcp_server_option_sets.test "name=test-set" |
10 changes: 10 additions & 0 deletions
10
examples/resources/routeros_ipv6_dhcp_server_option_sets/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,10 @@ | ||
resource "routeros_ipv6_dhcp_server_option" "domain-search" { | ||
name = "domain-search" | ||
code = 24 | ||
value = "0x07'example'0x05'local'0x00" | ||
} | ||
|
||
resource "routeros_ipv6_dhcp_server_option_sets" "test" { | ||
name = "test-set" | ||
options = [routeros_ipv6_dhcp_server_option.domain-search.name] | ||
} |
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,45 @@ | ||
package routeros | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
/* | ||
{ | ||
".id": "*1", | ||
"name": "set1", | ||
"options": "dns,option1" | ||
} | ||
*/ | ||
|
||
// https://help.mikrotik.com/docs/display/ROS/ | ||
func ResourceIpv6DhcpServerOptionSets() *schema.Resource { | ||
resSchema := map[string]*schema.Schema{ | ||
MetaResourcePath: PropResourcePath("/ipv6/dhcp-server/option/sets"), | ||
MetaId: PropId(Id), | ||
|
||
KeyComment: PropCommentRw, | ||
KeyName: PropName("The name of the DHCPv6 option."), | ||
"options": { | ||
Type: schema.TypeSet, | ||
Optional: true, | ||
Description: "The list of options.", | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
}, | ||
}, | ||
} | ||
|
||
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,54 @@ | ||
package routeros | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
) | ||
|
||
const testIpv6DhcpServerOptionSets = "routeros_ipv6_dhcp_server_option_sets.test" | ||
|
||
func TestAccIpv6DhcpServerOptionSetsTest_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("/ipv6/dhcp-server/option/sets", "routeros_ipv6_dhcp_server_option_sets"), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccIpv6DhcpServerOptionSetsConfig(), | ||
Check: resource.ComposeTestCheckFunc( | ||
testResourcePrimaryInstanceId(testIpv6DhcpServerOptionSets), | ||
resource.TestCheckResourceAttr(testIpv6DhcpServerOptionSets, "name", "test-set"), | ||
resource.TestCheckResourceAttr(testIpv6DhcpServerOptionSets, "options.#", "1"), | ||
resource.TestCheckResourceAttr(testIpv6DhcpServerOptionSets, "options.0", "domain-search-o24"), | ||
), | ||
}, | ||
}, | ||
}) | ||
|
||
}) | ||
} | ||
} | ||
|
||
func testAccIpv6DhcpServerOptionSetsConfig() string { | ||
return fmt.Sprintf(`%v | ||
resource "routeros_ipv6_dhcp_server_option" "domain-search" { | ||
name = "domain-search-o24" | ||
code = 24 | ||
value = "0x07'example'0x05'local'0x00" | ||
} | ||
resource "routeros_ipv6_dhcp_server_option_sets" "test" { | ||
name = "test-set" | ||
options = [routeros_ipv6_dhcp_server_option.domain-search.name] | ||
} | ||
`, providerConfig) | ||
} |