-
-
Notifications
You must be signed in to change notification settings - Fork 89
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 port aggregation #182
Conversation
Unsure how to test this, need to see if its possible without adopting a device or if it needs one to run against. |
5cac5f0
to
4446ef0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't need to be a part of this PR, but I think we should add acceptance test coverage that is opt-in with an environment variable to run against real hardware. Something like UNIFI_SWITCH=<MAC_ADDRESS>
.
ValidateFunc: validation.StringInSlice([]string{"switch", "mirror", "aggregate"}, false), | ||
// Default: "switch", | ||
}, | ||
"aggregate_num_ports": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add validation to make sure this is only set if op_mode
is set to aggregate
?
Is there an easy way to test this in combination with gitlab-terraform images? I built the plugin and simply replaced the cached one in .terraform/providers/registry.terraform.io/paultyng/unifi/0.34.0/linux_amd64/terraform-provider-unifi_v0.34.0 but on the next run of gitlab-terraform plan it gets replaced with a pristine copy from the registry... The change itself looks good when I compare it to the JSON returned when configuring a LAG. Maybe add some validation, like aggregate_num_ports must be set to use op_mode=aggregate. Or that there is no port_override for port 12 if there is a 2-port-LAG on port 11. |
I managed to test it locally, appears to be working.
|
I'm using this branch successfully in homelab-production. But I'd love to return to the released version. What is still needed before merging it? |
👋 Is planned to be merged at any point? Would very much like to be able to configure this :D |
@paultyng Anything else blocking this from being merged? |
4446ef0
to
9fdca69
Compare
Note that only switches with a Broadcom, Microsemi or Nephos chipset support both port mirroring and port aggregation. ```java package com.ubnt.data; public class Device extends X implements Sanitizable { // ... public int getMaxMirrorSession() { int n = 0; if (this.getModel() == Model.\u00f8\u00f50000) { n = 2; } else if (this.isBroadcomSwitch() || this.isMicrosemiSwitch() || this.isMediaTekSwitch() || this.isNephosSwitch()) { n = 1; } return this.thisforObject().getInt("max_mirror_sessions", n); } public int getMaxAggregation() { int n = 0; if (this.isBroadcomSwitch() || this.isMicrosemiSwitch() || this.isNephosSwitch()) { n = 6; } return this.thisforObject().getInt("max_aggregate_sessions", n); } // ... public boolean isBroadcomSwitch() { final Model model = this.getModel(); return model.getChipset().typeOf(Chipset.\u00f400000) && model.getType() == DeviceType.if; } public boolean isMicrosemiSwitch() { final Model model = this.getModel(); return model.getChipset().typeOf(Chipset.o00000) && model.getType() == DeviceType.if; } public boolean isMediaTekSwitch() { final Model model = this.getModel(); return model.getChipset().typeOf(Chipset.\u00d3O0000) && model.getType() == DeviceType.if; } public boolean isNephosSwitch() { final Model model = this.getModel(); return model.getChipset().typeOf(Chipset.\u00d5O0000) && model.getType() == DeviceType.if; } // ... } ``` To extract the list of models that use one of these chipsets I used the following script (executed as `java --class-path path/to/ace.jar main.java`): ```java import com.ubnt.data.Model; class UniFiModels { public static void main(String[] args) { /* for (Model model : Model.values()) { System.out.printf( "Model = %s\nSKU = %s\nType = %s\nFeatures = %s\nChipset = %s\nSysId = %s\nPortNum = %s\n\n", model, model.getSku(), model.getType(), model.getFeatures(), model.getChipset(), model.getSysId(), model.getPortNum()); } */ for (Model model : Model.values()) { System.out.printf("%s: %s (%s)\n", model.getChipset(), model, model.getSku()); } } } ```
9fdca69
to
431a234
Compare
@dekarl @szinn @CarbonCollins I've added test coverage and merged this now. Please feel free to test it out and report any issues you find. I will test it myself and make a new release in the next few days |
Fixes #142