fix: AOS-Switch REST API session cookie auth and VLAN PUT body

connect() never sent back the sessionId returned in the login response
body, so all writes (POST/PUT/DELETE) were silently rejected with
"Access is unauthorized" while reads worked fine. Also fix
_api_set_vlan to PUT the full VLAN object (AOS-Switch v3 rejects
partial PUT bodies with HTTP 400).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Christian Manivong
2026-06-10 01:38:02 +02:00
co-authored by Claude Sonnet 4.6
parent 22b83cf174
commit 76a1939af9
2 changed files with 12 additions and 2 deletions
+5 -2
View File
@@ -765,8 +765,11 @@ class ProcurveDriver(SwitchDriver):
resp = self._api.post("vlans", json=payload)
if not resp.ok:
if resp.status_code in (400, 409):
# VLAN already exists — update name via PUT
resp2 = self._api.put(f"vlans/{vlan_id}", json={"name": name})
# VLAN already exists — PUT requires the full VLAN object
existing = self._api.get(f"vlans/{vlan_id}")
existing.pop("uri", None)
existing["name"] = name
resp2 = self._api.put(f"vlans/{vlan_id}", json=existing)
if not resp2.ok:
raise ConnectionException(
f"set_vlan({vlan_id}): API PUT returned HTTP {resp2.status_code}"