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

Function detect_hardware

webapp_modern.py:5414–5497  ·  view source on GitHub ↗

Auto-detect current hardware and recommend profile

()

Source from the content-addressed store, hash-verified

5412 roll['key_issues'] += 1
5413 if (health.get('serve') or {}).get('published'):
5414 roll['published'] += 1
5415
5416 # Worst severity this node is carrying (its Watchtower + incident worst),
5417 # tallied so the card can show the mesh-wide distribution and headline.
5418 node_worst = None
5419 node_rank = -1
5420 for sev in (wt.get('worst'), inc.get('worst')):
5421 if sev and _MESH_SEV_RANK.get(sev, -1) > node_rank:
5422 node_rank = _MESH_SEV_RANK[sev]
5423 node_worst = sev
5424 if node_worst:
5425 roll['by_severity'][node_worst] += 1
5426 if node_rank > worst_rank:
5427 worst_rank = node_rank
5428 roll['worst'] = node_worst
5429
5430 if (reachable is False and polled) or (not is_self and not node.get('online') and not reachable) \
5431 or key_bad or undervoltage or node_rank >= _MESH_SEV_RANK['high']:
5432 roll['attention'] += 1
5433
5434 return roll
5435
5436
5437@app.route('/api/mesh/status', methods=['GET'])
5438def mesh_status():
5439 """Whole-mesh view: tailnet state, this node, peers, and peer health."""
5440 cfg = shared_data.config
5441 if not mesh_available:
5442 return jsonify({'success': True, 'enabled': False, 'installed': False,
5443 'reason': 'mesh_manager module is unavailable.',
5444 'self': None, 'peers': []})
5445
5446 state = mesh_manager.status()
5447 tag = _mesh_tag()
5448
5449 # A caller can force a synchronous poll (the Refresh button); otherwise the
5450 # cached result from the background loop is served instantly.
5451 if request.args.get('refresh') == '1' and _mesh_enabled():
5452 try:
5453 _mesh_poll_once()
5454 except Exception as exc:
5455 logger.debug(f"[mesh] forced poll failed: {exc}")
5456
5457 with _mesh_lock:
5458 health = dict(_mesh_peer_health)
5459 findings = dict(_mesh_peer_findings)
5460 last_poll = _mesh_last_poll
5461
5462 peers = []
5463 for peer in state.get('peers', []):
5464 node = dict(peer)
5465 node['is_ragnar'] = tag in peer.get('tags', [])
5466 node['health'] = health.get(peer['id'])
5467 node['findings'] = findings.get(peer['id'])
5468 # The unit number is reported by the unit itself, so it is only known
5469 # for peers we could actually reach.
5470 node['unit_id'] = (node['health'] or {}).get('unit_id', 0)
5471 node['viking_name'] = (node['health'] or {}).get('viking_name', '')

Callers

nothing calls this directly

Calls 3

warningMethod · 0.80
errorMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected