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

Disable defunct WLAN schedule not found #263

Open
mrMoe opened this issue Aug 7, 2022 · 4 comments · Fixed by #284
Open

Disable defunct WLAN schedule not found #263

mrMoe opened this issue Aug 7, 2022 · 4 comments · Fixed by #284

Comments

@mrMoe
Copy link

mrMoe commented Aug 7, 2022

Hi,

during importing my current config into terraform I played around with the WLAN schedule function since one of my networks has a schedule to be disabled in the night.

The enabling of the schedule in terraform was no problem

resource "unifi_wlan" "temp" {
  name         = "temp"
  l2_isolation = true
  no2ghz_oui   = false
  passphrase   = "password"
  pmf_mode     = "optional"
  security     = "wpapsk"
  uapsd        = false
  wlan_band    = "both"

  network_id    = unifi_network.temp.id
  ap_group_ids  = [data.unifi_ap_group.default.id]
  user_group_id = data.unifi_user_group.default.id

  schedule {
    day_of_week = "mon"
    block_start = "08:00"
    block_end   = "20:00"
  }
}

but it didn't activate in the UI.
And if I add a schedule to the temp WLAN in the UnifiController then terraform does not recognize the resource has changed in any way.

Thus I removed the schedule from the temp WLAN but now I get

Terraform will perform the following actions:

  # unifi_wlan.temp will be updated in-place
  ~ resource "unifi_wlan" "temp" {
        id                        = "123456789"
        name                      = "temp"
        # (21 unchanged attributes hidden)

      - schedule {
          - block_end   = "20:00" -> null
          - block_start = "8:00" -> null
          - day_of_week = "mon" -> null
        }
    }

Plan: 0 to add, 1 to change, 0 to destroy.
unifi_wlan.temp: Modifying... [id=123456789]
╷
│ Error: not found
│ 
│   with unifi_wlan.temp,
│   on main.tf line 108, in resource "unifi_wlan" "temp":
│  108: resource "unifi_wlan" "temp" { 

So it seems I can't remove the schedule anymore.

Another thing I noticed looking at the API requests that there are two different fields schedule and schedule_with_duration. The schedule has the terraform values but does not work and the schedule_with_duration has the values set in the Controller and work but are not available in terraform. It seems, there is a field and type missmatch in the library.

{
    "_id": "1234",
    "ap_group_ids": [
        "1234"
    ],
    "setting_preference": "manual",
    "name": "temp",
    "networkconf_id": "1234",
    "x_passphrase": "password",
    "site_id": "1234",
    "bss_transition": false,
    "dtim_mode": "default",
    "dtim_6e": 3,
    "dtim_na": 3,
    "dtim_ng": 1,
    "enabled": true,
    "fast_roaming_enabled": false,
    "group_rekey": 3600,
    "hide_ssid": false,
    "is_guest": false,
    "l2_isolation": true,
    "b_supported": false,
    "mac_filter_enabled": false,
    "mac_filter_list": [],
    "mac_filter_policy": "deny",
    "mcastenhance_enabled": false,
    "minrate_setting_preference": "auto",
    "minrate_na_enabled": false,
    "minrate_na_advertising_rates": false,
    "minrate_na_data_rate_kbps": 6000,
    "minrate_ng_enabled": false,
    "minrate_ng_advertising_rates": false,
    "minrate_ng_data_rate_kbps": 1000,
    "no2ghz_oui": false,
    "wpa_enc": "ccmp",
    "pmf_mode": "optional",
    "proxy_arp": false,
    "radius_das_enabled": false,
    "radius_mac_auth_enabled": false,
    "radius_macacl_format": "none_lower",
    "security": "wpapsk",
    "uapsd_enabled": false,
    "wlan_bands": [
        "2g",
        "5g"
    ],
    "wpa3_enhanced_192": false,
    "wpa3_fast_roaming": false,
    "wpa3_support": false,
    "wpa3_transition": false,
    "wpa_mode": "wpa2",
    "usergroup_id": "1234",
    "iapp_enabled": false,
    "x_iapp_key": "1234",
    "wlan_band": "both",
    "bc_filter_list": [],
    "sae_groups": [],
    "sae_psk": [],
    "schedule": [
        "mon|0800-2000"
    ],
    "schedule_with_duration": [
        {
            "name": "good night",
            "start_days_of_week": [
                "mon",
                "tue",
                "wed",
                "thu",
                "fri",
                "sat",
                "sun"
            ],
            "start_hour": 23,
            "start_minute": 0,
            "duration_minutes": 480
        }
    ],
    "name_combine_enabled": true,
    "p2p": false,
    "p2p_cross_connect": false,
    "radius_macacl_empty_password": false,
    "rrm_enabled": false,
    "tdls_prohibit": false,
    "vlan_enabled": false,
    "auth_cache": false,
    "bc_filter_enabled": false,
    "country_beacon": false,
    "dpi_enabled": false,
    "element_adopt": false,
    "dpigroup_id": "",
    "hotspot2conf_enabled": false,
    "hotspot2conf_id": "",
    "optimize_iot_wifi_connectivity": false,
    "radius_filter_id_enabled": false,
    "radiusprofile_id": "",
    "sae_psk_vlan_required": false,
    "schedule_enabled": false,
    "schedule_reversed": false
}

As controller I use the docker container from jacobalberty/unifi in version 7.1.66.

Hope you can help to sort this one out

@paultyng
Copy link
Owner

paultyng commented Oct 23, 2022

The WLAN schedule support dates back to v5 of the controller so not surprising that they have introduced some new UI features and API types now, it probably needs to be updated to use that new API field you noticed. I'll see about poking around with this over the weekend and see what I can find.

@paultyng
Copy link
Owner

#284 has an initial implementation. The tests seem to work and it handles deletions as well (I added a test for that). It is breaking unfortunately to support the new API field format so just thinking about it a bit more prior to merging it.

@paultyng paultyng linked a pull request Oct 23, 2022 that will close this issue
@mrMoe
Copy link
Author

mrMoe commented Oct 23, 2022

Hi Paul. Thanks for your support! I can confirm the change set the schedule of the wlan and after a refresh of the page I find the schedule_with_duration in the wlanconf response of the webserver but the UI does not show the schedule. So it seems, that something is still missing.

@paultyng
Copy link
Owner

Hmm ok let me investigate further, I'll reopen this for now.

@paultyng paultyng reopened this Oct 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants