Files
haproxy-openmanager/backend/config.py
T
taylanbakircioglu 481be91a4e feat(snapshot): PHASE 2 - Add entity snapshot for Frontend & Backend updates
- Created entity_snapshot.py helper module (~570 lines)
  - save_entity_snapshot() - Create snapshots with compaction
  - rollback_entity_from_snapshot() - Main rollback logic
  - _rollback_update() - UPDATE rollback for all entity types
  - _rollback_create() - CREATE rollback (entity deletion)
  - Feature flag support: ENTITY_SNAPSHOT_ENABLED (default: false)

- Integrated snapshot into Frontend update (frontend.py)
  - Capture full entity state before UPDATE
  - Create entity_snapshot metadata
  - Merge with pre_apply_snapshot for diff viewer
  - Store in config_versions.metadata JSONB

- Integrated snapshot into Backend update (backend.py)
  - Same snapshot pattern as Frontend
  - Works within transaction for atomicity
  - Preserves diff viewer compatibility

- Added feature flag to config.py
  - ENTITY_SNAPSHOT_ENABLED (environment variable)
  - Default: false (safe rollout)
  - Ready for Phase 7 gradual deployment

Next: WAF, SSL, Server update integration + Reject rollback logic
2025-11-14 01:06:38 +03:00

33 lines
1.1 KiB
Python

import os
from typing import Optional
# Database connection settings
DATABASE_URL = os.getenv("DATABASE_URL", "postgresql://haproxy_user:haproxy_password@postgres:5432/haproxy_openmanager")
# Redis connection
REDIS_URL = os.getenv("REDIS_URL", "redis://localhost:6379")
# CORS settings
CORS_ORIGINS = ["http://localhost:3000"]
# Security settings
SECRET_KEY = os.getenv("SECRET_KEY", "your-secret-key-here")
JWT_SECRET_KEY = SECRET_KEY # Alias for JWT middleware
ALGORITHM = "HS256"
JWT_ALGORITHM = ALGORITHM # Alias for JWT middleware
ACCESS_TOKEN_EXPIRE_MINUTES = 30
# Logging level
LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO")
# Public URL configuration (for agent installation scripts)
PUBLIC_URL = os.getenv("PUBLIC_URL", "http://localhost:8000")
MANAGEMENT_BASE_URL = os.getenv("MANAGEMENT_BASE_URL", PUBLIC_URL) # Backward compatibility
# Agent settings
AGENT_HEARTBEAT_TIMEOUT_SECONDS = 15
AGENT_CONFIG_SYNC_INTERVAL_SECONDS = 30
# Entity snapshot feature flag (for gradual rollout)
# IMPORTANT: Keep this FALSE in production until Phase 7 deployment
ENTITY_SNAPSHOT_ENABLED = os.getenv("ENTITY_SNAPSHOT_ENABLED", "false").lower() == "true"