Commit Graph

22 Commits

Author SHA1 Message Date
Mateusz Filipowicz
f5bd8ebb15 feat: switch to filipowm/go-unifi UniFi SDK client (#20)
* feat: switch to filipowm/go-unifi UniFi SDK client

* disable validation in tests

* replace usage of APIError by ServerError

* bump go-unifi to 1.4.0
2025-02-23 17:07:03 +01:00
Mateusz Filipowicz
b19314bc6e use filipowm/go-unifi instead of paultyng/go-unifi 2025-02-07 01:09:36 +01:00
dependabot[bot]
d79cc47b12 Bump golangci/golangci-lint-action from 3.7.1 to 6.0.1 (#458)
* Bump golangci/golangci-lint-action from 3.7.1 to 6.0.1

Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.7.1 to 6.0.1.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v3.7.1...v6.0.1)

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

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

* Go format

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Josh Spence <jspence@anduril.com>
2024-11-22 11:29:06 +11:00
David Symonds
2e6f384294 Support per-port PoE mode override for devices. (#393) 2023-09-08 15:23:43 +10:00
dependabot[bot]
3879e88f7a Bump github.com/hashicorp/terraform-plugin-sdk/v2 from 2.25.0 to 2.26.0 (#353)
* Bump github.com/hashicorp/terraform-plugin-sdk/v2 from 2.25.0 to 2.26.0

Bumps [github.com/hashicorp/terraform-plugin-sdk/v2](https://github.com/hashicorp/terraform-plugin-sdk) from 2.25.0 to 2.26.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.25.0...v2.26.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>

* Address deprecations

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Joshua Spence <josh@spence.com.au>
2023-03-22 10:43:31 +11:00
Joshua Spence
105d542879 Add DiffSuppressFunc for op_mode and aggregate_num_ports (#344) 2023-03-08 22:27:58 +11:00
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
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
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
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
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
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
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
Paul Tyng
5e428a4605 Fix some linting issues 2021-08-27 09:59:30 -04:00
Paul Tyng
ef03fd62be Fix %w usage in diags 2021-08-10 10:30:26 -04:00
Michael Wiesenbauer
4c36a8af1b move from deprecated CRUD functions to context aware CRUD 2021-08-10 10:30:26 -04:00
Paul Tyng
118f612b49 Modify device a little to allow creation, add basic testing 2021-03-27 16:58:23 -04:00
Paul Tyng
0b9b01940d Remove custom port override hashing for now 2021-03-22 09:40:30 -04:00
wolf-cosmose
051ed9875e Add rudimentary support for resource unifi_device (#112) 2021-03-20 22:38:32 -04:00