MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / get_hardware_profiles

Function get_hardware_profiles

webapp_modern.py:5258–5411  ·  view source on GitHub ↗

Get predefined hardware profiles for different Raspberry Pi models

()

Source from the content-addressed store, hash-verified

5256 if payload.get('reachable'):
5257 fresh[peer['id']] = {
5258 'findings': payload.get('findings') or [],
5259 'counts': payload.get('counts') or {},
5260 'features': payload.get('features') or {},
5261 }
5262 with _mesh_lock:
5263 _mesh_peer_findings.clear()
5264 _mesh_peer_findings.update(fresh)
5265
5266
5267def _mesh_ingest_peer_alerts(peers, health, timeout):
5268 """Pull peers' Watchtower alerts into this unit's incident engine.
5269
5270 This is the part Tailscale's console cannot do: the same actor probing two
5271 sites is one campaign, and only something that sees both alert streams can
5272 say so. Every unit does this independently — each holds its own correlated
5273 view of the whole mesh, so there is no collector whose loss blinds everyone.
5274 Alerts are ingested under the peer's unit name as a scope, so site-local
5275 addresses stay separated while public IPs and MACs still fuse across sites
5276 (see incident_engine.extract_entities).
5277 """
5278 try:
5279 limit = max(1, min(500, int(shared_data.config.get('mesh_alert_limit', 50))))
5280 except (TypeError, ValueError):
5281 limit = 50
5282 port = _mesh_node_port()
5283
5284 for peer in peers:
5285 if not (health.get(peer['id']) or {}).get('reachable'):
5286 continue # unreachable peers were already counted as degraded
5287 payload = mesh_manager.poll_peer(peer, port=port, timeout=timeout,
5288 path=f'/api/mesh/alerts?limit={limit}')
5289 if not payload.get('reachable'):
5290 continue
5291 scope = payload.get('node') or peer.get('short_name') or peer['id']
5292 alerts = payload.get('alerts') or []
5293 if not alerts:
5294 continue
5295
5296 # Only ingest what we have not already folded in. Peers serve a rolling
5297 # window, so every poll re-sends alerts we saw last cycle; without this
5298 # the same event would inflate an incident's alert count on every tick.
5299 seen = _mesh_alert_seen.setdefault(scope, set())
5300 fresh = []
5301 for alert in alerts:
5302 key = alert.get('key') or f"{alert.get('ts')}|{alert.get('title')}"
5303 if key in seen:
5304 continue
5305 seen.add(key)
5306 fresh.append(alert)
5307 # Bound the per-peer memory: a long-running unit must not grow a
5308 # set forever. The window is far larger than any single poll's payload.
5309 if len(seen) > 4000:
5310 _mesh_alert_seen[scope] = set(list(seen)[-2000:])
5311 if not fresh:
5312 continue
5313
5314 try:
5315 with _watchtower_lock:

Callers 1

apply_hardware_profileFunction · 0.85

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected