Apply a hardware profile to the system configuration
()
| 5498 | self_node['is_share_guest'] = self_share_tagged and not self_tagged |
| 5499 | self_node['health'] = _mesh_local_health() |
| 5500 | self_node['findings'] = dict(_mesh_local_findings(), |
| 5501 | features=_mesh_local_features()) |
| 5502 | self_node['unit_id'] = _mesh_unit_id() |
| 5503 | self_node['viking_name'] = _mesh_viking_name() |
| 5504 | key_state, key_msg = mesh_manager.node_key_health(state.get('self')) |
| 5505 | self_node['key_state'], self_node['key_message'] = key_state, key_msg |
| 5506 | self_node['label'] = cfg.get('mesh_site_label') or self_node.get('short_name', '') |
| 5507 | |
| 5508 | ragnar_peers = [p for p in peers if p['is_ragnar']] |
| 5509 | |
| 5510 | # A share-only guest is not a mesh member: it has no business enumerating the |
| 5511 | # host's mesh. Even though Tailscale lets it SEE those machines, Ragnar hides |
| 5512 | # them so this unit's UI shows no peers, no shared roster — only its own |
| 5513 | # share-only role. This is a view decision; the ACL is what actually confines |
| 5514 | # it on the wire. |
| 5515 | if self_share_tagged and not self_tagged: |
| 5516 | ragnar_peers = [] |
| 5517 | |
| 5518 | # Two units answering to the same number makes every report ambiguous |
| 5519 | # ("Unit 03 is offline" — which one?). Nothing prevents it, since units are |
| 5520 | # configured independently and there is no controller to arbitrate, so the |
| 5521 | # mesh detects the clash and says so instead. |
| 5522 | known = ([self_node] if self_node else []) + ragnar_peers |
| 5523 | assigned = [u['unit_id'] for u in known if u.get('unit_id')] |
| 5524 | duplicates = sorted({n for n in assigned if assigned.count(n) > 1}) |
| 5525 | |
| 5526 | # Viking names are derived from each machine's own identity with no central |
| 5527 | # allocator, so two units can independently land on the same one. Rare, but |
| 5528 | # a mesh where two boxes answer to "Bjorn Ironside" is exactly the confusion |
| 5529 | # naming was meant to remove — surface it so one can be renamed. |
| 5530 | names = [u['viking_name'] for u in known if u.get('viking_name')] |
| 5531 | duplicate_names = sorted({n for n in names if names.count(n) > 1}) |
| 5532 | |
| 5533 | # An operator can't act on "1 unit has no number" — they need to know WHICH |
| 5534 | # one. Name each unnumbered unit by whatever identity it does carry (Viking |
| 5535 | # name, then label, then Tailscale short name), and flag whether it's this |
| 5536 | # very unit so the UI can say "This unit" instead of a name it may not |
| 5537 | # recognise as itself. |
| 5538 | def _mesh_display_name(u): |
| 5539 | return (u.get('viking_name') or u.get('label') |
| 5540 | or u.get('short_name') or u.get('hostname') or 'unnamed unit') |
| 5541 | |
| 5542 | unnumbered_names = [ |
| 5543 | {'name': _mesh_display_name(u), 'is_self': u is self_node} |
| 5544 | for u in ([self_node] if self_node else []) + ragnar_peers |
| 5545 | if u.get('is_ragnar') is not False and not u.get('unit_id') |
| 5546 | and (u is self_node or (u.get('health') or {}).get('reachable')) |
| 5547 | ] |
| 5548 | unnumbered = len(unnumbered_names) |
| 5549 | |
| 5550 | with _mesh_install_lock: |
nothing calls this directly
no test coverage detected