- Remove executable permissions from configuration files (.editorconfig, .env.example, .gitignore) - Remove executable permissions from documentation files (README.md, LICENSE, SECURITY.md) - Remove executable permissions from web assets (HTML, CSS, JS files) - Remove executable permissions from data files (JSON, SQL, YAML, requirements.txt) - Remove executable permissions from source code files across all apps - Add executable permissions to Python
68 lines
2.2 KiB
Python
Executable File
68 lines
2.2 KiB
Python
Executable File
"""
|
|
Multi-Region Load Balancer CLI Commands for AITBC
|
|
Commands for managing multi-region load balancing
|
|
"""
|
|
|
|
import click
|
|
import json
|
|
import requests
|
|
from datetime import datetime
|
|
from typing import Dict, Any, List, Optional
|
|
|
|
@click.group()
|
|
def multi_region_load_balancer():
|
|
"""Multi-region load balancer management commands"""
|
|
pass
|
|
|
|
@multi_region_load_balancer.command()
|
|
@click.option('--test-mode', is_flag=True, help='Run in test mode')
|
|
def status(test_mode):
|
|
"""Get load balancer status"""
|
|
try:
|
|
if test_mode:
|
|
click.echo("⚖️ Load Balancer Status (test mode)")
|
|
click.echo("📊 Total Rules: 5")
|
|
click.echo("✅ Active Rules: 5")
|
|
click.echo("🌍 Regions: 3")
|
|
click.echo("📈 Requests/sec: 1,250")
|
|
return
|
|
|
|
# Get status from service
|
|
config = get_config()
|
|
response = requests.get(
|
|
f"{config.coordinator_url}/api/v1/dashboard",
|
|
headers={"Authorization": f"Bearer {config.api_key}"},
|
|
timeout=30
|
|
)
|
|
|
|
if response.status_code == 200:
|
|
status = response.json()
|
|
dashboard = status['dashboard']
|
|
click.echo("⚖️ Load Balancer Status")
|
|
click.echo(f"📊 Total Rules: {dashboard.get('total_balancers', 0)}")
|
|
click.echo(f"✅ Active Rules: {dashboard.get('active_balancers', 0)}")
|
|
click.echo(f"🌍 Regions: {dashboard.get('regions', 0)}")
|
|
click.echo(f"📈 Requests/sec: {dashboard.get('requests_per_second', 0)}")
|
|
else:
|
|
click.echo(f"❌ Failed to get status: {response.text}", err=True)
|
|
|
|
except Exception as e:
|
|
click.echo(f"❌ Error getting status: {str(e)}", err=True)
|
|
|
|
# Helper function to get config
|
|
def get_config():
|
|
"""Get CLI configuration"""
|
|
try:
|
|
from .config import get_config
|
|
return get_config()
|
|
except ImportError:
|
|
# Fallback for testing
|
|
from types import SimpleNamespace
|
|
return SimpleNamespace(
|
|
coordinator_url="http://localhost:8019",
|
|
api_key="test-api-key"
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
multi_region_load_balancer()
|