-
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.
Showing
5 changed files
with
105 additions
and
2 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,3 @@ | ||
#The ID can be found via API or the terminal | ||
#The command for the terminal is -> :put [/ip/dhcp-client/option get [print show-ids]] | ||
terraform import routeros_ip_dhcp_client_option.option "*0" |
4 changes: 4 additions & 0 deletions
4
examples/resources/routeros_ip_dhcp_client_option/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_ip_dhcp_client_option" "option" { | ||
name = "my-dhcp-option" | ||
code = 60 | ||
} |
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,47 @@ | ||
package routeros | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
// ResourceDhcpClient https://help.mikrotik.com/docs/display/ROS/DHCP#DHCP-DHCPClient | ||
func ResourceDhcpClientOption() *schema.Resource { | ||
resSchema := map[string]*schema.Schema{ | ||
MetaResourcePath: PropResourcePath("/ip/dhcp-client/option"), | ||
MetaId: PropId(Id), | ||
"name": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The name that will be used in dhcp-client.", | ||
}, | ||
"code": { | ||
Type: schema.TypeInt, | ||
Required: true, | ||
Description: "The dhcp-client option code.", | ||
}, | ||
"value": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "The dhcp-client option", | ||
}, | ||
"raw_value": | ||
{ | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Computed: true, | ||
Description: "raw_value is computed from value.", | ||
}, | ||
|
||
} | ||
return &schema.Resource{ | ||
CreateContext: DefaultCreate(resSchema), | ||
ReadContext: DefaultRead(resSchema), | ||
UpdateContext: DefaultUpdate(resSchema), | ||
DeleteContext: DefaultDelete(resSchema), | ||
Importer: &schema.ResourceImporter{ | ||
StateContext: schema.ImportStatePassthroughContext, | ||
}, | ||
|
||
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 ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
) | ||
|
||
const testIpDhcpClientOptionAddress = "routeros_ip_dhcp_client_option.test_dhcp" | ||
|
||
func TestAccIpDhcpClientOptionTest_basic(t *testing.T) { | ||
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("/ip/dhcp-client-option", "routeros_ip_dhcp_client_option"), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccIpDhcpClientOptionConfig(), | ||
Check: resource.ComposeTestCheckFunc( | ||
testResourcePrimaryInstanceId(testIpDhcpClientOptionAddress), | ||
resource.TestCheckResourceAttr(testIpDhcpClientOptionAddress, "name", "my-dhcp-option"), | ||
resource.TestCheckResourceAttr(testIpDhcpClientOptionAddress, "code", "60"), | ||
|
||
), | ||
}, | ||
}, | ||
}) | ||
|
||
}) | ||
} | ||
} | ||
|
||
func testAccIpDhcpClientOptionConfig() string { | ||
return providerConfig + ` | ||
resource "routeros_ip_dhcp_client_option" "test_dhcp" { | ||
name = "my-dhcp-option" | ||
code = 60 | ||
} | ||
` | ||
} |