#!/bin/bash
# SSH to Proxmox Sites

set -e

# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

echo -e "${BLUE}=== Proxmox Site SSH Connections ===${NC}"
echo ""
echo "Site 1 (ml110-01): 192.168.11.10"
echo "Site 2 (r630-01):  192.168.11.11"
echo ""

# Function to connect to a site
connect_site() {
    local IP=$1
    local NAME=$2
    local SITE=$3
    
    echo -e "${YELLOW}Connecting to $NAME ($SITE) at $IP...${NC}"
    echo ""
    
    ssh -o StrictHostKeyChecking=no root@$IP
}

# Menu
echo "Select which Proxmox server to connect to:"
echo "  1) Site 1 - ml110-01 (192.168.11.10)"
echo "  2) Site 2 - r630-01 (192.168.11.11)"
echo "  3) Both (test connectivity)"
echo ""
read -p "Enter choice [1-3]: " choice

case $choice in
    1)
        connect_site "192.168.11.10" "ml110-01" "Site 1"
        ;;
    2)
        connect_site "192.168.11.11" "r630-01" "Site 2"
        ;;
    3)
        echo -e "${YELLOW}Testing connectivity to both sites...${NC}"
        echo ""
        echo "Site 1 (192.168.11.10):"
        ssh -o ConnectTimeout=3 -o StrictHostKeyChecking=no root@192.168.11.10 "hostname && pveversion" 2>&1 | head -5 || echo "  Not reachable or requires authentication"
        echo ""
        echo "Site 2 (192.168.11.11):"
        ssh -o ConnectTimeout=3 -o StrictHostKeyChecking=no root@192.168.11.11 "hostname && pveversion" 2>&1 | head -5 || echo "  Not reachable or requires authentication"
        ;;
    *)
        echo "Invalid choice"
        exit 1
        ;;
esac

