Files
Sankofa/scripts/import-image-to-rbd.sh
defiQUG 33d50fb91e
Some checks failed
API CI / API Lint (push) Successful in 47s
API CI / API Type Check (push) Failing after 47s
API CI / API Test (push) Successful in 1m0s
API CI / API Build (push) Failing after 50s
API CI / Build Docker Image (push) Has been skipped
Build Crossplane Provider / build (push) Failing after 5m51s
CD Pipeline / Deploy to Staging (push) Failing after 29s
CI Pipeline / Lint and Type Check (push) Failing after 36s
CI Pipeline / Build (push) Has been skipped
CI Pipeline / Test Backend (push) Failing after 1m33s
CI Pipeline / Test Frontend (push) Failing after 30s
CI Pipeline / Security Scan (push) Failing after 1m16s
Crossplane Provider CI / Go Test (push) Failing after 3m23s
Crossplane Provider CI / Go Lint (push) Failing after 7m27s
Crossplane Provider CI / Go Build (push) Failing after 3m27s
Deploy to Staging / Deploy to Staging (push) Failing after 30s
Portal CI / Portal Lint (push) Failing after 21s
Portal CI / Portal Type Check (push) Failing after 21s
Portal CI / Portal Test (push) Failing after 21s
Portal CI / Portal Build (push) Failing after 22s
Test Suite / frontend-tests (push) Failing after 30s
Test Suite / api-tests (push) Failing after 49s
Test Suite / blockchain-tests (push) Failing after 30s
Type Check / type-check (map[directory:. name:root]) (push) Failing after 23s
Type Check / type-check (map[directory:api name:api]) (push) Failing after 21s
Type Check / type-check (map[directory:portal name:portal]) (push) Failing after 19s
Validate Configuration Files / validate (push) Failing after 1m52s
CD Pipeline / Deploy to Production (push) Has been skipped
chore: consolidate local WIP (repo cleanup 20260707)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 09:41:34 -07:00

85 lines
3.1 KiB
Bash
Executable File

#!/bin/bash
# Import cloud image directly to RBD pool using rbd import
# This is the correct method for copying images to ceph-rbd storage
set -e
SOURCE_IMAGE="/var/lib/vz/template/iso/ubuntu-22.04-cloud.img"
RBD_POOL="rbd"
RBD_IMAGE_NAME="template_cache_ubuntu_22_04_cloud"
echo "═══════════════════════════════════════════════════════════════════════════════"
echo " IMPORT IMAGE TO RBD POOL"
echo "═══════════════════════════════════════════════════════════════════════════════"
echo ""
# Check if running on r630-01
HOSTNAME=$(hostname)
if [ "$HOSTNAME" != "r630-01" ]; then
echo "⚠️ WARNING: This script should be run on r630-01"
echo " Current hostname: $HOSTNAME"
exit 1
fi
echo "Step 1: Checking if source image exists..."
if [ ! -f "$SOURCE_IMAGE" ]; then
echo "❌ Source image not found: $SOURCE_IMAGE"
echo " Available images in /var/lib/vz/template/iso/:"
ls -lh /var/lib/vz/template/iso/*.img 2>/dev/null | head -5 || echo " (no .img files found)"
exit 1
fi
IMAGE_SIZE=$(du -h "$SOURCE_IMAGE" | cut -f1)
echo "✅ Source image found: $SOURCE_IMAGE ($IMAGE_SIZE)"
echo ""
echo "Step 2: Checking RBD pool..."
if ! ceph osd pool ls 2>/dev/null | grep -q "^${RBD_POOL}$"; then
echo "❌ RBD pool '$RBD_POOL' does not exist"
exit 1
fi
echo "✅ RBD pool '$RBD_POOL' exists"
echo ""
echo "Step 3: Checking if image already exists in RBD pool..."
if rbd ls -p "$RBD_POOL" 2>/dev/null | grep -q "^${RBD_IMAGE_NAME}$"; then
echo "⚠️ Image '$RBD_IMAGE_NAME' already exists in RBD pool"
echo " Removing existing image to overwrite..."
rbd rm -p "$RBD_POOL" "$RBD_IMAGE_NAME" 2>/dev/null || true
echo " ✅ Existing image removed"
fi
echo ""
echo "Step 4: Importing image to RBD pool..."
echo " This may take a few minutes for large images..."
echo " Source: $SOURCE_IMAGE"
echo " Target: rbd/$RBD_IMAGE_NAME"
echo ""
if rbd import "$SOURCE_IMAGE" "${RBD_POOL}/${RBD_IMAGE_NAME}" --image-format 2 2>&1; then
echo "✅ Image imported successfully to RBD pool"
else
echo "❌ RBD import failed"
exit 1
fi
echo ""
echo "Step 5: Verifying imported image..."
if rbd ls -p "$RBD_POOL" 2>/dev/null | grep -q "^${RBD_IMAGE_NAME}$"; then
RBD_SIZE=$(rbd info -p "$RBD_POOL" "$RBD_IMAGE_NAME" 2>/dev/null | grep "size" | awk '{print $2, $3}' || echo "unknown")
echo "✅ Image verified in RBD pool"
echo " Image: ${RBD_POOL}/${RBD_IMAGE_NAME}"
echo " Size: $RBD_SIZE"
echo ""
echo "⚠️ Note: Proxmox may need to refresh to see this image."
echo " The image is now available in the RBD pool and can be used by VMs."
echo " The provider will search for images in ceph-rbd storage."
else
echo "⚠️ Image not found in RBD pool after import"
exit 1
fi
echo ""
echo "✅ Import complete!"