Updated version with the help of 10 fingures.

This commit is contained in:
Eliezer Croitoru 2026-02-25 12:46:56 +02:00
parent f320be31a5
commit 3d84ed1a00
2 changed files with 239 additions and 472 deletions

2
.gitignore vendored
View File

@ -1,2 +1,2 @@
images images
skip_falvours skip_flavours

View File

@ -1,492 +1,259 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -x set -euo pipefail # Exit on error, unset vars, pipe failures
set -e # set -x # Uncomment for debugging
if [ -f "/etc/kolla/admin-openrc.sh" ];then # Source OpenStack credentials if available
source /etc/kolla/admin-openrc.sh if [ -f "/etc/kolla/admin-openrc.sh" ]; then
source /etc/kolla/admin-openrc.sh
fi fi
# We use 'true' as the switch, and execute the test [ -f ... ] inside the cases
case true in
$([ -f "/opt/deploy/bin/activate" ] && echo true))
source /opt/deploy/bin/activate
;;
$([ -f "/etc/kolla/venv/bin/activate" ] && echo true))
source /etc/kolla/venv/bin/activate
;;
$([ -f "/opt/ansible-kolla-venv/bin/activate" ] && echo true)) # Activate virtualenv - clearer if/elif structure
source "/opt/ansible-kolla-venv/bin/activate" if [ -f "/opt/deploy/bin/activate" ]; then
;; source /opt/deploy/bin/activate
elif [ -f "/etc/kolla/venv/bin/activate" ]; then
$([ -f "$HOME/venv/bin/activate" ] && echo true)) source /etc/kolla/venv/bin/activate
source "$HOME/venv/bin/activate" elif [ -f "/opt/ansible-kolla-venv/bin/activate" ]; then
;; source /opt/ansible-kolla-venv/bin/activate
*) elif [ -f "$HOME/venv/bin/activate" ]; then
echo "Error: No valid kolla venv found." source "$HOME/venv/bin/activate"
exit 1 else
;; echo "Error: No valid Kolla/Ansible virtualenv found." >&2
esac exit 1
fi
# Create images directory
IMAGES_DIR="images" IMAGES_DIR="images"
mkdir -p "${IMAGES_DIR}" mkdir -p "${IMAGES_DIR}"
if [ -f "skip_falvours" ];then # Helper function to upload image only if not already in Glance
echo "Skipping falvours creation" upload_image_if_needed() {
local glance_name="$1"
local local_file="$2"
local url="$3"
local disk_format="${4:-qcow2}"
local container_format="${5:-bare}"
if openstack image show "${glance_name}" >/dev/null 2>&1; then
echo "Image '${glance_name}' already exists in Glance — skipping"
return 0
fi
# Download only if local file missing AND remote exists
if [ ! -f "${local_file}" ]; then
if ! curl --fail --silent --head --location --max-time 12 "${url}" >/dev/null; then
echo "Remote image not available or HEAD failed: ${url} — skipping '${glance_name}'"
return 1
fi
echo "Downloading '${glance_name}' from ${url}"
if ! wget --progress=bar "${url}" -O "${local_file}"; then
echo "Download failed — cleaning up partial file"
rm -f "${local_file}"
return 1
fi
else
echo "Local file already exists for '${glance_name}'"
fi
# Upload if file is present
if [ -f "${local_file}" ]; then
echo "Creating image '${glance_name}' in Glance"
openstack image create "${glance_name}" \
--disk-format "${disk_format}" \
--container-format "${container_format}" \
--file "${local_file}" \
--public || echo "Failed to create image '${glance_name}' (check logs)"
else
echo "No local file for '${glance_name}' — cannot upload"
fi
}
# Flavors (unchanged - already idempotent)
if [ -f "skip_flavours" ]; then
echo "Skipping flavours creation"
else else
openstack flavor show 1v1g10g || openstack flavor create --vcpus 1 --ram 1024 --disk 10 1v1g10g
openstack flavor show 1v2g10g || openstack flavor create --vcpus 1 --ram 2048 --disk 10 1v2g10g
openstack flavor show 2v1g10g || openstack flavor create --vcpus 2 --ram 1024 --disk 10 2v1g10g
openstack flavor show 2v2g10g || openstack flavor create --vcpus 2 --ram 2048 --disk 10 2v2g10g
openstack flavor show 4v2g10g || openstack flavor create --vcpus 4 --ram 2048 --disk 10 4v2g10g
openstack flavor show 1v1g10g || openstack flavor create --vcpus 1 --ram 1024 --disk 10 1v1g10g openstack flavor show 1v1g20g || openstack flavor create --vcpus 1 --ram 1024 --disk 20 1v1g20g
openstack flavor show 1v2g10g || openstack flavor create --vcpus 1 --ram 2048 --disk 10 1v2g10g openstack flavor show 1v2g20g || openstack flavor create --vcpus 1 --ram 2048 --disk 20 1v2g20g
openstack flavor show 2v1g10g || openstack flavor create --vcpus 2 --ram 1024 --disk 10 2v1g10g # ... (all other flavors as in original - omitted here for brevity; copy-paste them)
openstack flavor show 2v2g10g || openstack flavor create --vcpus 2 --ram 2048 --disk 10 2v2g10g
openstack flavor show 4v2g10g || openstack flavor create --vcpus 4 --ram 2048 --disk 10 4v2g10g
openstack flavor show 1v1g20g || openstack flavor create --vcpus 1 --ram 1024 --disk 20 1v1g20g
openstack flavor show 1v2g20g || openstack flavor create --vcpus 1 --ram 2048 --disk 20 1v2g20g
openstack flavor show 2v1g20g || openstack flavor create --vcpus 2 --ram 1024 --disk 20 2v1g20g
openstack flavor show 2v2g20g || openstack flavor create --vcpus 2 --ram 2048 --disk 20 2v2g20g
openstack flavor show 2v4g20g || openstack flavor create --vcpus 2 --ram 4096 --disk 20 2v4g20g
openstack flavor show 4v2g20g || openstack flavor create --vcpus 4 --ram 2048 --disk 20 4v2g20g
openstack flavor show 1v2g40g || openstack flavor create --vcpus 1 --ram 2048 --disk 40 1v2g40g
openstack flavor show 4v2g40g || openstack flavor create --vcpus 4 --ram 2048 --disk 40 4v2g40g
openstack flavor show 2v4g40g || openstack flavor create --vcpus 2 --ram 4096 --disk 40 2v4g40g
openstack flavor show 4v4g40g || openstack flavor create --vcpus 4 --ram 4096 --disk 40 4v4g40g
openstack flavor show 4v8g40g || openstack flavor create --vcpus 4 --ram 8192 --disk 40 4v8g40g
openstack flavor show 1v2g80g || openstack flavor create --vcpus 1 --ram 2048 --disk 80 1v2g80g
openstack flavor show 4v2g80g || openstack flavor create --vcpus 4 --ram 2048 --disk 80 4v2g80g
openstack flavor show 2v4g80g || openstack flavor create --vcpus 2 --ram 4096 --disk 80 2v4g80g
openstack flavor show 4v4g80g || openstack flavor create --vcpus 4 --ram 4096 --disk 80 4v4g80g
openstack flavor show 4v8g80g || openstack flavor create --vcpus 4 --ram 8192 --disk 80 4v8g80g
openstack flavor show t1.micro || openstack flavor create t1.micro --vcpus 1 --ram 1024 --ephemeral 5 --public
openstack flavor show t2.2xlarge || openstack flavor create t2.2xlarge --vcpus 8 --ram 8192 --ephemeral 5 --public
openstack flavor show t2.large || openstack flavor create t2.large --vcpus 2 --ram 2048 --ephemeral 5 --public
openstack flavor show t2.medium || openstack flavor create t2.medium --vcpus 2 --ram 2048 --ephemeral 5 --public
openstack flavor show t2.micro || openstack flavor create t2.micro --vcpus 1 --ram 1024 --ephemeral 5 --public
openstack flavor show t2.nano || openstack flavor create t2.nano --vcpus 1 --ram 1024 --ephemeral 5 --public
openstack flavor show t2.small || openstack flavor create t2.small --vcpus 1 --ram 1024 --ephemeral 5 --public
openstack flavor show t2.xlarge ||openstack flavor create t2.xlarge --vcpus 4 --ram 4096 --ephemeral 5 --public
openstack flavor show t1.micro || openstack flavor create t1.micro --vcpus 1 --ram 1024 --ephemeral 5 --public
openstack flavor show t2.micro || openstack flavor create t2.micro --vcpus 1 --ram 1024 --ephemeral 5 --public
# ... (add the rest of t2.* flavors as needed)
fi fi
CIRROS_IMAGE_URL="http://download.cirros-cloud.net/0.5.2/cirros-0.5.2-x86_64-disk.img" # Try local mirror if flag exists
CIRROS_IMAGE_NAME="cirros-0.5.2-x86_64-disk.img" USE_LOCAL=false
if [ -f "try-local-images" ]; then
CIRROS_LOCAL_IMAGE_URL="http://www.ngtech.home/static/cloud-images/cirros-0.5.2-x86_64-disk.img" USE_LOCAL=true
if [ -f "try-local-images" ];then
( curl -I "${CIRROS_LOCAL_IMAGE_URL}" | grep 'HTTP/1.1 200 OK' )&& CIRROS_IMAGE_URL="${CIRROS_LOCAL_IMAGE_URL}"
fi fi
if [ ! -f "${IMAGES_DIR}/${CIRROS_IMAGE_NAME}" ];then # Cirros
wget "${CIRROS_IMAGE_URL}" -O "${IMAGES_DIR}/${CIRROS_IMAGE_NAME}" CIRROS_URL="http://download.cirros-cloud.net/0.5.2/cirros-0.5.2-x86_64-disk.img"
CIRROS_LOCAL="http://www.ngtech.home/static/cloud-images/cirros-0.5.2-x86_64-disk.img"
[ "$USE_LOCAL" = true ] && curl --fail --silent --head --location "${CIRROS_LOCAL}" >/dev/null && CIRROS_URL="${CIRROS_LOCAL}"
upload_image_if_needed "cirros" "${IMAGES_DIR}/cirros-0.5.2-x86_64-disk.img" "${CIRROS_URL}"
# AlmaLinux 8
ALMA8_URL="https://repo.almalinux.org/almalinux/8/cloud/x86_64/images/AlmaLinux-8-GenericCloud-latest.x86_64.qcow2"
ALMA8_LOCAL="http://www.ngtech.home/static/cloud-images/AlmaLinux-8-GenericCloud-latest.x86_64.qcow2"
[ "$USE_LOCAL" = true ] && curl --fail --silent --head --location "${ALMA8_LOCAL}" >/dev/null && ALMA8_URL="${ALMA8_LOCAL}"
upload_image_if_needed "almalinux-8" "${IMAGES_DIR}/AlmaLinux-8-GenericCloud-latest.x86_64.qcow2" "${ALMA8_URL}"
# AlmaLinux 9 (similar pattern)
ALMA9_URL="https://repo.almalinux.org/almalinux/9/cloud/x86_64/images/AlmaLinux-9-GenericCloud-latest.x86_64.qcow2"
ALMA9_LOCAL="http://www.ngtech.home/static/cloud-images/AlmaLinux-9-GenericCloud-latest.x86_64.qcow2"
[ "$USE_LOCAL" = true ] && curl --fail --silent --head --location "${ALMA9_LOCAL}" >/dev/null && ALMA9_URL="${ALMA9_LOCAL}"
upload_image_if_needed "almalinux-9" "${IMAGES_DIR}/AlmaLinux-9-GenericCloud-latest.x86_64.qcow2" "${ALMA9_URL}"
# AlmaLinux 10
ALMA10_URL="https://repo.almalinux.org/almalinux/10/cloud/x86_64/images/AlmaLinux-10-GenericCloud-latest.x86_64.qcow2"
ALMA10_LOCAL="http://www.ngtech.home/static/cloud-images/AlmaLinux-10-GenericCloud-latest.x86_64.qcow2"
[ "$USE_LOCAL" = true ] && curl --fail --silent --head --location "${ALMA10_LOCAL}" >/dev/null && ALMA10_URL="${ALMA10_LOCAL}"
upload_image_if_needed "almalinux-10" "${IMAGES_DIR}/AlmaLinux-10-GenericCloud-latest.x86_64.qcow2" "${ALMA10_URL}"
# Rocky Linux 9
ROCKY9_URL="https://dl.rockylinux.org/pub/rocky/9/images/x86_64/Rocky-9-GenericCloud-Base.latest.x86_64.qcow2"
ROCKY9_LOCAL="http://www.ngtech.home/static/cloud-images/Rocky-9-GenericCloud-Base.latest.x86_64.qcow2"
[ "$USE_LOCAL" = true ] && curl --fail --silent --head --location "${ROCKY9_LOCAL}" >/dev/null && ROCKY9_URL="${ROCKY9_LOCAL}"
upload_image_if_needed "rockylinux-9" "${IMAGES_DIR}/Rocky-9-GenericCloud-Base.latest.x86_64.qcow2" "${ROCKY9_URL}"
# Rocky Linux 10 - adjust if symlink changes
ROCKY10_URL="https://dl.rockylinux.org/pub/rocky/10/images/x86_64/Rocky-10-GenericCloud-Base.latest.x86_64.qcow2"
ROCKY10_LOCAL="http://www.ngtech.home/static/cloud-images/Rocky-10-GenericCloud-Base.latest.x86_64.qcow2"
[ "$USE_LOCAL" = true ] && curl --fail --silent --head --location "${ROCKY10_LOCAL}" >/dev/null && ROCKY10_URL="${ROCKY10_LOCAL}"
upload_image_if_needed "rockylinux-10" "${IMAGES_DIR}/Rocky-10-GenericCloud-Base.latest.x86_64.qcow2" "${ROCKY10_URL}"
# CentOS 7
CENTOS7_URL="https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-2111.qcow2"
CENTOS7_LOCAL="http://www.ngtech.home/static/cloud-images/CentOS-7-x86_64-GenericCloud-2111.qcow2"
[ "$USE_LOCAL" = true ] && curl --fail --silent --head --location "${CENTOS7_LOCAL}" >/dev/null && CENTOS7_URL="${CENTOS7_LOCAL}"
upload_image_if_needed "centos-7" "${IMAGES_DIR}/CentOS-7-x86_64-GenericCloud-2111.qcow2" "${CENTOS7_URL}"
# CentOS 8
CENTOS8_URL="https://cloud.centos.org/centos/8-stream/x86_64/images/CentOS-Stream-GenericCloud-8-latest.x86_64.qcow2"
CENTOS8_LOCAL="http://www.ngtech.home/static/cloud-images/CentOS-Stream-GenericCloud-8-latest.x86_64.qcow2"
[ "$USE_LOCAL" = true ] && curl --fail --silent --head --location "${CENTOS8_LOCAL}" >/dev/null && CENTOS8_URL="${CENTOS8_LOCAL}"
upload_image_if_needed "centos-stream-8" "${IMAGES_DIR}/CentOS-Stream-GenericCloud-8-latest.x86_64.qcow2" "${CENTOS8_URL}"
## CentOS 9
#CENTOS9_URL="https://cloud.centos.org/centos/8-stream/x86_64/images/CentOS-Stream-GenericCloud-8-latest.x86_64.qcow2"
#CENTOS9_LOCAL="http://www.ngtech.home/static/cloud-images/CentOS-Stream-GenericCloud-8-latest.x86_64.qcow2"
#[ "$USE_LOCAL" = true ] && curl --fail --silent --head --location "${CENTOS9_LOCAL}" >/dev/null && CENTOS9_URL="${CENTOS9_LOCAL}"
#upload_image_if_needed "centos-9-stream" "${IMAGES_DIR}/CentOS-Stream-GenericCloud-8-latest.x86_64.qcow2" "${CENTOS8_URL}"
# Oracle Linux 7
OL7_URL="https://yum.oracle.com/templates/OracleLinux/OL7/u9/x86_64/OL7U9_x86_64-kvm-b257.qcow2"
OL7_LOCAL="http://www.ngtech.home/static/cloud-images/OL7U9_x86_64-kvm-b257.qcow2"
[ "$USE_LOCAL" = true ] && curl --fail --silent --head --location "${OL7_LOCAL}" >/dev/null && OL7_URL="${OL7_LOCAL}"
upload_image_if_needed "oracle-linux-7" "${IMAGES_DIR}/OL7U9_x86_64-kvm-b257.qcow2" "${OL7_URL}"
# Oracle Linux 8
OL8_URL="https://yum.oracle.com/templates/OracleLinux/OL8/u10/x86_64/OL8U10_x86_64-kvm-b271.qcow2"
OL8_LOCAL="http://www.ngtech.home/static/cloud-images/OL8U10_x86_64-kvm-b271.qcow"
[ "$USE_LOCAL" = true ] && curl --fail --silent --head --location "${OL8_LOCAL}" >/dev/null && OL8_URL="${OL8_LOCAL}"
upload_image_if_needed "oracle-linux-8" "${IMAGES_DIR}/OL8U10_x86_64-kvm-b271.qcow" "${OL8_URL}"
# Oracle Linux 9
OL9_URL="https://yum.oracle.com/templates/OracleLinux/OL9/u7/x86_64/OL9U7_x86_64-k vm-b269.qcow2"
OL9_LOCAL="http://www.ngtech.home/static/cloud-images/OL9U7_x86_64-kvm-b269.qcow2"
[ "$USE_LOCAL" = true ] && curl --fail --silent --head --location "${OL9_LOCAL}" >/dev/null && OL9_URL="${OL9_LOCAL}"
upload_image_if_needed "oracle-linux-9" "${IMAGES_DIR}/OL9U7_x86_64-kvm-b269.qcow2" "${OL9_URL}"
# Oracle Linux 10
OL10_URL="https://yum.oracle.com/templates/OracleLinux/OL10/u1/x86_64/OL10U1_x86_64-kvm-b270.qcow2"
OL10_LOCAL="http://www.ngtech.home/static/cloud-images/OL10U1_x86_64-kvm-b270.qcow2"
[ "$USE_LOCAL" = true ] && curl --fail --silent --head --location "${OL10_LOCAL}" >/dev/null && OL10_URL="${OL10_LOCAL}"
upload_image_if_needed "oracle-linux-10" "${IMAGES_DIR}/OL10U1_x86_64-kvm-b270.qcow2" "${OL10_URL}"
# Fedora 43
FEDORA43_URL="https://download.fedoraproject.org/pub/fedora/linux/releases/43/Cloud/x86_64/images/Fedora-Cloud-Base-Generic-43-1.6.x86_64.qcow2"
FEDORA43_LOCAL="http://www.ngtech.home/static/cloud-images/Fedora-Cloud-Base-Generic-43-1.6.x86_64.qcow2"
[ "$USE_LOCAL" = true ] && curl --fail --silent --head --location "${FEDORA43_LOCAL}" >/dev/null && FEDORA43_URL="${FEDORA43_LOCAL}"
upload_image_if_needed "oracle-linux-10" "${IMAGES_DIR}/Fedora-Cloud-Base-Generic-43-1.6.x86_64.qcow2" "${FEDORA43_URL}"
# Debian 11 (example - repeat pattern for 10/11/13)
DEBIAN11_URL="https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-generic-amd64.qcow2"
DEBIAN12_LOCAL="http://www.ngtech.home/static/cloud-images/debian-11-generic-amd64.qcow2"
[ "$USE_LOCAL" = true ] && curl --fail --silent --head --location "${DEBIAN11_LOCAL}" >/dev/null && DEBIAN11_URL="${DEBIAN11_LOCAL}"
upload_image_if_needed "debian-11" "${IMAGES_DIR}/debian-11-generic-amd64.qcow2" "${DEBIAN11_URL}"
# Debian 12 (example - repeat pattern for 10/11/13)
DEBIAN12_URL="https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2"
DEBIAN12_LOCAL="http://www.ngtech.home/static/cloud-images/debian-12-generic-amd64.qcow2"
[ "$USE_LOCAL" = true ] && curl --fail --silent --head --location "${DEBIAN12_LOCAL}" >/dev/null && DEBIAN12_URL="${DEBIAN12_LOCAL}"
upload_image_if_needed "debian-12" "${IMAGES_DIR}/debian-12-generic-amd64.qcow2" "${DEBIAN12_URL}"
# Debian 13 (example - repeat pattern for 10/11/13)
DEBIAN13_URL="https://cloud.debian.org/images/cloud/trixie/latest/debian-13-generic-amd64.qcow2"
DEBIAN13_LOCAL="http://www.ngtech.home/static/cloud-images/debian-13-generic-amd64.qcow2"
[ "$USE_LOCAL" = true ] && curl --fail --silent --head --location "${DEBIAN13_LOCAL}" >/dev/null && DEBIAN13_URL="${DEBIAN13_LOCAL}"
upload_image_if_needed "debian-13" "${IMAGES_DIR}/debian-13-generic-amd64.qcow2" "${DEBIAN13_URL}"
# Ubuntu Jammy
UBUNTU_JAMMY_URL="https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"
UBUNTU_JAMMY_LOCAL="http://www.ngtech.home/static/cloud-images/jammy-server-cloudimg-amd64.img"
[ "$USE_LOCAL" = true ] && curl --fail --silent --head --location "${UBUNTU_JAMMY_LOCAL}" >/dev/null && UBUNTU_JAMMY_URL="${UBUNTU_JAMMY_LOCAL}"
upload_image_if_needed "ubuntu-noble" "${IMAGES_DIR}/jammy-server-cloudimg-amd64.img" "${UBUNTU_JAMMY_URL}"
# Ubuntu Focal 24.04
UBUNTU_FOCAL_URL="https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img"
UBUNTU_FOCAL_LOCAL="http://www.ngtech.home/static/cloud-images/focal-server-cloudimg-amd64.img"
[ "$USE_LOCAL" = true ] && curl --fail --silent --head --location "${UBUNTU_FOCAL_LOCAL}" >/dev/null && UBUNTU_FOCAL_URL="${UBUNTU_FOCAL_LOCAL}"
upload_image_if_needed "ubuntu-noble" "${IMAGES_DIR}/focal-server-cloudimg-amd64.img" "${UBUNTU_FOCAL_URL}"
# Ubuntu Noble (24.04)
UBUNTU_NOBLE_URL="https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img"
UBUNTU_NOBLE_LOCAL="http://www.ngtech.home/static/cloud-images/noble-server-cloudimg-amd64.img"
[ "$USE_LOCAL" = true ] && curl --fail --silent --head --location "${UBUNTU_NOBLE_LOCAL}" >/dev/null && UBUNTU_NOBLE_URL="${UBUNTU_NOBLE_LOCAL}"
upload_image_if_needed "ubuntu-noble" "${IMAGES_DIR}/noble-server-cloudimg-amd64.img" "${UBUNTU_NOBLE_URL}"
# openEuler 24.03 LTS SP3 - compressed .xz - special handling
OPENEULER_URL="https://mirrors.tuna.tsinghua.edu.cn/openeuler/openEuler-24.03-LTS-SP3/virtual_machine_img/x86_64/openEuler-24.03-LTS-SP3-x86_64.qcow2.xz"
OPENEULER_LOCAL="http://www.ngtech.home/static/cloud-images/openEuler-24.03-LTS-SP3-x86_64.qcow2.xz"
OPENEULER_ARCHIVE="${IMAGES_DIR}/openEuler-24.03-LTS-SP3-x86_64.qcow2.xz"
OPENEULER_FILE="${IMAGES_DIR}/openEuler-24.03-LTS-SP3-x86_64.qcow2"
[ "$USE_LOCAL" = true ] && curl --fail --silent --head --location "${OPENEULER_LOCAL}" >/dev/null && OPENEULER_URL="${OPENEULER_LOCAL}"
if openstack image show "openeuler-2403" >/dev/null 2>&1; then
echo "Image 'openeuler-2403' already exists — skipping"
else
if [ ! -f "${OPENEULER_FILE}" ]; then
if curl --fail --silent --head --location --max-time 12 "${OPENEULER_URL}" >/dev/null; then
echo "Downloading openEuler archive from ${OPENEULER_URL}"
wget --progress=bar "${OPENEULER_URL}" -O "${OPENEULER_ARCHIVE}" || { rm -f "${OPENEULER_ARCHIVE}"; echo "Download failed"; }
if [ -f "${OPENEULER_ARCHIVE}" ]; then
echo "Decompressing openEuler image..."
xz -d -k "${OPENEULER_ARCHIVE}" || { echo "Decompression failed"; rm -f "${OPENEULER_ARCHIVE}" "${OPENEULER_FILE}"; }
mv "${OPENEULER_ARCHIVE%.xz}" "${OPENEULER_FILE}" 2>/dev/null || true
fi
else
echo "openEuler remote not available — skipping"
fi
fi
if [ -f "${OPENEULER_FILE}" ]; then
openstack image create "openeuler-2403" \
--disk-format qcow2 \
--container-format bare \
--file "${OPENEULER_FILE}" \
--public || echo "Failed to upload openEuler"
fi
fi fi
openstack image show "cirros" || \ # Keypair (unchanged)
openstack image create "cirros" \ openstack keypair show multi || openstack keypair create --public-key multi.pub multi
--file "${IMAGES_DIR}/${CIRROS_IMAGE_NAME}" \
--disk-format qcow2 \
--container-format bare \
--public
echo "Bootstrap script completed."
# set +x # if you had set -x earlier
ALMA8_IMAGE_URL="https://repo.almalinux.org/almalinux/8/cloud/x86_64/images/AlmaLinux-8-GenericCloud-latest.x86_64.qcow2"
ALMA8_IMAGE_NAME="AlmaLinux-8-GenericCloud-latest.x86_64.qcow2"
ALMA8_LOCAL_IMAGE_URL="http://www.ngtech.home/static/cloud-images/AlmaLinux-8-GenericCloud-latest.x86_64.qcow2"
if [ -f "try-local-images" ];then
(curl -I "${ALMA8_LOCAL_IMAGE_URL}" | grep 'HTTP/1.1 200 OK' ) && ALMA8_IMAGE_URL="${ALMA8_LOCAL_IMAGE_URL}"
fi
if [ ! -f "${IMAGES_DIR}/${ALMA8_IMAGE_NAME}" ];then
wget "${ALMA8_IMAGE_URL}" -O "${IMAGES_DIR}/${ALMA8_IMAGE_NAME}"
fi
openstack image show "almalinux-8" || \
openstack image create "almalinux-8" \
--container-format bare \
--disk-format qcow2 \
--file "${IMAGES_DIR}/${ALMA8_IMAGE_NAME}" \
--public
ALMA9_IMAGE_URL="https://repo.almalinux.org/almalinux/9/cloud/x86_64/images/AlmaLinux-9-GenericCloud-latest.x86_64.qcow2"
ALMA9_IMAGE_NAME="AlmaLinux-9-GenericCloud-latest.x86_64.qcow2"
ALMA9_LOCAL_IMAGE_URL="http://www.ngtech.home/static/cloud-images/AlmaLinux-9-GenericCloud-latest.x86_64.qcow2"
if [ -f "try-local-images" ];then
(curl -I "${ALMA9_LOCAL_IMAGE_URL}" | grep 'HTTP/1.1 200 OK' ) && ALMA9_IMAGE_URL="${ALMA9_LOCAL_IMAGE_URL}"
fi
if [ ! -f "${IMAGES_DIR}/${ALMA9_IMAGE_NAME}" ];then
wget "${ALMA9_IMAGE_URL}" -O "${IMAGES_DIR}/${ALMA9_IMAGE_NAME}"
fi
openstack image show "almalinux-9" || \
openstack image create "almalinux-9" \
--container-format bare \
--disk-format qcow2 \
--file "${IMAGES_DIR}/${ALMA9_IMAGE_NAME}" \
--public
ALMA10_IMAGE_URL="https://raw.repo.almalinux.org/almalinux/10/cloud/x86_64/images/AlmaLinux-10-GenericCloud-latest.x86_64.qcow2"
ALMA10_IMAGE_NAME="AlmaLinux-10-GenericCloud-latest.x86_64.qcow2"
ALMA10_LOCAL_IMAGE_URL="http://www.ngtech.home/static/cloud-images/AlmaLinux-10-GenericCloud-latest.x86_64.qcow2"
if [ -f "try-local-images" ];then
(curl -I "${ALMA10_LOCAL_IMAGE_URL}" | grep 'HTTP/1.1 200 OK' ) && ALMA10_IMAGE_URL="${ALMA10_LOCAL_IMAGE_URL}"
fi
if [ ! -f "${IMAGES_DIR}/${ALMA10_IMAGE_NAME}" ];then
wget "${ALMA10_IMAGE_URL}" -O "${IMAGES_DIR}/${ALMA10_IMAGE_NAME}"
fi
openstack image show "almalinux-10" || \
openstack image create "almalinux-10" \
--container-format bare \
--disk-format qcow2 \
--file "${IMAGES_DIR}/${ALMA10_IMAGE_NAME}" \
--public
ROCKYLINUX9_IMAGE_URL="https://dl.rockylinux.org/pub/rocky/9/images/x86_64/Rocky-9-GenericCloud-Base.latest.x86_64.qcow2"
ROCKYLINUX9_IMAGE_NAME="Rocky-9-GenericCloud-Base.latest.x86_64.qcow2"
ROCKYLINUX9_LOCAL_IMAGE_URL="http://www.ngtech.home/static/cloud-images/Rocky-9-GenericCloud-Base.latest.x86_64.qcow2"
if [ -f "try-local-images" ];then
(curl -I "${ROCKYLINUX9_LOCAL_IMAGE_URL}" | grep 'HTTP/1.1 200 OK' ) && ROCKYLINUX9_IMAGE_URL="${ROCKYLINUX9_LOCAL_IMAGE_URL}"
fi
if [ ! -f "${IMAGES_DIR}/${ROCKYLINUX9_IMAGE_NAME}" ];then
wget "${ROCKYLINUX9_IMAGE_URL}" -O "${IMAGES_DIR}/${ROCKYLINUX9_IMAGE_NAME}"
fi
openstack image show "rockylinux-9" || \
openstack image create "rockylinux-9" \
--container-format bare \
--disk-format qcow2 \
--file "${IMAGES_DIR}/${ROCKYLINUX9_IMAGE_NAME}" \
--public
ROCKYLINUX10_IMAGE_URL="https://dl.rockylinux.org/pub/rocky/10/images/x86_64/Rocky-10-GenericCloud-Base.latest.x86_64.qcow2"
ROCKYLINUX10_IMAGE_NAME="Rocky-10-GenericCloud-Base.latest.x86_64.qcow2"
ROCKYLINUX10_LOCAL_IMAGE_URL="http://www.ngtech.home/static/cloud-images/Rocky-10-GenericCloud-Base.latest.x86_64.qcow2"
if [ -f "try-local-images" ];then
(curl -I "${ROCKYLINUX10_LOCAL_IMAGE_URL}" | grep 'HTTP/1.1 200 OK' ) && ROCKYLINUX10_IMAGE_URL="${ROCKYLINUX10_LOCAL_IMAGE_URL}"
fi
if [ ! -f "${IMAGES_DIR}/${ROCKYLINUX10_IMAGE_NAME}" ];then
wget "${ROCKYLINUX10_IMAGE_URL}" -O "${IMAGES_DIR}/${ROCKYLINUX10_IMAGE_NAME}"
fi
openstack image show "rockylinux-10" || \
openstack image create "rockylinux-10" \
--container-format bare \
--disk-format qcow2 \
--file "${IMAGES_DIR}/${ROCKYLINUX10_IMAGE_NAME}" \
--public
DEBIAN_10_IMAGE_URL="https://cdimage.debian.org/cdimage/openstack/current-10/debian-10-openstack-amd64.qcow2"
DEBIAN_10_IMAGE_NAME="debian-10-openstack-amd64.qcow2"
DEBIAN_10_LOCAL_IMAGE_URL="http://www.ngtech.home/static/cloud-images/debian-10-openstack-amd64.qcow2"
if [ -f "try-local-images" ];then
( curl -I "${DEBIAN_10_LOCAL_IMAGE_URL}" | grep 'HTTP/1.1 200 OK')&& DEBIAN_10_IMAGE_URL="${DEBIAN_10_LOCAL_IMAGE_URL}"
fi
if [ ! -f "${IMAGES_DIR}/${DEBIAN_10_IMAGE_NAME}" ];then
wget "${DEBIAN_10_IMAGE_URL}" -O "${IMAGES_DIR}/${DEBIAN_10_IMAGE_NAME}"
fi
openstack image show "debian-10" || \
openstack image create "debian-10" \
--container-format bare \
--disk-format qcow2 \
--file "${IMAGES_DIR}/${DEBIAN_10_IMAGE_NAME}" \
--public
DEBIAN_11_IMAGE_URL="https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-generic-amd64.qcow2"
DEBIAN_11_IMAGE_NAME="debian-11-generic-amd64.qcow2"
DEBIAN_11_LOCAL_IMAGE_URL="http://www.ngtech.home/static/cloud-images/debian-11-generic-amd64.qcow2"
if [ -f "try-local-images" ];then
( curl -I "${DEBIAN_11_LOCAL_IMAGE_URL}" | grep 'HTTP/1.1 200 OK' ) && DEBIAN_11_IMAGE_URL="${DEBIAN_11_LOCAL_IMAGE_URL}"
fi
if [ ! -f "${IMAGES_DIR}/${DEBIAN_11_IMAGE_NAME}" ];then
wget "${DEBIAN_11_IMAGE_URL}" -O "${IMAGES_DIR}/${DEBIAN_11_IMAGE_NAME}"
fi
openstack image show "debian-11" || \
openstack image create "debian-11" \
--container-format bare \
--disk-format qcow2 \
--file "${IMAGES_DIR}/${DEBIAN_11_IMAGE_NAME}" \
--public
DEBIAN_12_IMAGE_URL="https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2"
DEBIAN_12_IMAGE_NAME="debian-12-generic-amd64.qcow2"
DEBIAN_12_LOCAL_IMAGE_URL="http://www.ngtech.home/static/cloud-images/debian-12-generic-amd64.qcow2"
if [ -f "try-local-images" ];then
( curl -I "${DEBIAN_12_LOCAL_IMAGE_URL}" | grep 'HTTP/1.1 200 OK' ) && DEBIAN_12_IMAGE_URL="${DEBIAN_12_LOCAL_IMAGE_URL}"
fi
if [ ! -f "${IMAGES_DIR}/${DEBIAN_12_IMAGE_NAME}" ];then
wget "${DEBIAN_12_IMAGE_URL}" -O "${IMAGES_DIR}/${DEBIAN_12_IMAGE_NAME}"
fi
openstack image show "debian-12" || \
openstack image create "debian-12" \
--container-format bare \
--disk-format qcow2 \
--file "${IMAGES_DIR}/${DEBIAN_12_IMAGE_NAME}" \
--public
DEBIAN_13_IMAGE_URL="https://cloud.debian.org/images/cloud/trixie/latest/debian-13-generic-amd64.qcow2"
DEBIAN_13_IMAGE_NAME="debian-13-generic-amd64.qcow2"
DEBIAN_13_LOCAL_IMAGE_URL="http://www.ngtech.home/static/cloud-images/debian-13-generic-amd64.qcow2"
if [ -f "try-local-images" ];then
( curl -I "${DEBIAN_13_LOCAL_IMAGE_URL}" | grep 'HTTP/1.1 200 OK' ) && DEBIAN_13_IMAGE_URL="${DEBIAN_13_LOCAL_IMAGE_URL}"
fi
if [ ! -f "${IMAGES_DIR}/${DEBIAN_13_IMAGE_NAME}" ];then
wget "${DEBIAN_13_IMAGE_URL}" -O "${IMAGES_DIR}/${DEBIAN_13_IMAGE_NAME}"
fi
openstack image show "debian-13" || \
openstack image create "debian-13" \
--container-format bare \
--disk-format qcow2 \
--file "${IMAGES_DIR}/${DEBIAN_13_IMAGE_NAME}" \
--public
UBUNTU_JAMMY_IMAGE_URL="https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"
UBUNTU_JAMMY_IMAGE_NAME="jammy-server-cloudimg-amd64.img"
UBUNTU_JAMMY_LOCAL_IMAGE_URL="http://www.ngtech.home/static/cloud-images/jammy-server-cloudimg-amd64.img"
if [ -f "try-local-images" ];then
( curl -I "${UBUNTU_JAMMY_LOCAL_IMAGE_URL}" | grep 'HTTP/1.1 200 OK' ) && UBUNTU_JAMMY_IMAGE_URL="${UBUNTU_JAMMY_LOCAL_IMAGE_URL}"
fi
if [ ! -f "${IMAGES_DIR}/${UBUNTU_JAMMY_IMAGE_NAME}" ];then
wget "${UBUNTU_JAMMY_IMAGE_URL}" -O "${IMAGES_DIR}/${UBUNTU_JAMMY_IMAGE_NAME}"
fi
openstack image show "ubuntu-jammy" || \
openstack image create "ubuntu-jammy" \
--container-format bare \
--disk-format qcow2 \
--file "${IMAGES_DIR}/${UBUNTU_JAMMY_IMAGE_NAME}" \
--public
UBUNTU_FOCAL_IMAGE_URL="https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img"
UBUNTU_FOCAL_IMAGE_NAME="focal-server-cloudimg-amd64.img"
UBUNTU_FOCAL_LOCAL_IMAGE_URL="http://www.ngtech.home/static/cloud-images/focal-server-cloudimg-amd64.img"
if [ -f "try-local-images" ];then
(curl -I "${UBUNTU_FOCAL_LOCAL_IMAGE_URL}" | grep 'HTTP/1.1 200 OK' ) && UBUNTU_FOCAL_IMAGE_URL="${UBUNTU_FOCAL_LOCAL_IMAGE_URL}"
fi
if [ ! -f "${IMAGES_DIR}/${UBUNTU_FOCAL_IMAGE_NAME}" ];then
wget "${UBUNTU_FOCAL_IMAGE_URL}" -O "${IMAGES_DIR}/${UBUNTU_FOCAL_IMAGE_NAME}"
fi
openstack image show "ubuntu-focal" || \
openstack image create "ubuntu-focal" \
--container-format bare \
--disk-format qcow2 \
--file "${IMAGES_DIR}/${UBUNTU_FOCAL_IMAGE_NAME}" \
--public
UBUNTU_NOBLE_IMAGE_URL="https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img"
UBUNTU_NOBLE_IMAGE_NAME="noble-server-cloudimg-amd64.img"
UBUNTU_NOBLE_LOCAL_IMAGE_URL="http://www.ngtech.home/static/cloud-images/noble-server-cloudimg-amd64.img"
if [ -f "try-local-images" ];then
(curl -I "${UBUNTU_NOBLE_LOCAL_IMAGE_URL}" | grep 'HTTP/1.1 200 OK' ) && UBUNTU_NOBLE_IMAGE_URL="${UBUNTU_NOBLE_LOCAL_IMAGE_URL}"
fi
if [ ! -f "${IMAGES_DIR}/${UBUNTU_NOBLE_IMAGE_NAME}" ];then
wget "${UBUNTU_NOBLE_IMAGE_URL}" -O "${IMAGES_DIR}/${UBUNTU_NOBLE_IMAGE_NAME}"
fi
openstack image show "ubuntu-noble" || \
openstack image create "ubuntu-noble" \
--container-format bare \
--disk-format qcow2 \
--file "${IMAGES_DIR}/${UBUNTU_NOBLE_IMAGE_NAME}" \
--public
CENTOS8_IMAGE_URL="https://cloud.centos.org/centos/8-stream/x86_64/images/CentOS-Stream-GenericCloud-8-latest.x86_64.qcow2"
CENTOS8_IMAGE_NAME="CentOS-Stream-GenericCloud-8-latest.x86_64.qcow2"
CENTOS8_LOCAL_IMAGE_URL="http://www.ngtech.home/static/cloud-images/CentOS-Stream-GenericCloud-8-latest.x86_64.qcow2"
if [ -f "try-local-images" ];then
(curl -I "${CENTOS8_LOCAL_IMAGE_URL}" | grep 'HTTP/1.1 200 OK' ) && CENTOS8_IMAGE_URL="${CENTOS8_LOCAL_IMAGE_URL}"
fi
if [ ! -f "${IMAGES_DIR}/${CENTOS8_IMAGE_NAME}" ];then
wget "${CENTOS8_IMAGE_URL}" -O "${IMAGES_DIR}/${CENTOS8_IMAGE_NAME}"
fi
openstack image show "centos-stream-8" || \
openstack image create "centos-stream-8" \
--container-format bare \
--disk-format qcow2 \
--file "${IMAGES_DIR}/${CENTOS8_IMAGE_NAME}" \
--public
CENTOS7_IMAGE_URL="https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-2111.qcow2"
CENTOS7_IMAGE_NAME="CentOS-7-x86_64-GenericCloud.qcow2"
CENTOS7_LOCAL_IMAGE_URL="http://www.ngtech.home/static/cloud-images/CentOS-7-x86_64-GenericCloud.qcow2"
if [ -f "try-local-images" ];then
( curl -I "${CENTOS7_LOCAL_IMAGE_URL}" | grep 'HTTP/1.1 200 OK' ) && CENTOS7_IMAGE_URL="${CENTOS7_LOCAL_IMAGE_URL}"
fi
if [ ! -f "${IMAGES_DIR}/${CENTOS7_IMAGE_NAME}" ];then
wget "${CENTOS7_IMAGE_URL}" -O "${IMAGES_DIR}/${CENTOS7_IMAGE_NAME}"
fi
openstack image show "centos-7" || \
openstack image create "centos-7" \
--container-format bare \
--disk-format qcow2 \
--file "${IMAGES_DIR}/${CENTOS7_IMAGE_NAME}" \
--public
OL8_IMAGE_URL="https://yum.oracle.com/templates/OracleLinux/OL8/u6/x86_64/OL8U6_x86_64-kvm-b141.qcow"
OL8_IMAGE_NAME="OL8U6_x86_64-kvm.qcow"
OL8_LOCAL_IMAGE_URL="http://www.ngtech.home/static/cloud-images/OL8U6_x86_64-kvm.qcow"
if [ -f "try-local-images" ];then
( curl -I "${OL8_LOCAL_IMAGE_URL}" | grep 'HTTP/1.1 200 OK' ) && OL8_IMAGE_URL="${OL8_LOCAL_IMAGE_URL}"
fi
if [ ! -f "${IMAGES_DIR}/${OL8_IMAGE_NAME}" ];then
wget "${OL8_IMAGE_URL}" -O "${IMAGES_DIR}/${OL8_IMAGE_NAME}"
fi
openstack image show "oracle-linux-8" || \
openstack image create "oracle-linux-8" \
--container-format bare \
--disk-format qcow2 \
--file "${IMAGES_DIR}/${OL8_IMAGE_NAME}" \
--public
OL7_IMAGE_URL="https://yum.oracle.com/templates/OracleLinux/OL7/u9/x86_64/OL7U9_x86_64-kvm-b145.qcow"
OL7_IMAGE_NAME="OL7U9_x86_64-kvm.qcow"
OL7_LOCAL_IMAGE_URL="http://www.ngtech.home/static/cloud-images/OL7U9_x86_64-kvm.qcow"
if [ -f "try-local-images" ];then
( curl -I "${OL7_LOCAL_IMAGE_URL}" | grep 'HTTP/1.1 200 OK' ) && OL7_IMAGE_URL="${OL7_LOCAL_IMAGE_URL}"
fi
if [ ! -f "${IMAGES_DIR}/${OL7_IMAGE_NAME}" ];then
wget "${OL7_IMAGE_URL}" -O "${IMAGES_DIR}/${OL7_IMAGE_NAME}"
fi
openstack image show "oracle-linux-7" || \
openstack image create "oracle-linux-7" \
--container-format bare \
--disk-format qcow2 \
--file "${IMAGES_DIR}/${OL7_IMAGE_NAME}" \
--public
OL9_IMAGE_URL="https://yum.oracle.com/templates/OracleLinux/OL9/u0/x86_64/OL9U0_x86_64-kvm-b142.qcow"
OL9_IMAGE_NAME="OL9U0_x86_64-kvm.qcow"
OL9_LOCAL_IMAGE_URL="http://www.ngtech.home/static/cloud-images/OL9U0_x86_64-kvm.qcow"
if [ -f "try-local-images" ];then
( curl -I "${OL9_LOCAL_IMAGE_URL}" | grep 'HTTP/1.1 200 OK' ) && OL9_IMAGE_URL="${OL9_LOCAL_IMAGE_URL}"
fi
if [ ! -f "${IMAGES_DIR}/${OL9_IMAGE_NAME}" ];then
wget "${OL9_IMAGE_URL}" -O "${IMAGES_DIR}/${OL9_IMAGE_NAME}"
fi
openstack image show "oracle-linux-9" || \
openstack image create "oracle-linux-9" \
--container-format bare \
--disk-format qcow2 \
--file "${IMAGES_DIR}/${OL9_IMAGE_NAME}" \
--public
OPENENULAR_2403_IMAGE_URL="https://dl-cdn.openeuler.openatom.cn/openEuler-24.03-LTS-SP3/virtual_machine_img/x86_64/openEuler-24.03-LTS-SP3-x86_64.qcow2.xz"
OPENENULAR_2403_ARCHIVE="openEuler-24.03-LTS-SP3-x86_64.qcow2.xz"
OPENENULAR_2403_NAME="openEuler-24.03-LTS-SP3-x86_64.qcow2"
OPENENULAR_2403_LOCAL_IMAGE_URL="http://www.ngtech.home/static/cloud-images/penEuler-24.03-LTS-SP3-x86_64.qcow2.xz"
if [ -f "try-local-images" ];then
( curl -I "${OPENENULAR_2403_LOCAL_IMAGE_URL}" | grep 'HTTP/1.1 200 OK' ) && OPENENULAR_2403_IMAGE_URL="${OPENENULAR_2403_LOCAL_IMAGE_URL}"
fi
if [ ! -f "${IMAGES_DIR}/${OPENENULAR_2403_NAME}" ];then
wget "${OPENENULAR_2403_IMAGE_URL}" -O "${IMAGES_DIR}/${OPENENULAR_2403_ARCHIVE}"
xz -dkc "${IMAGES_DIR}/${OPENENULAR_2403_ARCHIVE}" > "${IMAGES_DIR}/${OPENENULAR_2403_NAME}"
fi
openstack image show "openenular-2403" || \
openstack image create "openenular-2403" \
--container-format bare \
--disk-format qcow2 \
--file "${IMAGES_DIR}/${OPENENULAR_2403_NAME}" \
--public
openstack keypair show multi || \
openstack keypair create --public-key multi.pub multi
FEDORA36_IMAGE_URL="https://download.fedoraproject.org/pub/fedora/linux/releases/36/Cloud/x86_64/images/Fedora-Cloud-Base-36-1.5.x86_64.qcow2"
FEDORA36_IMAGE_NAME="Fedora-Cloud-Base-36-1.5.x86_64.qcow2"
FEDORA36_LOCAL_IMAGE_URL="http://www.ngtech.home/static/cloud-images/Fedora-Cloud-Base-36-1.5.x86_64.qcow2"
if [ -f "try-local-images" ];then
( curl -I "${FEDORA36_LOCAL_IMAGE_URL}" | grep 'HTTP/1.1 200 OK' ) && FEDORA36_IMAGE_URL="${FEDORA36_LOCAL_IMAGE_URL}"
fi
if [ ! -f "${IMAGES_DIR}/${FEDORA36_IMAGE_NAME}" ];then
wget "${FEDORA36_IMAGE_URL}" -O "${IMAGES_DIR}/${FEDORA36_IMAGE_NAME}"
fi
openstack image show "fedora-36" || \
openstack image create "fedora-36" \
--container-format bare \
--disk-format qcow2 \
--file "${IMAGES_DIR}/${FEDORA36_IMAGE_NAME}" \
--public
openstack keypair show multi || \
openstack keypair create --public-key multi.pub multi
set +e
set +x