-
Notifications
You must be signed in to change notification settings - Fork 61
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_routerboard_usb
resource to manage th…
…e USB port
- Loading branch information
Showing
4 changed files
with
54 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 @@ | ||
terraform import routeros_system_routerboard_usb.settings . |
3 changes: 3 additions & 0 deletions
3
examples/resources/routeros_system_routerboard_usb/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,3 @@ | ||
resource "routeros_system_routerboard_usb" "settings" { | ||
type = "auto" | ||
} |
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,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, | ||
} | ||
} |