Commit Graph

392 Commits

Author SHA1 Message Date
Paul Tyng
0401ae6913 Add support for port aggregation (#182)
* 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>
2023-03-08 18:02:34 +11:00
dependabot[bot]
ef6aa3bd9b Bump github.com/moby/buildkit from 0.11.2 to 0.11.4 (#343)
Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.11.2 to 0.11.4.
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/compare/v0.11.2...v0.11.4)

---
updated-dependencies:
- dependency-name: github.com/moby/buildkit
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-08 07:31:10 +11:00
dependabot[bot]
88d31f21b1 Bump github.com/testcontainers/testcontainers-go/modules/compose from 0.17.0 to 0.18.0 (#339)
* Bump github.com/testcontainers/testcontainers-go/modules/compose

Bumps [github.com/testcontainers/testcontainers-go/modules/compose](https://github.com/testcontainers/testcontainers-go) from 0.17.0 to 0.18.0.
- [Release notes](https://github.com/testcontainers/testcontainers-go/releases)
- [Commits](https://github.com/testcontainers/testcontainers-go/compare/v0.17.0...v0.18.0)

---
updated-dependencies:
- dependency-name: github.com/testcontainers/testcontainers-go/modules/compose
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix `replace` directives

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Joshua Spence <josh@spence.com.au>
2023-03-06 13:33:41 +11:00
dependabot[bot]
60dd1070fe Bump github.com/testcontainers/testcontainers-go from 0.17.0 to 0.18.0 (#341)
Bumps [github.com/testcontainers/testcontainers-go](https://github.com/testcontainers/testcontainers-go) from 0.17.0 to 0.18.0.
- [Release notes](https://github.com/testcontainers/testcontainers-go/releases)
- [Commits](https://github.com/testcontainers/testcontainers-go/compare/v0.17.0...v0.18.0)

---
updated-dependencies:
- dependency-name: github.com/testcontainers/testcontainers-go
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-06 12:24:20 +11:00
dependabot[bot]
52c193c1ce Bump github.com/deckarep/golang-set/v2 from 2.1.0 to 2.2.0 (#340)
Bumps [github.com/deckarep/golang-set/v2](https://github.com/deckarep/golang-set) from 2.1.0 to 2.2.0.
- [Release notes](https://github.com/deckarep/golang-set/releases)
- [Commits](https://github.com/deckarep/golang-set/compare/v2.1.0...v2.2.0)

---
updated-dependencies:
- dependency-name: github.com/deckarep/golang-set/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-06 12:22:36 +11:00
dependabot[bot]
79e7bbff75 Bump github.com/hashicorp/terraform-plugin-docs from 0.13.0 to 0.14.1 (#332)
Bumps [github.com/hashicorp/terraform-plugin-docs](https://github.com/hashicorp/terraform-plugin-docs) from 0.13.0 to 0.14.1.
- [Release notes](https://github.com/hashicorp/terraform-plugin-docs/releases)
- [Changelog](https://github.com/hashicorp/terraform-plugin-docs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/terraform-plugin-docs/compare/v0.13.0...v0.14.1)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/terraform-plugin-docs
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-06 09:56:47 +11:00
Joshua Spence
0e72ef9deb Revert "Enable $LOTSOFDEVICES (#325)" (#337)
This reverts commit ce6e1a5a6a.
2023-03-05 10:10:30 +11:00
Joshua Spence
9367e123fe Dump controller logs after acceptance tests (#335)
* Dump logs

* Incrase log verbosity

* Fix lint

* Add `LogConsumer`

* Revert "Add `LogConsumer`"

This reverts commit eba91831e11fd8b38343d14363fe553a3591377b.

* Tidying

* Minor tidying

* Conditional guard

* Minor

* Fix

* Fix

* Dump logs in CI
2023-03-04 00:09:50 +11:00
Joshua Spence
c713a22aa6 Don't use USW-Leaf in acceptance tests (#336)
The USW-Leaf consistently fails to be adopted:

```
[2023-03-03T04:25:11,002] XXX <fake-UDC48X6> ERROR inform - dev[00:27:22:00:00:12] failed to update capability: api.err.InvalidReportPort
[2023-03-03T04:25:21,004] XXX <fake-UDC48X6> ERROR inform - dev[00:27:22:00:00:12] failed to update capability: api.err.InvalidReportPort
[2023-03-03T04:25:31,005] XXX <fake-UDC48X6> ERROR inform - dev[00:27:22:00:00:12] failed to update capability: api.err.InvalidReportPort
[2023-03-03T04:25:41,006] XXX <fake-UDC48X6> ERROR inform - dev[00:27:22:00:00:12] failed to update capability: api.err.InvalidReportPort
```
2023-03-03 17:11:32 +11:00
dependabot[bot]
887ef59368 Bump github.com/containerd/containerd from 1.6.12 to 1.6.18 (#334)
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.6.12 to 1.6.18.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.6.12...v1.6.18)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-03 16:39:55 +11:00
Joshua Spence
b27b54a755 Use testcontainers-go (#330)
* Use `testcontainers-go`

* Wait for ready

* Sleep

* Remove `time.Sleep`

* Wait until devices appear

* Pass environment

* Add `golangci-lint` to tools

* Minor
2023-03-03 15:19:19 +11:00
Joshua Spence
284c42aaae Improve device allocation (#333)
* Improve device allocation

* Improve

* Tweak MAC code

* Add `golangci-lint` to tools

* Debugging

* Revert "Debugging"

This reverts commit 90c0b054256e9a741193854dc6b5984f6e749a9a.

* Use `golang-set`

* Remove `sync.Mutex`

* Cleanup
2023-03-03 14:05:09 +11:00
Joshua Spence
cecd408e57 Migrate to terraform-plugin-testing (#331)
See https://developer.hashicorp.com/terraform/plugin/testing/migrating.
2023-03-03 09:04:31 +11:00
Chris Hasenpflug
8bfcf5b503 firewall_rule: Add enabled attribute (#63)
* firewall_rule: Add enabled attribute

Resolves #62

* Add tests

* Update docs

---------

Co-authored-by: Joshua Spence <josh@spence.com.au>
2023-03-02 20:06:04 +11:00
Joshua Spence
17ed6d8258 Revert "Bump github.com/hashicorp/terraform-plugin-docs from 0.13.0 to 0.14.0 (#324)" (#327)
This reverts commit 7f01dd296a.
2023-03-01 17:23:18 +11:00
dependabot[bot]
7f01dd296a Bump github.com/hashicorp/terraform-plugin-docs from 0.13.0 to 0.14.0 (#324)
Bumps [github.com/hashicorp/terraform-plugin-docs](https://github.com/hashicorp/terraform-plugin-docs) from 0.13.0 to 0.14.0.
- [Release notes](https://github.com/hashicorp/terraform-plugin-docs/releases)
- [Changelog](https://github.com/hashicorp/terraform-plugin-docs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/terraform-plugin-docs/compare/v0.13.0...v0.14.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/terraform-plugin-docs
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-01 13:05:23 +11:00
Joshua Spence
f0ee3cbbfa Lower the device retry timeouts (#322)
* Lower the device retry timeouts

* Add debug logging

* Revert "Add debug logging"

This reverts commit 209da04dd9cee2e826724f27ea4602cdc9414015.

* Tweak timeouts
2023-03-01 13:04:40 +11:00
Joshua Spence
ce6e1a5a6a Enable $LOTSOFDEVICES (#325)
From https://hub.docker.com/r/jacobalberty/unifi:

> Enable this with `true` if you run a system with a lot of devices and/or with a low powered system (like a Raspberry Pi). This makes a few adjustments to try and improve performance:
>
> - enable `unifi.G1GC.enabled`
> - set `unifi.xms` to `JVM_INIT_HEAP_SIZE`
> - set `unifi.xmx` to `JVM_MAX_HEAP_SIZE`
> - enable `unifi.db.nojournal`
> - set `unifi.dg.extraargs` to `--quiet`

See also https://help.ui.com/hc/en-us/articles/115005159588-UniFi-How-to-Tune-the-Network-Application-for-High-Number-of-UniFi-Devices.
2023-03-01 13:03:29 +11:00
Joshua Spence
263a2c71d2 Remove UNIFI_ACC_WLAN_CONCURRENCY (#323)
* Remove `UNIFI_ACC_WLAN_CONCURRENCY`

* Update resource_wlan_test.go

* Update resource_wlan_test.go
2023-03-01 10:44:11 +11:00
Joshua Spence
6420a08e58 Limit number of demo devices (#321)
We currently only need switches for the acceptance tests, so don't provision any access points or gateways.
2023-03-01 09:56:30 +11:00
Joshua Spence
d02faeb871 Use default demo credentials (#320) 2023-03-01 00:22:09 +11:00
Joshua Spence
d3147cf83c Allow 10 minutes for device adoption (#318) 2023-02-28 22:40:58 +11:00
Joshua Spence
2eba55a7f3 Change default value for allow_adoption (#317)
* Change default value for `allow_adoption`

* Update docs
2023-02-28 22:19:22 +11:00
Joshua Spence
5cc1679b7f Tidying 2023-02-28 21:52:07 +11:00
Joshua Spence
c0a2d0e07b Skip PDUs 2023-02-28 21:52:07 +11:00
Joshua Spence
b5a1680cd9 Revert "Remove debug code"
This reverts commit 4f768d67c08ae476033bfc59d428c14f6cd0435d.
2023-02-28 21:52:07 +11:00
Joshua Spence
c3b52a2191 Temp 2023-02-28 21:52:07 +11:00
Joshua Spence
5becf45299 Remove debug code 2023-02-28 21:52:07 +11:00
Joshua Spence
6a337ed666 Add another USP-RPS model 2023-02-28 21:52:07 +11:00
Joshua Spence
8264d9f30b Add temporary debug code 2023-02-28 21:52:07 +11:00
Joshua Spence
592bc6267f Don't use the USP-RPS as a test device
The [USP-RPS](https://store.ui.com/products/usp-rps) is a "switch" (has `usw` type) but it doesn't have ports and so the port override tests will fail. Just ignore these devices.
2023-02-28 21:52:07 +11:00
Joshua Spence
8b28a7d42e Allow device timeouts to be customized 2023-02-28 16:47:22 +11:00
Joshua Spence
c52cc13660 Wait for updates to propagate to devices 2023-02-28 16:47:22 +11:00
Joshua Spence
a83f9b3dbd Ensure the same MAC address isn't reused 2023-02-28 16:47:22 +11:00
Joshua Spence
8f0cd30efc Consider "unknown" and "upgrading" to be valid pending states 2023-02-28 16:47:22 +11:00
Joshua Spence
c3be14dc13 Allow five minutes for device adoption 2023-02-28 16:47:22 +11:00
Michon van Dooren
05df488c3b Add test clearing device portoverrides (#313)
* Add test clearing device portoverrides

* Update `go-unifi`

---------

Co-authored-by: Joshua Spence <josh@spence.com.au>
2023-02-28 11:54:15 +11:00
Joshua Spence
aa9f778363 Ensure subsystem logger has been created (#314) 2023-02-28 11:38:54 +11:00
Christian Winther
7296c9d730 unifi_port_forward enabled should default to true (#258)
Fixes https://github.com/paultyng/terraform-provider-unifi/issues/255
2023-02-28 08:29:54 +11:00
Joshua Spence
b3662a627f Fix network mDNS acceptance tests (#311)
* Make compatible with `getTestVLAN`

* Run `go generate`
2023-02-25 10:18:49 +11:00
Xabier Larrakoetxea Gallego
dc95eceb2e Add support for mDNS on network resource (#292)
* Add support for mDNS on network resource

Signed-off-by: Xabier Larrakoetxea <me@slok.dev>

* Add mDSN network tests

Signed-off-by: Xabier Larrakoetxea <me@slok.dev>

---------

Signed-off-by: Xabier Larrakoetxea <me@slok.dev>
2023-02-25 10:05:48 +11:00
Joshua Spence
81c357b3a5 Improve test stability (#310)
* Improve stability of network/wlan tests

* Improve stability of user tests

* Don't test with different Terraform versions
2023-02-24 18:04:56 +11:00
dependabot[bot]
8e3b620881 bump golang.org/x/net from 0.6.0 to 0.7.0 (#308)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.6.0 to 0.7.0.
- [Release notes](https://github.com/golang/net/releases)
- [Commits](https://github.com/golang/net/compare/v0.6.0...v0.7.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-24 16:51:19 +11:00
Joshua Spence
066163a22c Allow device adoption (#188)
* Allow device adoption

* Handling disappearing device

* Allocate test devices dynamically

* Increase `NotFoundChecks`

* Demo devices don't seem to have sequential MACs

* Change default for `forget_on_destroy`

* Minor
2023-02-24 10:42:06 +11:00
Michon van Dooren
7eadb9ba08 Expose source port of firewall rules (#305)
* Expose source port of firewall rules

* Add tests

---------

Co-authored-by: Joshua Spence <josh@spence.com.au>
2023-02-23 15:55:08 +11:00
Joshua Spence
cecb61809d Update versions (#309) 2023-02-23 15:10:37 +11:00
Michon van Dooren
b5e936c724 Set default wlan band to 'both' (#304) 2023-02-23 14:50:29 +11:00
dependabot[bot]
ecbf8743b8 Bump github.com/hashicorp/terraform-plugin-sdk/v2 from 2.24.1 to 2.25.0 (#307)
Bumps [github.com/hashicorp/terraform-plugin-sdk/v2](https://github.com/hashicorp/terraform-plugin-sdk) from 2.24.1 to 2.25.0.
- [Release notes](https://github.com/hashicorp/terraform-plugin-sdk/releases)
- [Changelog](https://github.com/hashicorp/terraform-plugin-sdk/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/terraform-plugin-sdk/compare/v2.24.1...v2.25.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/terraform-plugin-sdk/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-16 12:28:20 +11:00
dependabot[bot]
13bb3e9fd2 Bump golangci/golangci-lint-action from 3.3.1 to 3.4.0 (#300)
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.3.1 to 3.4.0.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v3.3.1...v3.4.0)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-11 15:03:53 +11:00
dependabot[bot]
503f49112b Bump goreleaser/goreleaser-action from 4.1.0 to 4.2.0 (#302)
Bumps [goreleaser/goreleaser-action](https://github.com/goreleaser/goreleaser-action) from 4.1.0 to 4.2.0.
- [Release notes](https://github.com/goreleaser/goreleaser-action/releases)
- [Commits](https://github.com/goreleaser/goreleaser-action/compare/v4.1.0...v4.2.0)

---
updated-dependencies:
- dependency-name: goreleaser/goreleaser-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-11 14:50:31 +11:00