Skip to content

SDK-363: Add edge.stats via HTTP Relay channel for device metrics#352

Open
asafn-ctera wants to merge 1 commit into
masterfrom
SDK-363-relay-cttp-stats
Open

SDK-363: Add edge.stats via HTTP Relay channel for device metrics#352
asafn-ctera wants to merge 1 commit into
masterfrom
SDK-363-relay-cttp-stats

Conversation

@asafn-ctera
Copy link
Copy Markdown
Contributor

@asafn-ctera asafn-ctera commented May 14, 2026

Summary

  • Adds edge.stats.get(stat_type, interval) for fetching device metrics remotely through the portal
  • Uses the HTTP Relay channel (/devices/<name>/) instead of the Binary API channel (/devicecmdnew/) — the relay forwards full raw HTTP including cookies, which the device-side gw-api-handler requires for auth after firmware upgrades
  • SSO-based authentication to the device through the relay tunnel (same mechanism as edge.remote_access())
  • No portal or gateway code changes required

Changes

File Change
cterasdk/edge/stats.py NewStats command class with get() and lazy SSO-based _ensure_session()
cterasdk/edge/__init__.py Add stats to __all__
cterasdk/objects/synchronous/edge.py Wire relay client (lazy init) + edge.stats property
tests/ut/edge/test_stats.py New — 11 unit tests

Background

After filer firmware upgrades (ESC-10493), the device metrics API (gw-api-handler) requires cookie-based session auth (_cteraSessionId_). The SDK was routing requests through the Binary API CTTP channel which serializes requests into a binary struct carrying only method + URI — cookies cannot be represented. The HTTP Relay channel (/devices/<name>/), already used by the Device UI for browser-based remote access, forwards raw HTTP end-to-end including cookies.

Usage

portal = GlobalAdmin('portal.example.com')
portal.login('admin', 'password')

edge = portal.devices.device('my-filer')
cpu = edge.stats.get('cpu', interval='day')
mem = edge.stats.get('memory', interval='week')

Test plan

  • All 11 new unit tests pass
  • All 346 existing edge unit tests pass (zero regressions)
  • All 16 core remote/devices tests pass
  • Manual validation against a portal with an upgraded filer (ESC-10493 scenario)

Ref: SDK-363 | ESC-10493

After filer firmware upgrades, the device-side metrics API (gw-api-handler)
requires cookie-based session auth (_cteraSessionId_). The existing binary
API channel (/devicecmdnew/) cannot carry HTTP headers by design, so auth
always fails.

This adds a new Stats command class that uses the portal's HTTP Relay
channel (/devices/<name>/) — the same tunnel the Device UI uses — which
forwards full raw HTTP including cookies end-to-end.

- New cterasdk/edge/stats.py: Stats class with get() for all stat types
  and intervals, lazy SSO-based device authentication via the relay tunnel
- Wire relay client in Clients.__init__ with lazy initialization (device
  name is only available after remote_command populates __dict__)
- Expose edge.stats property on the Edge object (None for local edges)
- 11 unit tests covering validation, SSO flow, and session reuse

Ref: ESC-10493
Co-authored-by: Cursor <cursoragent@cursor.com>
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 this pull request may close these issues.

1 participant