Remove outdated testing results and release notes; add new Proxmox documentation generation and connection testing scripts.
Some checks failed
CI/CD Pipeline / Lint Code (push) Failing after 7m58s
CI/CD Pipeline / Generate Documentation (push) Failing after 7m56s
CI/CD Pipeline / Run Tests (push) Has been skipped
CI/CD Pipeline / Security Scanning (push) Has been skipped
CI/CD Pipeline / Deploy to Staging (push) Has been skipped
CI/CD Pipeline / Build and Push Docker Images (api) (push) Has been skipped
CI/CD Pipeline / Build and Push Docker Images (chat) (push) Has been skipped
CI/CD Pipeline / Build and Push Docker Images (frontend) (push) Has been skipped
CI/CD Pipeline / Build and Push Docker Images (worker) (push) Has been skipped
CI/CD Pipeline / Deploy to Production (push) Has been skipped

This commit is contained in:
2025-10-21 11:12:40 +02:00
parent c8aebaaee3
commit e9c2b18bf0
20 changed files with 285 additions and 7813 deletions

View File

@@ -0,0 +1,118 @@
#!/usr/bin/env python3
"""
Generate Proxmox documentation from within the worker container.
This script tests the complete flow: collect data -> generate docs using template.
"""
import asyncio
import logging
import sys
from pathlib import Path
# Configure logging
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
handlers=[
logging.StreamHandler(sys.stdout),
logging.FileHandler("/tmp/proxmox_docs_container.log")
]
)
logger = logging.getLogger(__name__)
async def main():
"""Main function to generate Proxmox documentation"""
try:
logger.info("=" * 80)
logger.info("PROXMOX DOCUMENTATION GENERATION TEST")
logger.info("=" * 80)
# Import after configuring logging
from datacenter_docs.collectors.proxmox_collector import ProxmoxCollector
from datacenter_docs.generators.template_generator import TemplateBasedGenerator
# Step 1: Collect Proxmox data
logger.info("\n[STEP 1] Collecting Proxmox data...")
collector = ProxmoxCollector()
collect_result = await collector.run()
if not collect_result["success"]:
logger.error(f"❌ Collection failed: {collect_result['error']}")
return False
logger.info("✅ Data collection successful")
# Log collected data summary
data = collect_result.get("data", {})
vms = data.get("data", {}).get("vms", [])
containers = data.get("data", {}).get("containers", [])
nodes = data.get("data", {}).get("nodes", [])
logger.info(f" - VMs: {len(vms)}")
logger.info(f" - Containers: {len(containers)}")
logger.info(f" - Nodes: {len(nodes)}")
# Step 2: Generate documentation using template
logger.info("\n[STEP 2] Generating documentation using template...")
template_path = "/app/templates/documentation/proxmox.yaml"
if not Path(template_path).exists():
logger.error(f"❌ Template not found: {template_path}")
return False
logger.info(f" Using template: {template_path}")
generator = TemplateBasedGenerator(template_path)
# Generate and save each section individually
logger.info("\n[STEP 3] Generating documentation sections...")
sections_results = await generator.generate_and_save_sections(
data=data,
save_individually=True
)
# Print results
logger.info("\n" + "=" * 80)
logger.info("GENERATION RESULTS")
logger.info("=" * 80)
success_count = 0
failed_count = 0
for i, result in enumerate(sections_results, 1):
section_id = result.get("section_id", "unknown")
title = result.get("title", "Unknown")
success = result.get("success", False)
if success:
success_count += 1
file_path = result.get("file_path", "N/A")
logger.info(f"✅ Section {i}: {title}")
logger.info(f" File: {file_path}")
else:
failed_count += 1
error = result.get("error", "Unknown error")
logger.info(f"❌ Section {i}: {title}")
logger.info(f" Error: {error}")
# Final summary
logger.info("\n" + "=" * 80)
logger.info("SUMMARY")
logger.info("=" * 80)
logger.info(f"Total sections: {len(sections_results)}")
logger.info(f"Successful: {success_count}")
logger.info(f"Failed: {failed_count}")
logger.info(f"Success rate: {(success_count / len(sections_results) * 100):.1f}%")
logger.info("=" * 80)
return success_count == len(sections_results)
except Exception as e:
logger.error(f"❌ Unexpected error: {e}", exc_info=True)
return False
if __name__ == "__main__":
success = asyncio.run(main())
sys.exit(0 if success else 1)

View File

