#!/bin/bash
# Alternative verification using Proxmox API
# This uses the Proxmox API token to query disk information

set -e

# Configuration
PROXMOX_HOST="192.168.11.11"
PROXMOX_PORT="8006"
PROXMOX_USER="root@pam"

# Get token from Kubernetes secret
echo "Attempting to get Proxmox credentials from Kubernetes..."
TOKEN=$(kubectl get secret -n crossplane-system proxmox-credentials -o jsonpath='{.data.token}' 2>/dev/null | base64 -d)

if [ -z "$TOKEN" ]; then
    echo "ERROR: Could not retrieve Proxmox token from Kubernetes"
    echo "Please run the verification script directly on R630-01 instead"
    exit 1
fi

echo "Token retrieved (first 20 chars): ${TOKEN:0:20}..."
echo ""

# Try to query Proxmox API for storage information
echo "Querying Proxmox API for storage information..."
echo ""

# Note: Proxmox API endpoints for storage/disk info
# This is a basic attempt - may need adjustment based on actual API

echo "=== Storage Information via Proxmox API ==="
echo ""
echo "Note: Direct disk enumeration via API is limited."
echo "For detailed disk information, please run the verification script"
echo "directly on R630-01:"
echo ""
echo "  ssh root@192.168.11.11"
echo "  bash /tmp/verify-r630-250gb-drives.sh"
echo ""
echo "Or run these commands manually on R630-01:"
echo ""
echo "  lsblk -o NAME,SIZE,TYPE,MOUNTPOINT,FSTYPE,MODEL,SERIAL"
echo "  fdisk -l | grep -E '^Disk /dev/sd'"
echo "  ceph osd tree"
echo ""

