Skip to content

Commit

Permalink
fix: Can not set rtt parameters in routeros_tool_netwatch
Browse files Browse the repository at this point in the history
Fixes #535
  • Loading branch information
vaerh committed Aug 7, 2024
1 parent 010d547 commit afa971e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 2 additions & 0 deletions examples/resources/routeros_tool_netwatch/resource.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
resource "routeros_tool_netwatch" "test" {
name = "watch-google-pdns"
type = "icmp"
host = "8.8.8.8"
interval = "30s"
up_script = ":log info \"Ping to 8.8.8.8 successful\""
thr_max = "400ms"
}
21 changes: 17 additions & 4 deletions routeros/resource_tool_netwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ func ResourceToolNetwatch() *schema.Resource {
resSchema := map[string]*schema.Schema{
MetaResourcePath: PropResourcePath("/tool/netwatch"),
MetaId: PropId(Id),
MetaSkipFields: PropSkipFields(
// Generic
"since", "status", "done_tests", "failed_tests",
// ICMP
"sent_count", "response_count", "loss_count", "loss_percent", "rtt_avg", "rtt_min", "rtt_max", "rtt_jitter",
"rtt_stdev",
// TCP
"tcp_connect_time",
// HTTP, HTTPS
"http_status_code",
// DNS
"ip", "ip6", "mail_servers", "name_servers",
),

KeyComment: PropCommentRw,
KeyDisabled: PropDisabledRw,
Expand Down Expand Up @@ -135,25 +148,25 @@ func ResourceToolNetwatch() *schema.Resource {
Description: "Fail threshold for loss-percent.",
DiffSuppressFunc: AlwaysPresentNotUserProvided,
},
"thr_rtt_avg": {
"thr_avg": {
Type: schema.TypeString,
Optional: true,
Description: "Fail threshold for rtt-avg.",
DiffSuppressFunc: TimeEquall,
},
"thr_rtt_jitter": {
"thr_jitter": {
Type: schema.TypeString,
Optional: true,
Description: "Fail threshold for rtt-jitter.",
DiffSuppressFunc: TimeEquall,
},
"thr_rtt_max": {
"thr_max": {
Type: schema.TypeString,
Optional: true,
Description: "Fail threshold for rtt-max (a value above thr-max is a probe fail).",
DiffSuppressFunc: TimeEquall,
},
"thr_rtt_stdev": {
"thr_stdev": {
Type: schema.TypeString,
Optional: true,
Description: "Fail threshold for rtt-stdev.",
Expand Down
2 changes: 2 additions & 0 deletions routeros/resource_tool_netwatch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ func testAccToolNetwatchConfig() string {
return fmt.Sprintf(`%v
resource "routeros_tool_netwatch" "test" {
name = "watch-google-pdns"
type = "icmp"
host = "8.8.8.8"
interval = "30s"
up_script = ":log info \"Ping to 8.8.8.8 successful\""
thr_max = "400ms"
}
`, providerConfig)
}

0 comments on commit afa971e

Please sign in to comment.