ADD: remove architecture , fix sites

This commit is contained in:
2026-06-07 18:31:10 +01:00
parent d4d15da0df
commit 515fc94754
7 changed files with 60 additions and 413 deletions

View File

@@ -9,7 +9,7 @@ from modules.backups import _ssh_main, get_all_root_containers, get_container_st
# ────────────────────────────────────────────────────────────────
# STATIC SITE REGISTRY (source of truth for UI + architecture)
# STATIC SITE REGISTRY (source of truth for Application Sites UI)
# ────────────────────────────────────────────────────────────────
PLATFORM = {
@@ -18,6 +18,7 @@ PLATFORM = {
'tagline': 'Navitrends ops dashboard',
'domain': 'cloudops.nav.ovh',
'domain_protocol': 'https',
'ssl_configured': True,
'port': 8088,
'internal_port': 5000,
'container': 'management-platform',
@@ -45,6 +46,7 @@ SITES = [
'internal_port': 8000,
'domain': 'erpnext.navitrends.ovh',
'domain_protocol': 'http',
'ssl_configured': False,
'health_path': '/',
'volumes': ['frappe-setup_frappe-sites', 'frappe-setup_mariadb-data'],
},
@@ -65,6 +67,7 @@ SITES = [
'internal_port': 8069,
'domain': 'odooo.nav.ovh',
'domain_protocol': 'https',
'ssl_configured': True,
'health_path': '/web',
'volumes': ['odoo-clean_db-data', 'odoo-clean_odoo-etc'],
},
@@ -85,6 +88,7 @@ SITES = [
'internal_port': 80,
'domain': 'next.cloud.nav.ovh',
'domain_protocol': 'https',
'ssl_configured': True,
'health_path': '/status.php',
'volumes': ['nextcloud-setup_nextcloud-data', 'nextcloud-setup_nextcloud-db-data'],
},
@@ -105,6 +109,7 @@ SITES = [
'internal_port': 80,
'domain': None,
'domain_protocol': 'http',
'ssl_configured': False,
'health_path': '/',
'volumes': ['mautic-setup_mautic-data', 'mautic-setup_mautic-db-data'],
'networks': ['mautic-network'],
@@ -126,6 +131,7 @@ SITES = [
'internal_port': 5678,
'domain': None,
'domain_protocol': 'http',
'ssl_configured': False,
'health_path': '/healthz',
'volumes': ['n8n-setup_n8n-data', 'n8n-setup_n8n-db-data'],
'networks': ['n8n-network', 'integration-network'],
@@ -140,24 +146,30 @@ def _build_urls(site):
port = site['port']
proto = site.get('domain_protocol', 'http')
path = site.get('health_path', '/') or '/'
ssl_configured = site.get('ssl_configured', proto == 'https')
domain = site.get('domain')
has_domain = bool(domain)
if has_domain:
primary_url = f"{proto}://{domain}{path}"
access_url = f"{proto}://{domain}"
if ssl_configured:
access_url = f"{proto}://{domain}"
health_url = f"{access_url}{path}"
else:
access_url = f"http://{domain}:{port}"
health_url = f"{access_url}{path}"
else:
primary_url = f"http://{ip}:{port}{path}"
access_url = f"http://{ip}:{port}"
health_url = f"{access_url}{path}"
return {
'has_domain': has_domain,
'domain': domain,
'domain_protocol': proto,
'ssl_configured': ssl_configured,
'ip_url': f"http://{ip}:{port}",
'access_url': access_url.rstrip('/'),
'health_url': primary_url,
'health_url': health_url,
}
@@ -317,96 +329,3 @@ def get_site_health(site_id):
probe['status'] = 'up' if probe['reachable'] else 'down'
probe['checked_at'] = time.time()
return probe
def get_architecture():
"""Topology for architecture page — stacks, platform, shared infra."""
ctr_map = _container_map()
stacks = []
for site in SITES:
nodes = []
edges = []
main = site['main_container']
db_nodes = [c for c in site.get('containers', []) if c['role'] == 'Database']
cache_nodes = [c for c in site.get('containers', []) if 'Cache' in c.get('role', '')]
for ctr in site.get('containers', []):
live = ctr_map.get(ctr['name'], {})
is_up = 'Up' in live.get('status', '')
nodes.append({
'id': ctr['name'],
'label': ctr['name'],
'role': ctr['role'],
'type': 'database' if ctr['role'] == 'Database' else (
'cache' if 'Cache' in ctr['role'] else 'app'
),
'status': 'running' if is_up else ('stopped' if live else 'missing'),
'image': live.get('image', ctr.get('image', '')),
})
for db in db_nodes:
edges.append({'from': main, 'to': db['name'], 'label': 'DB'})
for cache in cache_nodes:
edges.append({'from': main, 'to': cache['name'], 'label': 'Redis'})
urls = _build_urls(site)
stacks.append({
'id': site['id'],
'name': site['name'],
'category': site['category'],
'brand_color': site['brand_color'],
'compose_dir': site['compose_dir'],
'port': site['port'],
'domain': site.get('domain'),
'access_url': urls['access_url'],
'nodes': nodes,
'edges': edges,
'networks': site.get('networks', ['bridge']),
'running': sum(1 for n in nodes if n['status'] == 'running'),
'total': len(nodes),
})
platform_status = 'running'
if RUNNING_ON_MAIN_SERVER:
out, _ = _ssh_main("docker inspect --format='{{.State.Status}}' management-platform 2>/dev/null")
if out.strip().lower() not in ('running', 'restarting'):
platform_status = out.strip() or 'unknown'
else:
out, _ = _ssh_main("docker inspect --format='{{.State.Status}}' management-platform 2>/dev/null")
platform_status = out.strip().lower() if out else 'unknown'
plat_urls = _build_urls({
'domain': PLATFORM['domain'],
'domain_protocol': PLATFORM['domain_protocol'],
'port': PLATFORM['port'],
'health_path': PLATFORM['health_path'],
})
return {
'server_ip': MAIN_SERVER_IP,
'platform': {
'id': PLATFORM['id'],
'name': PLATFORM['name'],
'tagline': PLATFORM['tagline'],
'container': PLATFORM['container'],
'port': PLATFORM['port'],
'internal_port': PLATFORM['internal_port'],
'domain': PLATFORM['domain'],
'domain_protocol': PLATFORM['domain_protocol'],
'status': platform_status,
'brand_color': PLATFORM['brand_color'],
**plat_urls,
},
'stacks': stacks,
'shared': {
'networks': ['integration-network', 'mautic-network', 'n8n-network'],
'backup_path': '/root/backups',
'vm_backup_path': '/backups/main-server',
},
'summary': {
'sites': len(SITES),
'containers': sum(s['total'] for s in stacks),
'running': sum(s['running'] for s in stacks),
},
}