Cutsheet trace mode and mismatch alerts
Lint / Python (flake8) (push) Successful in 1m8s
Security / Python Security (bandit) (push) Successful in 56s
Test / Python Tests (pytest) (push) Successful in 43s
Lint / Python (flake8) (pull_request) Successful in 50s
Lint / JS (eslint) (pull_request) Successful in 30s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 55s
Test / Python Tests (pytest) (pull_request) Successful in 50s
Lint / JS (eslint) (push) Successful in 16m17s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Lint / Python (flake8) (push) Successful in 1m8s
Security / Python Security (bandit) (push) Successful in 56s
Test / Python Tests (pytest) (push) Successful in 43s
Lint / Python (flake8) (pull_request) Successful in 50s
Lint / JS (eslint) (pull_request) Successful in 30s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 55s
Test / Python Tests (pytest) (pull_request) Successful in 50s
Lint / JS (eslint) (push) Successful in 16m17s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Trace a cord: pick a panel port, press Start, and unplug the cord at the panel. The page polls a new admin-only endpoint that reads every switch port's state from UniFi (cached 2 s), shows the one port that dropped with a button to record the cable, and confirms when it's plugged back in. Several ports dropping at once, or none within 3 minutes, is explained rather than guessed at. Mismatch alerts: the monitor runs the cutsheet check every poll. Each mismatched installed run (wrong neighbor, no link, missing port, port conflict) keeps one cable_mismatch event on its switch, resolved when fixed, and opens a P4 ticket after cutsheet.mismatch_ticket_hours (default 24, 0 never). Suppressing the switch or port stops the ticket. Also fixes buttons with the hidden attribute still showing, which left a Delete button on the new-cable form. Closes #12 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cd602fdacf
commit
86aa29b378
11 files changed
+446
-1
No files matched your search
+42
@@ -469,3 +469,45 @@ def parse_csv(text: str, items: Dict[str, dict], max_rows: int = 2000) -> Tuple[
|
||||
labels.add(cable['label'].lower())
|
||||
rows.append(cable)
|
||||
return rows, errors
|
||||
|
||||
|
||||
# ── Problems, for the monitor ───────────────────────────────────────────────
|
||||
|
||||
def problems(cables: List[dict], items: Dict[str, dict], switches: dict) -> List[dict]:
|
||||
"""One entry per installed run whose check found a problem.
|
||||
|
||||
A run through a panel is several cables with the same verdict; it is reported
|
||||
once, under the cable on the switch port (the one people look for).
|
||||
Returns [{'key', 'cable_id', 'label', 'switch', 'port', 'verdict', 'detail', 'path'}].
|
||||
"""
|
||||
switches = switches or {}
|
||||
results = evaluate(cables, items, switches)
|
||||
by_id = {c['id']: c for c in cables}
|
||||
seen_runs = set()
|
||||
found = []
|
||||
for cid, r in sorted(results.items()):
|
||||
if r['verdict'] not in PROBLEM_VERDICTS or by_id[cid]['status'] != 'installed':
|
||||
continue
|
||||
run = tuple(sorted(r['path']['cable_ids']))
|
||||
if run in seen_runs and r['verdict'] != 'conflict':
|
||||
continue
|
||||
seen_runs.add(run)
|
||||
hops = r['path']['hops']
|
||||
ends = [n for n in (hops[0], hops[-1]) if n and n[0] in switches]
|
||||
switch_end = ends[0] if ends else _node(by_id[cid], 'a')
|
||||
# Name the run after the cable plugged into the switch, when there is one
|
||||
lead = next((by_id[i] for i in r['path']['cable_ids']
|
||||
if switch_end in (_node(by_id[i], 'a'), _node(by_id[i], 'b'))), by_id[cid])
|
||||
if r['verdict'] == 'conflict':
|
||||
lead = by_id[cid]
|
||||
found.append({
|
||||
'key': f'cable {lead["id"]}',
|
||||
'cable_id': lead['id'],
|
||||
'label': lead.get('label') or f'#{lead["id"]}',
|
||||
'switch': switch_end[0] if switch_end else lead['a_device'],
|
||||
'port': switch_end[1] if switch_end else lead['a_port'],
|
||||
'verdict': r['verdict'],
|
||||
'detail': r['detail'],
|
||||
'path': ' → '.join(describe_node(h) for h in hops if not isinstance(h, int)),
|
||||
})
|
||||
return found
|
||||
Reference in new issue
Block a user