-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add the
routeros_system_led
resource to manage LEDs
- Loading branch information
Showing
4 changed files
with
86 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,3 @@ | ||
#The ID can be found via API or the terminal | ||
#The command for the terminal is -> :put [/system/leds get [print show-ids]] | ||
terraform import routeros_system_led.sfp1 '*1' |
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 @@ | ||
resource "routeros_system_led" "sfp1" { | ||
interface = "sfp1" | ||
leds = ["sfp-led"] | ||
type = "interface-activity" | ||
} |
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,77 @@ | ||
package routeros | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" | ||
) | ||
|
||
/* | ||
{ | ||
".id": "*1", | ||
"default": "true", | ||
"disabled": "false", | ||
"interface": "sfp1", | ||
"leds": "sfp-led", | ||
"type": "interface-activity" | ||
} | ||
*/ | ||
|
||
// https://help.mikrotik.com/docs/display/ROS/LEDs | ||
func ResourceSystemLed() *schema.Resource { | ||
resSchema := map[string]*schema.Schema{ | ||
MetaResourcePath: PropResourcePath("/system/leds"), | ||
MetaId: PropId(Id), | ||
|
||
"default": { | ||
Type: schema.TypeBool, | ||
Computed: true, | ||
}, | ||
KeyDisabled: PropDisabledRw, | ||
"interface": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "An option to set the interface to which the LED is connected.", | ||
ValidateFunc: validation.StringIsNotWhiteSpace, | ||
DiffSuppressFunc: AlwaysPresentNotUserProvided, | ||
}, | ||
"leds": { | ||
Type: schema.TypeList, | ||
Optional: true, | ||
Elem: &schema.Schema{Type: schema.TypeString}, | ||
Description: "An option to set the LED name.", | ||
}, | ||
"modem_signal_treshold": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
Description: "An option to set the signal strength threshold for the modem LED.", | ||
ValidateFunc: validation.IntBetween(-113, -51), | ||
DiffSuppressFunc: AlwaysPresentNotUserProvided, | ||
}, | ||
"type": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "An option to set the LED type.", | ||
ValidateFunc: validation.StringInSlice([]string{ | ||
"align-down", "align-left", "align-right", "align-up", "ap-cap", "fan-fault", "flash-access", | ||
"interface-activity", "interface-receive", "interface-speed", "interface-speed-1G", | ||
"interface-speed-25G", "interface-status", "interface-transmit", | ||
"modem-signal", "modem-technology", "off", "on", "poe-fault", "poe-out", | ||
"wireless-signal-strength", "wireless-status", | ||
}, false), | ||
DiffSuppressFunc: AlwaysPresentNotUserProvided, | ||
}, | ||
} | ||
|
||
return &schema.Resource{ | ||
CreateContext: DefaultCreate(resSchema), | ||
ReadContext: DefaultRead(resSchema), | ||
UpdateContext: DefaultUpdate(resSchema), | ||
DeleteContext: DefaultDelete(resSchema), | ||
|
||
Importer: &schema.ResourceImporter{ | ||
StateContext: schema.ImportStatePassthroughContext, | ||
}, | ||
|
||
Schema: resSchema, | ||
} | ||
} |