chore: update file permissions to executable across repository
- Change file mode from 644 to 755 for all project files - Add chain_id parameter to get_balance RPC endpoint with default "ait-devnet" - Rename Miner.extra_meta_data to extra_metadata for consistency
This commit is contained in:
67
cli/aitbc_cli/commands/multi_region_load_balancer.py
Normal file
67
cli/aitbc_cli/commands/multi_region_load_balancer.py
Normal file
@@ -0,0 +1,67 @@
|
||||
"""
|
||||
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()
|
||||
Reference in New Issue
Block a user