Skip to content

Commit

Permalink
feat: Add the routeros_system_routerboard_usb resource to manage th…
Browse files Browse the repository at this point in the history
…e USB port
  • Loading branch information
dokmic authored and vaerh committed Aug 19, 2024
1 parent 85db3b5 commit 4251b6a
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import routeros_system_routerboard_usb.settings .
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resource "routeros_system_routerboard_usb" "settings" {
type = "auto"
}
1 change: 1 addition & 0 deletions routeros/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ func Provider() *schema.Provider {
"routeros_system_routerboard_button_reset": ResourceSystemRouterboardButtonReset(),
"routeros_system_routerboard_button_wps": ResourceSystemRouterboardButtonWps(),
"routeros_system_routerboard_settings": ResourceSystemRouterboardSettings(),
"routeros_system_routerboard_usb": ResourceSystemRouterboardUsb(),
"routeros_system_scheduler": ResourceSystemScheduler(),
"routeros_system_script": ResourceSystemScript(),
"routeros_system_user": ResourceUser(),
Expand Down
49 changes: 49 additions & 0 deletions routeros/resource_system_routerboard_usb.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package routeros

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

/*
{
"type": "auto",
"usb-mode": "automatic"
}
*/

// https://help.mikrotik.com/docs/display/ROS/USB+Features
func ResourceSystemRouterboardUsb() *schema.Resource {
resSchema := map[string]*schema.Schema{
MetaResourcePath: PropResourcePath("/system/routerboard/usb"),
MetaId: PropId(Id),

"type": {
Type: schema.TypeString,
Optional: true,
Description: "An option to set the type of the USB port. Possible value: `auto`, `mini-PCIe`, `USB-type-A`.",
ValidateFunc: validation.StringInSlice([]string{"auto", "mini-PCIe", "USB-type-A"}, false),
DiffSuppressFunc: AlwaysPresentNotUserProvided,
},
"usb_mode": {
Type: schema.TypeString,
Optional: true,
Description: "An option to set the USB port mode. Possible values: `automatic`, `force-host`.",
ValidateFunc: validation.StringInSlice([]string{"automatic", "force-host"}, false),
DiffSuppressFunc: AlwaysPresentNotUserProvided,
},
}

return &schema.Resource{
CreateContext: DefaultSystemCreate(resSchema),
ReadContext: DefaultSystemRead(resSchema),
UpdateContext: DefaultSystemUpdate(resSchema),
DeleteContext: DefaultSystemDelete(resSchema),

Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},

Schema: resSchema,
}
}

0 comments on commit 4251b6a

Please sign in to comment.