@@ -0,0 +1,167 @@
#!/usr/bin/env python3
"""
Simple test script for Proxmox API connection
Tests only the Proxmox connection without loading full application
"""
import sys
from pathlib import Path
# Add src to path
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
from datacenter_docs.utils.config import get_settings
def test_proxmox_connection():
"""Test Proxmox API connection"""
print("=" * 80)
print("PROXMOX API CONNECTION TEST")
print("=" * 80)
# Load settings
settings = get_settings()
print("\n📋 Configuration:")
print(f" Host: {settings.PROXMOX_HOST}")
print(f" Port: {settings.PROXMOX_PORT}")
print(f" User: {settings.PROXMOX_USER}")
print(f" Token Name: {settings.PROXMOX_TOKEN_NAME}")
print(f" Token Value: {'*' * 8}{settings.PROXMOX_TOKEN_VALUE[-4:] if settings.PROXMOX_TOKEN_VALUE else 'NOT SET'}")
print(f" Verify SSL: {settings.PROXMOX_VERIFY_SSL}")
print(f" Timeout: {settings.PROXMOX_TIMEOUT}s")
# Check if configured
if not settings.PROXMOX_HOST or settings.PROXMOX_HOST == "proxmox.example.com":
print("\n❌ ERROR: Proxmox host not configured")
print(" Please set PROXMOX_HOST in .env file")
return False
# Try to import proxmoxer
try:
from proxmoxer import ProxmoxAPI
except ImportError:
print("\n❌ ERROR: proxmoxer library not installed")
print(" Install with: pip install proxmoxer")
return False
print("\n🔌 Connecting to Proxmox...")
try:
# Prepare connection parameters
auth_params = {
"host": settings.PROXMOX_HOST,
"port": settings.PROXMOX_PORT,
"verify_ssl": settings.PROXMOX_VERIFY_SSL,
"timeout": settings.PROXMOX_TIMEOUT,
}
# API Token authentication
if settings.PROXMOX_TOKEN_NAME and settings.PROXMOX_TOKEN_VALUE:
print(f" Using API token authentication: {settings.PROXMOX_USER}!{settings.PROXMOX_TOKEN_NAME}")
auth_params["user"] = settings.PROXMOX_USER
auth_params["token_name"] = settings.PROXMOX_TOKEN_NAME
auth_params["token_value"] = settings.PROXMOX_TOKEN_VALUE
# Password authentication
elif settings.PROXMOX_PASSWORD:
print(f" Using password authentication: {settings.PROXMOX_USER}")
auth_params["user"] = settings.PROXMOX_USER
auth_params["password"] = settings.PROXMOX_PASSWORD
else:
print("\n❌ ERROR: No authentication credentials configured")
print(" Set either PROXMOX_TOKEN_NAME/VALUE or PROXMOX_PASSWORD")
return False
# Connect
proxmox = ProxmoxAPI(**auth_params)
# Test connection by getting version
version = proxmox.version.get()
print(f"\n✅ Connection successful!")
print(f" Proxmox VE version: {version.get('version')}")
print(f" Release: {version.get('release', 'unknown')}")
# Get cluster status
print("\n📊 Cluster Information:")
try:
cluster_status = proxmox.cluster.status.get()
for item in cluster_status:
if item.get("type") == "cluster":
print(f" Cluster Name: {item.get('name')}")
print(f" Quorate: {'Yes' if item.get('quorate') else 'No'}")
print(f" Nodes: {item.get('nodes')}")
break
except Exception as e:
print(f" ⚠️ Could not get cluster info: {e}")
# Get nodes
print("\n🖥️ Nodes:")
try:
nodes = proxmox.nodes.get()
for node in nodes:
status_icon = "🟢" if node.get("status") == "online" else "🔴"
print(f" {status_icon} {node.get('node')}: {node.get('status')}")
except Exception as e:
print(f" ⚠️ Could not get nodes: {e}")
# Get VM count
print("\n💻 Virtual Machines:")
try:
total_vms = 0
total_containers = 0
for node in nodes:
node_name = node["node"]
try:
vms = proxmox.nodes(node_name).qemu.get()
containers = proxmox.nodes(node_name).lxc.get()
total_vms += len(vms)
total_containers += len(containers)
print(f" Node {node_name}: {len(vms)} VMs, {len(containers)} containers")
except Exception:
pass
print(f"\n 📊 TOTAL: {total_vms} VMs, {total_containers} containers")
except Exception as e:
print(f" ⚠️ Could not get VMs: {e}")
print("\n" + "=" * 80)
print("✅ ALL TESTS PASSED - Proxmox connection is working!")
print("=" * 80)
return True
except Exception as e:
print(f"\n❌ CONNECTION FAILED")
print(f" Error: {e}")
print(f" Type: {type(e).__name__}")
if "401" in str(e):
print("\n💡 Troubleshooting:")
print(" - Check that PROXMOX_USER is correct (should include realm: user@pam or user@pve)")
print(" - Verify PROXMOX_TOKEN_NAME matches the token ID in Proxmox")
print(" - Verify PROXMOX_TOKEN_VALUE is correct")
print(" - Check token has proper permissions (PVEAuditor role on path /)")
elif "SSL" in str(e):
print("\n💡 Troubleshooting:")
print(" - Try setting PROXMOX_VERIFY_SSL=false in .env")
print(" - Or install valid SSL certificate on Proxmox")
elif "refused" in str(e).lower():
print("\n💡 Troubleshooting:")
print(" - Check PROXMOX_HOST is correct")
print(" - Check PROXMOX_PORT is correct (default: 8006)")
print(" - Verify firewall allows access to Proxmox API")
print(" - Check Proxmox API service is running: systemctl status pveproxy")
print("\n" + "=" * 80)
return False
if __name__ == "__main__":
success = test_proxmox_connection()
sys.exit(0 if success else 1)