-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(switch): Add support for /interface/ethernet/switch/vlan
Fixes #325
- Loading branch information
Showing
3 changed files
with
80 additions
and
1 deletion.
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
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,69 @@ | ||
package routeros | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" | ||
) | ||
|
||
/* | ||
{ | ||
".id": "*2", | ||
"disabled": "false", | ||
"invalid": "false", | ||
"ports": "ether1", | ||
"switch": "switch1", | ||
"vlan-id": "0" | ||
} | ||
*/ | ||
|
||
// https://help.mikrotik.com/docs/display/ROS/Switch+Chip+Features#SwitchChipFeatures-VLANTable | ||
func ResourceInterfaceEthernetSwitchVlan() *schema.Resource { | ||
resSchema := map[string]*schema.Schema{ | ||
MetaResourcePath: PropResourcePath("/interface/ethernet/switch/vlan"), | ||
MetaId: PropId(Id), | ||
|
||
KeyComment: PropCommentRw, | ||
KeyDisabled: PropDisabledRw, | ||
"independent_learning": { | ||
Type: schema.TypeBool, | ||
Optional: true, | ||
Description: "Whether to use shared-VLAN-learning (SVL) or independent-VLAN-learning (IVL).", | ||
DiffSuppressFunc: AlwaysPresentNotUserProvided, | ||
}, | ||
KeyInvalid: PropInvalidRo, | ||
"ports": { | ||
Type: schema.TypeList, | ||
Required: true, | ||
Description: "Interface member list for the respective VLAN.", | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
DiffSuppressFunc: AlwaysPresentNotUserProvided, | ||
}, | ||
}, | ||
"switch": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "Name of the switch for which the respective VLAN entry is intended for.", | ||
}, | ||
"vlan_id": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
Description: "The VLAN ID for certain switch port configurations.", | ||
ValidateFunc: validation.IntBetween(0, 4094), | ||
DiffSuppressFunc: AlwaysPresentNotUserProvided, | ||
}, | ||
} | ||
|
||
return &schema.Resource{ | ||
CreateContext: DefaultCreate(resSchema), | ||
ReadContext: DefaultRead(resSchema), | ||
UpdateContext: DefaultUpdate(resSchema), | ||
DeleteContext: DefaultSystemDelete(resSchema), | ||
|
||
Importer: &schema.ResourceImporter{ | ||
StateContext: schema.ImportStatePassthroughContext, | ||
}, | ||
|
||
Schema: resSchema, | ||
} | ||
} |
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,9 @@ | ||
package routeros | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestAccInterfaceEthernetSwitchVlan_basic(t *testing.T) { | ||
t.Log("Test skipped, The test is skipped, the resource is only available on real hardware.") | ||
} |