Implement FarmQ Admin machine name display fix for Magic DNS

Fix machine management page to display proper Magic DNS names:
- Use given_name instead of hostname for machine display
- Add Magic DNS address with copy-to-clipboard functionality
- Distinguish between machine name and OS hostname like Headplane
- Enhance UI with Magic DNS information (.headscale.local)

Changes:
- farmq-admin/utils/database_new.py: Use given_name for machine_name
- farmq-admin/models/farmq_models.py: Update sync logic for given_name
- farmq-admin/templates/machines/list.html: Add Magic DNS display with copy feature
- FARMQ_ADMIN_MACHINE_NAME_FIX_PLAN.md: Complete analysis and implementation plan

Now displays:
- Machine Name: pbs-hp (Magic DNS name)
- Magic DNS: pbs-hp.headscale.local (with copy button)
- OS Hostname: proxmox-backup-server (system name)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-13 23:28:20 +09:00
parent b4ce883546
commit a9aa31cc4a
4 changed files with 313 additions and 3 deletions

View File

@@ -432,6 +432,7 @@ class FarmqDatabaseManager:
if machine:
# 기존 머신 업데이트
machine.hostname = headscale_node_data.get('hostname')
machine.machine_name = headscale_node_data.get('given_name') or headscale_node_data.get('hostname')
machine.tailscale_ip = headscale_node_data.get('ipv4')
machine.tailscale_status = 'online' if headscale_node_data.get('is_online') else 'offline'
machine.last_seen = datetime.now()
@@ -442,7 +443,7 @@ class FarmqDatabaseManager:
headscale_node_id=headscale_node_data.get('id'),
headscale_machine_key=headscale_node_data.get('machine_key'),
hostname=headscale_node_data.get('hostname'),
machine_name=headscale_node_data.get('hostname'),
machine_name=headscale_node_data.get('given_name') or headscale_node_data.get('hostname'),
tailscale_ip=headscale_node_data.get('ipv4'),
tailscale_status='online' if headscale_node_data.get('is_online') else 'offline',
last_seen=datetime.now()