log_error "Cluster is not quorate. Cannot proceed with migration."
exit1
fi
log_success "Cluster is quorate"
echo""
# Verify target node is online
log_info "Verifying target node ($TARGET_NODE) is online..."
target_online=$(ssh_proxmox "pvesh get /nodes --output-format json" 2>&1| python3 -c "import sys, json; nodes=json.load(sys.stdin); target=[n for n in nodes if n['node']=='$TARGET_NODE' and n['status']=='online']; print('online' if target else 'offline')" 2>/dev/null ||echo"unknown")
if[["$target_online" !="online"]];then
log_error "Target node $TARGET_NODE is not online (status: $target_online)"
exit1
fi
log_success "Target node is online"
echo""
# Priority containers to migrate (high resource usage)
PRIORITY_CONTAINERS=(
"1000:besu-validator-1"
"1001:besu-validator-2"
"1002:besu-validator-3"
"1003:besu-validator-4"
"1004:besu-validator-5"
"2500:besu-rpc-1"
"2501:besu-rpc-2"
"2502:besu-rpc-3"
"5000:blockscout-1"
)
log_info "Will migrate the following containers to $TARGET_NODE:"
for container in "${PRIORITY_CONTAINERS[@]}";do
vmid="${container%%:*}"
name="${container#*:}"
echo" - $vmid: $name"
done
echo""
log_warn "Starting migrations. Each migration may take 2-5 minutes."
echo""
failed=0
success=0
total=${#PRIORITY_CONTAINERS[@]}
for container in "${PRIORITY_CONTAINERS[@]}";do
vmid="${container%%:*}"
name="${container#*:}"
if migrate_container "$vmid""$name";then
success=$((success +1))
else
failed=$((failed +1))
fi
# Small delay between migrations
if[[$success -lt $total]];then
log_info "Waiting 10 seconds before next migration..."