Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for interface/ethernet/switch/* #325

Closed
durandguru opened this issue Dec 26, 2023 · 8 comments · Fixed by #338 or #340
Closed

Add support for interface/ethernet/switch/* #325

durandguru opened this issue Dec 26, 2023 · 8 comments · Fixed by #338 or #340
Assignees
Labels
enhancement New feature or request released

Comments

@durandguru
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Could you add support for the following:?
interface/ethernet/switch/host
interface/ethernet/switch/port
interface/ethernet/switch/port-isolation
interface/ethernet/switch/rule
interface/ethernet/switch/vlan

Describe the solution you'd like
interface/ethernet/switch/port and interface/ethernet/switch/vlan are needed to hardware offload switching on some models

Additional context
interface/ethernet/switch is already implemented

@vaerh
Copy link
Collaborator

vaerh commented Jan 15, 2024

🎉 This issue has been resolved in version 1.32.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@vaerh vaerh added the released label Jan 15, 2024
@durandguru
Copy link
Contributor Author

Thanks for creating the code! I'm testing it and when i create an switch vlan everything is working. Removing the switch vlan. the provider sees it as an system object and only deletes it from the state and not from routeros.

Create:
resource "routeros_interface_ethernet_switch_vlan" "vlan_55" {
switch = "switch1"
ports = ["ether1", "switch1-cpu"]
vlan_id = 55
}

Remove:
routeros_interface_ethernet_switch_vlan.vlan_55: Destroying... [id=*7]
routeros_interface_ethernet_switch_vlan.vlan_55: Destruction complete after 0s

│ Warning: Delete operation on a system object.

│ This resource contains system settings and cannot be deleted or reset. This action will remove the object from the Terraform state. See also: 'terraform state rm'
https://developer.hashicorp.com/terraform/cli/commands/state/rm

@vaerh
Copy link
Collaborator

vaerh commented Jan 16, 2024

🎉 This issue has been resolved in version 1.32.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@vaerh
Copy link
Collaborator

vaerh commented Jan 16, 2024

I made a mistake with the deletion procedure. In the new release everything should be deleted normally. Unfortunately I didn't have time to fully test everything, so please write me if you have any errors. Creating rules was not tested at all, because the test router does not support it.

@durandguru
Copy link
Contributor Author

routeros_interface_ethernet_switch_vlan is now working fine.

routeros_interface_ethernet_switch_port_isolation creation is fine. Delete does not return the value as before. In this case setting on ether5 a override. Deletion in terraform only removes from state. leaves the value for the override to ether5
resource "routeros_interface_ethernet_switch_port_isolation" "test" {
name = "ether5"
forwarding_override = "ether5"
}

For routeros_interface_ethernet_switch_host gives error about vlanid. Default in winbox is 0. Creation with the option vlan_id = "0" works without an problem. Also for this deletion does not work because of error about Delete operation on a system object. And this is an user created object.
resource "routeros_interface_ethernet_switch_host" "test" {
switch = "switch1"
mac_address = "01:01:01:01:01:01"
ports = ["ether5"]
mirror = true
}

Error: strconv.Atoi: parsing "auto": invalid syntax for 'vlan_id' field

│ with routeros_interface_ethernet_switch_host.test,
│ on test.tf line 6, in resource "routeros_interface_ethernet_switch_host" "test":
│ 6: resource "routeros_interface_ethernet_switch_host" "test" {

@durandguru
Copy link
Contributor Author

durandguru commented Jan 17, 2024

For routeros_interface_ethernet_switch_rule ports must be string: And should be list. And also error about system object for deletion, this also an user object.
resource "routeros_interface_ethernet_switch_rule" "test" {
switch = "switch1"
ports = ["ether1"]
copy_to_cpu = true
}

Gives :
Error: Incorrect attribute value type

│ on test.tf line 16, in resource "routeros_interface_ethernet_switch_rule" "test":
│ 16: ports = ["ether5"]

│ Inappropriate value for attribute "ports": string required.

After apply and missing field:
│ Warning: Field 'dynamic' not found in the schema

│ with routeros_interface_ethernet_switch_rule.test,
│ on test.tf line 14, in resource "routeros_interface_ethernet_switch_rule" "test":
│ 14: resource "routeros_interface_ethernet_switch_rule" "test" {

│ [MikrotikResourceDataToTerraform] The field was lost during the Schema development: ▷ 'dynamic': 'false' ◁

@vaerh vaerh reopened this Jan 19, 2024
@vaerh
Copy link
Collaborator

vaerh commented Jan 19, 2024

I've fixed the bugs, I'll put out a new release now. Please test it.
For routeros_interface_ethernet_switch_port_isolation this is a typical behavior, because it is not possible to delete ports or to reset them to their original state (because it is not known what it was).

vaerh added a commit that referenced this issue Jan 19, 2024
vaerh added a commit that referenced this issue Jan 19, 2024
@vaerh
Copy link
Collaborator

vaerh commented Jan 19, 2024

🎉 This issue has been resolved in version 1.32.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
2 participants