collabSupport/services/voiceDiag/checks/wan/wanSite.js
jmcqueen b802383441 Add Prisma SD-WAN voice-quality enrichment for /phonestatus + /voicediag
Introduces a full Palo Alto Prisma SD-WAN integration (dual-mode SASE
OAuth 2.0 / legacy CloudGenix auth, pagination, 429 backoff, session
priming) that surfaces per-path latency/jitter/loss/MOS, site
healthscore, link state, and alarm data for a store. Wired into the
/phonestatus WAN follow-up and eight new /voicediag WAN checks graded
against ITU-T G.114 / RFC 3550 defaults (env-overridable via
WAN_STANDARD_*).

Also adds a shape-aware detail renderer for /voicediag (per-link
tables with verdict icons instead of a stringified JSON dump) and a
--window flag (15m / 1h / 6h / 24h / 1d, env default via
WAN_STANDARD_WINDOW_MINUTES) so operators can widen the look-back
without redeploying. scripts/prismaProbe.js is bundled as a CLI for
schema iteration against a live tenant.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-09 09:45:29 -04:00

57 lines
2 KiB
JavaScript

// src/services/voiceDiag/checks/wan/wanSite.js
//
// Info-only anchor check for the WAN bucket. Confirms which Prisma
// SD-WAN site the store resolved to and how many appliances /
// links we're seeing. Doesn't grade anything — its whole purpose is
// to give the operator context ("yes we found the site; here's what
// we're seeing") before the per-signal checks below start emitting
// warn/error verdicts.
//
// Skipped when no Prisma site was matched — the runner shows that
// as `skipped: not applicable — missing sdwanSite`, which is more
// honest than a hard-coded "we couldn't reach Prisma" error
// because there are two genuine reasons the site is null: (1)
// this store isn't Prisma-managed at all, or (2) the Prisma
// integration is misconfigured. buildContext() logs which one it
// was.
import { maybeSkippedByKillSwitch } from './_helpers.js';
export const WAN_SITE_STANDARDS = Object.freeze({
// No thresholds — this is a discovery/context check.
requiresPrismaSite: true,
});
export const wanSiteCheck = {
id: 'wanSite',
label: 'SD-WAN Site Discovery',
requires: ['sdwanSite'],
scope: null,
standards: WAN_SITE_STANDARDS,
async run(ctx) {
const skip = maybeSkippedByKillSwitch(wanSiteCheck);
if (skip) return skip;
const site = ctx.sdwanSite;
const elements = Array.isArray(ctx.sdwanData?.elements) ? ctx.sdwanData.elements : [];
const links = Array.isArray(ctx.sdwanData?.links) ? ctx.sdwanData.links : [];
const connectedCount = elements.filter((e) => e.connected).length;
return {
status: 'ok',
message:
`Site **${site.name}** (${elements.length} element${elements.length === 1 ? '' : 's'}, ` +
`${connectedCount} connected) with ${links.length} WAN path${links.length === 1 ? '' : 's'}.`,
details: {
siteId: site.id,
siteName: site.name,
elementCount: elements.length,
connectedElementCount: connectedCount,
linkCount: links.length,
},
remediation: null,
};
},
};