* Add support for port aggregation Fixes #142 * Return `*unifi.Device` from `allocateDevice` * Merge `TestAccDevice_switch_portOverrides` and `TestAccDevice_remove_portOverrides` * Add tests 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()); } } } ``` --------- Co-authored-by: Joshua Spence <josh@spence.com.au>
44 lines
963 B
HCL
44 lines
963 B
HCL
data "unifi_port_profile" "disabled" {
|
|
# look up the built-in disabled port profile
|
|
name = "Disabled"
|
|
}
|
|
|
|
resource "unifi_port_profile" "poe" {
|
|
name = "poe"
|
|
forward = "customize"
|
|
|
|
native_networkconf_id = var.native_network_id
|
|
tagged_networkconf_ids = [
|
|
var.some_vlan_network_id,
|
|
]
|
|
|
|
poe_mode = "auto"
|
|
}
|
|
|
|
resource "unifi_device" "us_24_poe" {
|
|
# optionally specify MAC address to skip manually importing
|
|
# manual import is the safest way to add a device
|
|
mac = "01:23:45:67:89:AB"
|
|
|
|
name = "Switch with POE"
|
|
|
|
port_override {
|
|
number = 1
|
|
name = "port w/ poe"
|
|
port_profile_id = unifi_port_profile.poe.id
|
|
}
|
|
|
|
port_override {
|
|
number = 2
|
|
name = "disabled"
|
|
port_profile_id = data.unifi_port_profile.disabled.id
|
|
}
|
|
|
|
# port aggregation for ports 11 and 12
|
|
port_override {
|
|
number = 11
|
|
op_mode = "aggregate"
|
|
aggregate_num_ports = 2
|
|
}
|
|
}
|