Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add DHCP server config resource #288

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import routeros_ip_dhcp_server_config.settings .
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "routeros_ip_dhcp_server_config" "settings" {
accounting = true
interim_update = "1m"
radius_password = "same-as-user"
store_leases_disk = "10m"
}
1 change: 1 addition & 0 deletions routeros/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func Provider() *schema.Provider {
// IP objects
"routeros_ip_dhcp_client": ResourceDhcpClient(),
"routeros_ip_dhcp_server": ResourceDhcpServer(),
"routeros_ip_dhcp_server_config": ResourceDhcpServerConfig(),
"routeros_ip_dhcp_server_network": ResourceDhcpServerNetwork(),
"routeros_ip_dhcp_server_lease": ResourceDhcpServerLease(),
"routeros_ip_dhcp_server_option": ResourceDhcpServerOption(),
Expand Down
53 changes: 53 additions & 0 deletions routeros/resource_ip_dhcp_server_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package routeros

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

// ResourceDhcpServerConfig https://help.mikrotik.com/docs/display/ROS/DHCP#DHCP-StoreConfiguration
func ResourceDhcpServerConfig() *schema.Resource {
resSchema := map[string]*schema.Schema{
MetaResourcePath: PropResourcePath("/ip/dhcp-server/config"),
MetaId: PropId(Id),

"accounting": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Description: "An option that enables accounting for DHCP leases.",
},
"interim_update": {
Type: schema.TypeString,
Optional: true,
Default: "0s",
Description: "An option determining whether the DHCP server sends periodic updates to the accounting server during a lease.",
DiffSuppressFunc: TimeEquall,
},
"radius_password": {
Type: schema.TypeString,
Optional: true,
Default: "empty",
Description: "An option to set the password parameter for the RADIUS server. This option is available in RouterOS starting from version 7.0.",
ValidateFunc: validation.StringInSlice([]string{"empty", "same-as-user"}, false),
},
"store_leases_disk": {
Type: schema.TypeString,
Optional: true,
Default: "5m",
Description: "An option of how often the DHCP leases will be stored on disk.",
DiffSuppressFunc: TimeEquall,
},
}
return &schema.Resource{
CreateContext: DefaultSystemCreate(resSchema),
ReadContext: DefaultSystemRead(resSchema),
UpdateContext: DefaultSystemUpdate(resSchema),
DeleteContext: DefaultSystemDelete(resSchema),
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},

Schema: resSchema,
}
}
Loading