#!/bin/bash
# batch-enhance-all-vms.sh
# Batch enhance all VM YAML files with Python script

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
ENHANCE_SCRIPT="$SCRIPT_DIR/enhance-vm-yaml.py"

log() {
    echo -e "\033[0;34m[$(date +'%Y-%m-%d %H:%M:%S')]\033[0m $*"
}

log_success() {
    echo -e "\033[0;32m[$(date +'%Y-%m-%d %H:%M:%S')] ✅\033[0m $*"
}

echo "=========================================="
echo "Batch Enhancing All VM YAML Files"
echo "=========================================="
echo ""

# Find all VM YAML files (exclude backups and templates if needed)
VM_FILES=$(find "$PROJECT_ROOT/examples/production" -name "*.yaml" -type f | grep -v ".backup" | sort)

TOTAL=$(echo "$VM_FILES" | wc -l)
log "Found $TOTAL VM YAML files to process"
echo ""

# Process each file
for file in $VM_FILES; do
    python3 "$ENHANCE_SCRIPT" "$file"
done

echo ""
echo "=========================================="
log_success "Batch enhancement complete!"
echo "=========================================="
echo ""
log "Backup files created with .backup extension"
log "Review changes and remove backups when satisfied"

