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
+7
View File
@@ -127,6 +127,13 @@ class ProcurveApiClient:
raise ConnectAuthError(
f"REST API login failed (HTTP {resp.status_code}) for {self.hostname}"
)
# AOS-Switch returns the session cookie in the JSON body rather than
# via Set-Cookie — it must be sent back as a Cookie header on every
# subsequent request, otherwise writes (POST/PUT/DELETE) are rejected
# with "Access is unauthorized" while reads still succeed.
cookie = resp.json().get("cookie")
if cookie:
self._session.headers.update({"Cookie": cookie})
logger.debug("REST API login OK for %s", self.hostname)
def setup(self, api_version: str, proto: str) -> None: