headscale-tailscale-replace.../farmq-admin/test_multiple_proxmox.py
시골약사 fb00b0a5fd Add multi-host Proxmox support with SSL certificate handling
- Added support for multiple Proxmox hosts (pve7.0bin.in:443, Healthport PVE:8006)
- Enhanced VM management APIs to accept host parameter
- Fixed WebSocket URL generation bug (dynamic port handling)
- Added comprehensive SSL certificate trust help system
- Implemented host selection dropdown in UI
- Added VNC connection failure detection and automatic SSL help redirection
- Updated session management to store host_key information
- Enhanced error handling for different Proxmox configurations

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-13 00:03:25 +09:00

103 lines
3.0 KiB
Python

#!/usr/bin/env python3
"""
다중 Proxmox 서버 접속 테스트
"""
from utils.proxmox_client import ProxmoxClient
import json
# Proxmox 서버 설정
PROXMOX_HOSTS = {
'pve7.0bin.in': {
'host': 'pve7.0bin.in',
'username': 'root@pam',
'password': 'trajet6640',
'port': 443,
'name': 'PVE 7.0 (Main)'
},
'healthport_pve': {
'host': '100.64.0.6',
'username': 'root@pam',
'password': 'healthport',
'port': 8006,
'name': 'Healthport PVE'
}
}
def test_proxmox_connection(host_key, host_config):
"""Proxmox 서버 연결 테스트"""
print(f"\n{'='*50}")
print(f"🔍 Testing connection to: {host_config['name']}")
print(f"📡 Host: {host_config['host']}")
print(f"👤 Username: {host_config['username']}")
print(f"{'='*50}")
try:
# ProxmoxClient 생성 및 로그인 시도
client = ProxmoxClient(
host_config['host'],
host_config['username'],
host_config['password'],
port=host_config['port']
)
print("🔐 Attempting login...")
if client.login():
print("✅ Login successful!")
# VM 목록 가져오기 시도
print("📋 Fetching VM list...")
vms = client.get_vm_list()
if vms:
print(f"✅ Found {len(vms)} VMs:")
for vm in vms[:5]: # 처음 5개만 표시
print(f" • VM {vm.get('vmid', 'N/A')}: {vm.get('name', 'Unknown')} ({vm.get('status', 'unknown')})")
if len(vms) > 5:
print(f" ... and {len(vms) - 5} more VMs")
else:
print("⚠️ No VMs found or unable to fetch VM list")
return True
else:
print("❌ Login failed!")
return False
except Exception as e:
print(f"❌ Connection error: {e}")
return False
def main():
"""메인 테스트 함수"""
print("🚀 Multiple Proxmox Server Connection Test")
print("=" * 60)
results = {}
for host_key, host_config in PROXMOX_HOSTS.items():
success = test_proxmox_connection(host_key, host_config)
results[host_key] = {
'success': success,
'config': host_config
}
# 결과 요약
print(f"\n{'='*60}")
print("📊 TEST RESULTS SUMMARY")
print(f"{'='*60}")
for host_key, result in results.items():
status = "✅ SUCCESS" if result['success'] else "❌ FAILED"
print(f"{result['config']['name']}: {status}")
successful_hosts = [k for k, v in results.items() if v['success']]
print(f"\n🎯 {len(successful_hosts)}/{len(PROXMOX_HOSTS)} hosts connected successfully")
if successful_hosts:
print("\n✅ Ready for multi-host implementation!")
else:
print("\n⚠️ No hosts connected. Check network and credentials.")
if __name__ == '__main__':
main()