From 5aa60ab86f12f6e448ad5c94692e4e092c5b4ebe Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 30 Mar 2026 09:36:59 +0200 Subject: [PATCH 01/64] systemvmtemplate: bump to Debian 13 'trixie' and ACS 4.23 --- tools/appliance/systemvmtemplate/scripts/apt_upgrade.sh | 4 ++-- .../systemvmtemplate/scripts/configure_systemvm_services.sh | 4 ++-- .../template-base_aarch64-target_aarch64.json | 4 ++-- .../systemvmtemplate/template-base_x86_64-target_aarch64.json | 4 ++-- .../systemvmtemplate/template-base_x86_64-target_x86_64.json | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/appliance/systemvmtemplate/scripts/apt_upgrade.sh b/tools/appliance/systemvmtemplate/scripts/apt_upgrade.sh index 91a1dd3cdabc..6b6f5f10a1b5 100755 --- a/tools/appliance/systemvmtemplate/scripts/apt_upgrade.sh +++ b/tools/appliance/systemvmtemplate/scripts/apt_upgrade.sh @@ -36,8 +36,8 @@ function add_backports() { sed -i '/deb-src/d' /etc/apt/sources.list sed -i '/backports/d' /etc/apt/sources.list sed -i '/security/d' /etc/apt/sources.list - echo 'deb http://http.debian.net/debian bookworm-backports main' >> /etc/apt/sources.list - echo 'deb http://security.debian.org/debian-security bookworm-security main' >> /etc/apt/sources.list + echo 'deb http://http.debian.net/debian trixie-backports main' >> /etc/apt/sources.list + echo 'deb http://security.debian.org/debian-security trixie-security main' >> /etc/apt/sources.list } function apt_upgrade() { diff --git a/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh b/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh index 8bc71d29c1c0..c630ffb54cc7 100755 --- a/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh +++ b/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh @@ -19,7 +19,7 @@ set -e set -x -CLOUDSTACK_RELEASE=4.22.0 +CLOUDSTACK_RELEASE=4.23.0 function configure_apache2() { # Enable ssl, rewrite and auth @@ -41,7 +41,7 @@ function configure_issue() { __?.o/ Apache CloudStack SystemVM $CLOUDSTACK_RELEASE ( )# https://cloudstack.apache.org - (___(_) Debian GNU/Linux 12 \n \l + (___(_) Debian GNU/Linux 13 \n \l EOF } diff --git a/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json b/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json index f15552ca5cc4..cc25b1a6b4d1 100644 --- a/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json +++ b/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json @@ -32,8 +32,8 @@ "format": "qcow2", "headless": true, "http_directory": "http", - "iso_checksum": "sha512:55ab206cd8b0da2898767c3eb6ab5ebef101e3925ec91b3b5f0a286136195b7072588f6ac2d059c545c6938978704ae78cd18d7d9d2a86a7380e46ce27ee4e7b", - "iso_url": "https://cdimage.debian.org/mirror/cdimage/archive/12.12.0/arm64/iso-cd/debian-12.12.0-arm64-netinst.iso", + "iso_checksum": "sha512:d3749e6b47c715cf12ba0685bc1bb8859d09ae87c0d99af5e02f336726966f5d06b0b72f6135aac1cbcf337900618f72e898bf2e94509ad75d7e5d28af45f064", + "iso_url": "https://cdimage.debian.org/mirror/cdimage/release/13.4.0/arm64/iso-cd/debian-13.4.0-arm64-netinst.iso", "net_device": "virtio-net", "output_directory": "../dist", "qemu_binary": "qemu-system-aarch64", diff --git a/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json b/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json index c16bf1fb2a29..556407bc476c 100644 --- a/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json +++ b/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json @@ -31,8 +31,8 @@ "format": "qcow2", "headless": true, "http_directory": "http", - "iso_checksum": "sha512:55ab206cd8b0da2898767c3eb6ab5ebef101e3925ec91b3b5f0a286136195b7072588f6ac2d059c545c6938978704ae78cd18d7d9d2a86a7380e46ce27ee4e7b", - "iso_url": "https://cdimage.debian.org/mirror/cdimage/archive/12.12.0/arm64/iso-cd/debian-12.12.0-arm64-netinst.iso", + "iso_checksum": "sha512:d3749e6b47c715cf12ba0685bc1bb8859d09ae87c0d99af5e02f336726966f5d06b0b72f6135aac1cbcf337900618f72e898bf2e94509ad75d7e5d28af45f064", + "iso_url": "https://cdimage.debian.org/mirror/cdimage/release/13.4.0/arm64/iso-cd/debian-13.4.0-arm64-netinst.iso", "net_device": "virtio-net", "output_directory": "../dist", "qemu_binary": "qemu-system-aarch64", diff --git a/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json b/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json index 941eea9dcd7b..71ff06ab4841 100644 --- a/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json +++ b/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json @@ -27,8 +27,8 @@ "format": "qcow2", "headless": true, "http_directory": "http", - "iso_checksum": "sha512:c93055182057dd19a334260671c7e10880541b7721ad9c8df87be47e0a11d5bbf85018350ff224ff6a5f6a68320b07e95d539cef9dc020c93966bfaa86d4b2ce", - "iso_url": "https://cdimage.debian.org/mirror/cdimage/archive/12.12.0/amd64/iso-cd/debian-12.12.0-amd64-netinst.iso", + "iso_checksum": "sha512:3e02de4ed744799350bd4039b137053835238ff9f9f29eee812309cd7eebdb5127b0f2b54d167b76d324530aa16939b41ae2d2f2d1995a2801e19938acdc927f", + "iso_url": "https://cdimage.debian.org/mirror/cdimage/release/13.4.0/amd64/iso-cd/debian-13.4.0-amd64-netinst.iso", "net_device": "virtio-net", "output_directory": "../dist", "qemuargs": [ From 3d9140222b84c06335a6ec903fa3f614defde725 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 30 Mar 2026 09:17:30 +0000 Subject: [PATCH 02/64] pom.xml: update to systemvm template 4.23.0.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 80111b26a4ab..5fef4a862171 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ UTF-8 UTF-8 https://download.cloudstack.org/systemvm - 4.22.0.0 + 4.23.0.0 apache https://sonarcloud.io engine/schema/src/main/java/org/apache/cloudstack/backup/BackupOfferingDetailsVO.java From 0300e07ad2939f2a18c0d88cb297a03160081565 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Tue, 13 Oct 2026 13:41:54 +0000 Subject: [PATCH 03/64] Update URL and ACS version --- pom.xml | 2 +- .../systemvmtemplate/scripts/configure_systemvm_services.sh | 2 +- .../template-base_aarch64-target_aarch64.json | 4 ++-- .../systemvmtemplate/template-base_x86_64-target_aarch64.json | 4 ++-- .../systemvmtemplate/template-base_x86_64-target_x86_64.json | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 5fef4a862171..8a1c7a27652d 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ UTF-8 UTF-8 https://download.cloudstack.org/systemvm - 4.23.0.0 + 24.0.0 apache https://sonarcloud.io engine/schema/src/main/java/org/apache/cloudstack/backup/BackupOfferingDetailsVO.java diff --git a/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh b/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh index c630ffb54cc7..e30bd97896a3 100755 --- a/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh +++ b/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh @@ -19,7 +19,7 @@ set -e set -x -CLOUDSTACK_RELEASE=4.23.0 +CLOUDSTACK_RELEASE=24.0 function configure_apache2() { # Enable ssl, rewrite and auth diff --git a/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json b/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json index cc25b1a6b4d1..fe1e363423e2 100644 --- a/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json +++ b/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json @@ -32,8 +32,8 @@ "format": "qcow2", "headless": true, "http_directory": "http", - "iso_checksum": "sha512:d3749e6b47c715cf12ba0685bc1bb8859d09ae87c0d99af5e02f336726966f5d06b0b72f6135aac1cbcf337900618f72e898bf2e94509ad75d7e5d28af45f064", - "iso_url": "https://cdimage.debian.org/mirror/cdimage/release/13.4.0/arm64/iso-cd/debian-13.4.0-arm64-netinst.iso", + "iso_checksum": "sha512:cff08e2f29c2846f0503fe57ad1085b5067f29acab444acdf7cdf5b10f2a11140a0e87828e4ffeb9828d188053690467ebe50151c142551d6053fc3288808b86", + "iso_url": "https://cdimage.debian.org/mirror/cdimage/release/13.7.0/arm64/iso-cd/debian-13.7.0-arm64-netinst.iso", "net_device": "virtio-net", "output_directory": "../dist", "qemu_binary": "qemu-system-aarch64", diff --git a/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json b/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json index 556407bc476c..5c15d35888c3 100644 --- a/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json +++ b/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json @@ -31,8 +31,8 @@ "format": "qcow2", "headless": true, "http_directory": "http", - "iso_checksum": "sha512:d3749e6b47c715cf12ba0685bc1bb8859d09ae87c0d99af5e02f336726966f5d06b0b72f6135aac1cbcf337900618f72e898bf2e94509ad75d7e5d28af45f064", - "iso_url": "https://cdimage.debian.org/mirror/cdimage/release/13.4.0/arm64/iso-cd/debian-13.4.0-arm64-netinst.iso", + "iso_checksum": "sha512:cff08e2f29c2846f0503fe57ad1085b5067f29acab444acdf7cdf5b10f2a11140a0e87828e4ffeb9828d188053690467ebe50151c142551d6053fc3288808b86", + "iso_url": "https://cdimage.debian.org/mirror/cdimage/release/13.7.0/arm64/iso-cd/debian-13.7.0-arm64-netinst.iso", "net_device": "virtio-net", "output_directory": "../dist", "qemu_binary": "qemu-system-aarch64", diff --git a/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json b/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json index 71ff06ab4841..967645b500d5 100644 --- a/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json +++ b/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json @@ -27,8 +27,8 @@ "format": "qcow2", "headless": true, "http_directory": "http", - "iso_checksum": "sha512:3e02de4ed744799350bd4039b137053835238ff9f9f29eee812309cd7eebdb5127b0f2b54d167b76d324530aa16939b41ae2d2f2d1995a2801e19938acdc927f", - "iso_url": "https://cdimage.debian.org/mirror/cdimage/release/13.4.0/amd64/iso-cd/debian-13.4.0-amd64-netinst.iso", + "iso_checksum": "sha512:ef04d0276850d70e4aaec0b55003628660e9631b26e35215a70ab3c8c707294a4b12731bc73c75a932902f703a7c278310ca99df28d6b36fb06d5618d8d0f678", + "iso_url": "https://cdimage.debian.org/mirror/cdimage/release/13.7.0/amd64/iso-cd/debian-13.7.0-amd64-netinst.iso", "net_device": "virtio-net", "output_directory": "../dist", "qemuargs": [ From 9c402d8a0191add2a395710dd7982f4e3e6d8c47 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Tue, 13 Oct 2026 16:50:55 +0200 Subject: [PATCH 04/64] systemvmtemplate: fix build on Debian 13 - use openjdk-21-jre-headless, as openjdk-17-jre-headless is not available in Debian 13 - drop software-properties-common, which is not available in Debian 13 - configure the Docker apt repository with a keyring in /etc/apt/keyrings and a sources.list.d entry instead of apt-key and add-apt-repository; use VERSION_CODENAME from /etc/os-release instead of lsb_release - install chrony in the preseed files, as the ntp package is not available in Debian 13 - do not fail if /etc/apt/sources.list does not exist, and add the backports and security repositories in sources.list.d - disable the cloud-init units that exist, as cloud-init.service no longer exists and stopping it failed the build --- .../systemvmtemplate/http/preseed_aarch64.cfg | 2 +- .../systemvmtemplate/http/preseed_x86_64.cfg | 2 +- .../systemvmtemplate/scripts/apt_upgrade.sh | 18 ++++++++++------ .../scripts/configure_systemvm_services.sh | 8 +++++-- .../scripts/install_systemvm_packages.sh | 21 ++++++++----------- 5 files changed, 29 insertions(+), 22 deletions(-) diff --git a/tools/appliance/systemvmtemplate/http/preseed_aarch64.cfg b/tools/appliance/systemvmtemplate/http/preseed_aarch64.cfg index 5262603deaa4..92e426d3d0d2 100644 --- a/tools/appliance/systemvmtemplate/http/preseed_aarch64.cfg +++ b/tools/appliance/systemvmtemplate/http/preseed_aarch64.cfg @@ -107,7 +107,7 @@ d-i passwd/user-default-groups string audio cdrom video admin ### Package selection tasksel tasksel/first multiselect ssh-server -d-i pkgsel/include string openssh-server ntp acpid sudo bzip2 openssl +d-i pkgsel/include string openssh-server chrony acpid sudo bzip2 openssl # Allowed values: none, safe-upgrade, full-upgrade d-i pkgsel/upgrade select full-upgrade d-i pkgsel/update-policy select none diff --git a/tools/appliance/systemvmtemplate/http/preseed_x86_64.cfg b/tools/appliance/systemvmtemplate/http/preseed_x86_64.cfg index 1ed0edd492f9..fdcfe83c1010 100644 --- a/tools/appliance/systemvmtemplate/http/preseed_x86_64.cfg +++ b/tools/appliance/systemvmtemplate/http/preseed_x86_64.cfg @@ -98,7 +98,7 @@ d-i passwd/user-default-groups string audio cdrom video admin ### Package selection tasksel tasksel/first multiselect ssh-server -d-i pkgsel/include string openssh-server ntp acpid sudo bzip2 openssl +d-i pkgsel/include string openssh-server chrony acpid sudo bzip2 openssl # Allowed values: none, safe-upgrade, full-upgrade d-i pkgsel/upgrade select full-upgrade d-i pkgsel/update-policy select none diff --git a/tools/appliance/systemvmtemplate/scripts/apt_upgrade.sh b/tools/appliance/systemvmtemplate/scripts/apt_upgrade.sh index 6b6f5f10a1b5..38336dd0ac1d 100755 --- a/tools/appliance/systemvmtemplate/scripts/apt_upgrade.sh +++ b/tools/appliance/systemvmtemplate/scripts/apt_upgrade.sh @@ -32,12 +32,18 @@ function fix_tune2fs() { } function add_backports() { - sed -i '/cdrom/d' /etc/apt/sources.list - sed -i '/deb-src/d' /etc/apt/sources.list - sed -i '/backports/d' /etc/apt/sources.list - sed -i '/security/d' /etc/apt/sources.list - echo 'deb http://http.debian.net/debian trixie-backports main' >> /etc/apt/sources.list - echo 'deb http://security.debian.org/debian-security trixie-security main' >> /etc/apt/sources.list + # Debian 13 installs apt sources in /etc/apt/sources.list.d/debian.sources + # and /etc/apt/sources.list may not exist + if [ -f /etc/apt/sources.list ]; then + sed -i '/cdrom/d' /etc/apt/sources.list + sed -i '/deb-src/d' /etc/apt/sources.list + sed -i '/backports/d' /etc/apt/sources.list + sed -i '/security/d' /etc/apt/sources.list + fi + cat > /etc/apt/sources.list.d/backports-security.list << EOF +deb http://http.debian.net/debian trixie-backports main +deb http://security.debian.org/debian-security trixie-security main +EOF } function apt_upgrade() { diff --git a/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh b/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh index e30bd97896a3..455e59915f87 100755 --- a/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh +++ b/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh @@ -142,8 +142,12 @@ datasource: EOF touch /etc/cloud/cloud-init.disabled - systemctl stop cloud-init - systemctl disable cloud-init + # cloud-init.service was split into several units in newer cloud-init versions + for svc in cloud-init cloud-init-local cloud-init-main cloud-init-network cloud-config cloud-final; do + if systemctl cat ${svc}.service > /dev/null 2>&1; then + systemctl disable ${svc}.service + fi + done configure_apache2 configure_strongswan diff --git a/tools/appliance/systemvmtemplate/scripts/install_systemvm_packages.sh b/tools/appliance/systemvmtemplate/scripts/install_systemvm_packages.sh index d391b5c4e192..00ab7e194a33 100755 --- a/tools/appliance/systemvmtemplate/scripts/install_systemvm_packages.sh +++ b/tools/appliance/systemvmtemplate/scripts/install_systemvm_packages.sh @@ -66,7 +66,7 @@ function install_packages() { xenstore-utils libxenstore4 \ ipvsadm conntrackd libnetfilter-conntrack3 \ keepalived irqbalance \ - openjdk-17-jre-headless \ + openjdk-21-jre-headless \ ipcalc ipset \ iptables-persistent \ libtcnative-1 libssl-dev libapr1-dev \ @@ -77,7 +77,7 @@ function install_packages() { sharutils genisoimage \ strongswan libcharon-extra-plugins libstrongswan-extra-plugins strongswan-charon strongswan-starter \ virt-what open-vm-tools qemu-guest-agent hyperv-daemons cloud-guest-utils \ - conntrack apt-transport-https ca-certificates curl gnupg gnupg-agent software-properties-common + conntrack apt-transport-https ca-certificates curl gnupg gnupg-agent apt-get install -y python3-json-pointer python3-jsonschema cloud-init @@ -91,17 +91,14 @@ function install_packages() { fi # Install docker and containerd for CKS - curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - - apt-key fingerprint 0EBFCD88 - if [ "${arch}" == "arm64" ]; then - add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" - elif [ "${arch}" == "amd64" ]; then - add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" - elif [ "${arch}" == "s390x" ]; then - add-apt-repository "deb [arch=s390x] https://download.docker.com/linux/debian $(lsb_release -cs) stable" - else - add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" + local docker_arch="${arch}" + if [[ "${arch}" != "arm64" && "${arch}" != "amd64" && "${arch}" != "s390x" ]]; then + docker_arch="amd64" fi + install -m 0755 -d /etc/apt/keyrings + curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc + chmod a+r /etc/apt/keyrings/docker.asc + echo "deb [arch=${docker_arch} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo "${VERSION_CODENAME}") stable" > /etc/apt/sources.list.d/docker.list apt-get update ${apt_get} install containerd.io From cad91387518813b2fe58a43af2a08e9c4eed730e Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Tue, 13 Oct 2026 21:20:45 +0200 Subject: [PATCH 05/64] engine-schema: use new systemvm template directory and file names For 24.x and later the systemvm templates are published in a directory named after the major version, with the major.minor version in the file names (24/systemvmtemplate-24.0-x86_64-kvm.qcow2.bz2), instead of major.minor and major.minor.patch (4.22/systemvmtemplate-4.22.0-...). --- engine/schema/pom.xml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/engine/schema/pom.xml b/engine/schema/pom.xml index 6e078d7ec9f8..a92845184e95 100644 --- a/engine/schema/pom.xml +++ b/engine/schema/pom.xml @@ -88,8 +88,15 @@ From 405cdf452b8523a2f078c869ff89d16863a2abfb Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Fri, 16 Oct 2026 08:32:17 +0200 Subject: [PATCH 06/64] engine-schema: use new systemvm template names in metadata and export script For 24.x and later, templateConfig.sh generates metadata.ini with the templates in the directory named after the major version and with major.minor in the file and template names (24/systemvmtemplate-24.0-..., systemvm-kvm-24.0-x86_64), so that the checksums are found in sha512sum.txt. The version in metadata.ini is unchanged (24.0.0). export-templates.sh uses major.minor for the template file names too. Legacy (4.x) behavior is unchanged. Tests are updated and extended. --- engine/schema/templateConfig.sh | 10 +++++--- engine/schema/test_templateConfig.sh | 33 +++++++++++++++++++++++---- scripts/installer/export-templates.sh | 4 ++-- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/engine/schema/templateConfig.sh b/engine/schema/templateConfig.sh index 7a8283e77c1c..71b395689c15 100755 --- a/engine/schema/templateConfig.sh +++ b/engine/schema/templateConfig.sh @@ -28,9 +28,7 @@ function getTemplateVersion() { subversion2="$(cut -d'.' -f2 <<<"$version")" minorversion="$(cut -d'.' -f3 <<<"$version")" fourthversion="$(cut -d'.' -f4 <<<"$version")" - export CS_VERSION="${subversion1}"."${subversion2}" export CS_MINOR_VERSION="${minorversion}" - export VERSION="${CS_VERSION}.${CS_MINOR_VERSION}" if [[ "$subversion1" -ge "$NEW_VERSIONING_CUTOVER_MAJOR_VERSION" ]]; then # New versioning (major.minor.security): the third component is the # security release itself, there is no separate patch component. A @@ -40,11 +38,17 @@ function getTemplateVersion() { echo "Invalid version '${projVersion}': major versions at or above ${NEW_VERSIONING_CUTOVER_MAJOR_VERSION} do not support a 4-component major.minor.patch.security format" >&2 exit 1 fi - export FULL_VERSION="${VERSION}" + # The templates are in the directory named after the major version (24), + # and the file names contain major.minor (24.0), like 4.22 and 4.22.0 before + export CS_VERSION="${subversion1}" + export VERSION="${subversion1}.${subversion2}" + export FULL_VERSION="${subversion1}.${subversion2}.${minorversion}" else # Legacy versioning: major.minor.patch, or major.minor.patch.security when a 4th # component is present. Without a 4th component, VERSION is already correct as-is; # appending an empty security component would leave a dangling trailing dot. + export CS_VERSION="${subversion1}"."${subversion2}" + export VERSION="${CS_VERSION}.${CS_MINOR_VERSION}" if [[ -n "$fourthversion" ]]; then export FULL_VERSION="${VERSION}.${fourthversion}" else diff --git a/engine/schema/test_templateConfig.sh b/engine/schema/test_templateConfig.sh index 2acb4281edb7..95cab07fb280 100755 --- a/engine/schema/test_templateConfig.sh +++ b/engine/schema/test_templateConfig.sh @@ -51,6 +51,7 @@ assert_eq "legacy: VERSION" "4.22.0" "$VERSION" assert_eq "legacy: FULL_VERSION keeps the 4th (security) component" "4.22.0.0" "$FULL_VERSION" getTemplateVersion "4.23.0.1-SNAPSHOT" +assert_eq "legacy with -SNAPSHOT suffix: CS_VERSION" "4.23" "$CS_VERSION" assert_eq "legacy with -SNAPSHOT suffix: VERSION" "4.23.0" "$VERSION" assert_eq "legacy with -SNAPSHOT suffix: FULL_VERSION" "4.23.0.1" "$FULL_VERSION" @@ -62,16 +63,18 @@ assert_eq "legacy 3-component (no security): FULL_VERSION has no trailing dot" " # --- getTemplateVersion: new versioning (major >= 24, post-cutover) --- getTemplateVersion "24.0.0" -assert_eq "cutover: CS_VERSION" "24.0" "$CS_VERSION" -assert_eq "cutover: VERSION" "24.0.0" "$VERSION" +assert_eq "cutover: CS_VERSION (directory) is the major version" "24" "$CS_VERSION" +assert_eq "cutover: VERSION (file names) is major.minor" "24.0" "$VERSION" assert_eq "cutover: FULL_VERSION has no trailing dot (patch dropped)" "24.0.0" "$FULL_VERSION" getTemplateVersion "24.1.2-SNAPSHOT" -assert_eq "cutover with -SNAPSHOT suffix: VERSION" "24.1.2" "$VERSION" +assert_eq "cutover with -SNAPSHOT suffix: CS_VERSION" "24" "$CS_VERSION" +assert_eq "cutover with -SNAPSHOT suffix: VERSION" "24.1" "$VERSION" assert_eq "cutover with -SNAPSHOT suffix: FULL_VERSION" "24.1.2" "$FULL_VERSION" getTemplateVersion "99.9.9" -assert_eq "future major: VERSION" "99.9.9" "$VERSION" +assert_eq "future major: CS_VERSION" "99" "$CS_VERSION" +assert_eq "future major: VERSION" "99.9" "$VERSION" assert_eq "future major: FULL_VERSION" "99.9.9" "$FULL_VERSION" # A 4-component major.minor.patch.security value is invalid at/after the cutover (matches @@ -96,7 +99,7 @@ run_create_metadata_file() { : > "$METADATAFILE" createMetadataFile - grep '^version = ' "$METADATAFILE" | head -1 | cut -d' ' -f3 + grep "^${2:-version} = " "$METADATAFILE" | head -1 | cut -d' ' -f3 rm -rf "$workdir" } @@ -107,6 +110,26 @@ assert_eq "metadata.ini legacy 'version' line" "4.22.0.0" "$actual" actual="$(run_create_metadata_file "24.0.0")" assert_eq "metadata.ini cutover 'version' line has no trailing dot" "24.0.0" "$actual" +# --- createMetadataFile: file names, directory, template name and checksum --- + +actual="$(run_create_metadata_file "4.22.0.0" downloadurl)" +assert_eq "metadata.ini legacy downloadurl" "https://download.cloudstack.org/systemvm//4.22/systemvmtemplate-4.22.0-x86_64-kvm.qcow2.bz2" "$actual" +actual="$(run_create_metadata_file "4.22.0.0" templatename)" +assert_eq "metadata.ini legacy templatename" "systemvm-kvm-4.22.0-x86_64" "$actual" +actual="$(run_create_metadata_file "4.22.0.0" checksum)" +assert_eq "metadata.ini legacy checksum is found" "abc123" "$actual" + +actual="$(run_create_metadata_file "24.0.0" downloadurl)" +assert_eq "metadata.ini cutover downloadurl" "https://download.cloudstack.org/systemvm//24/systemvmtemplate-24.0-x86_64-kvm.qcow2.bz2" "$actual" +actual="$(run_create_metadata_file "24.0.0" filename)" +assert_eq "metadata.ini cutover filename" "systemvmtemplate-24.0-x86_64-kvm.qcow2.bz2" "$actual" +actual="$(run_create_metadata_file "24.0.0" templatename)" +assert_eq "metadata.ini cutover templatename" "systemvm-kvm-24.0-x86_64" "$actual" +actual="$(run_create_metadata_file "24.0.0" checksum)" +assert_eq "metadata.ini cutover checksum is found" "abc123" "$actual" +actual="$(run_create_metadata_file "24.0.1" downloadurl)" +assert_eq "metadata.ini cutover security release uses the same template" "https://download.cloudstack.org/systemvm//24/systemvmtemplate-24.0-x86_64-kvm.qcow2.bz2" "$actual" + echo "" echo "${pass} passed, ${fail} failed" [[ $fail -eq 0 ]] diff --git a/scripts/installer/export-templates.sh b/scripts/installer/export-templates.sh index 820596837131..5d38ac54472a 100755 --- a/scripts/installer/export-templates.sh +++ b/scripts/installer/export-templates.sh @@ -26,8 +26,8 @@ TEMPLATE_VERSION=$(awk -F "=" '/version/ {print $2}' ${IMAGE_PATH}${METADATA_FIL TEMPLATE_PATH="/usr/share/cloudstack-management/templates/systemvm/" TEMPLATE_MAJOR_VERSION="$(cut -d'.' -f1 <<<"$TEMPLATE_VERSION")" if [[ "$TEMPLATE_MAJOR_VERSION" -ge "$NEW_VERSIONING_CUTOVER_MAJOR_VERSION" ]]; then - # New versioning (major.minor.security): the generated template files use the full version as-is. - VERSION="${TEMPLATE_VERSION}" + # New versioning (major.minor.security): the template files contain major.minor, without the security component. + VERSION="$(cut -d'.' -f1,2 <<<"$TEMPLATE_VERSION")" else # Legacy versioning drops the trailing security component only for four-component metadata; # a valid three-component major.minor.patch value is already the filename version. From 3308b7cf88a4283d3f9b57fe23b81c71a0c6ebe5 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 19 Oct 2026 18:41:48 +0200 Subject: [PATCH 07/64] setup: update the Debian 13 templates, add build-acs-image.sh - templates.sql: use the patched Debian 13 images (20261017-2634) from http://10.0.34.8/templates/debian-13-genericcloud-amd64/ for the KVM, XenServer (vhd.bz2) and VMware (ova) templates, with their SHA-512 checksums - scripts/util/build-acs-image.sh: new script to patch, shrink and convert a cloud image (qcow2) to VHD, OVA and XenServer VHD for CloudStack, and to create SHA512SUMS - schema-21to22.sql, schema-2214to30.sql: remove the inserts of the old CentOS 5 builtin templates (ids 4, 7 and 5) --- .../resources/META-INF/db/schema-21to22.sql | 5 - .../resources/META-INF/db/schema-2214to30.sql | 3 - scripts/util/build-acs-image.sh | 601 ++++++++++++++++++ setup/db/templates.sql | 6 +- 4 files changed, 604 insertions(+), 11 deletions(-) create mode 100755 scripts/util/build-acs-image.sh diff --git a/engine/schema/src/main/resources/META-INF/db/schema-21to22.sql b/engine/schema/src/main/resources/META-INF/db/schema-21to22.sql index 8da29caae53b..6905f62e84ca 100755 --- a/engine/schema/src/main/resources/META-INF/db/schema-21to22.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-21to22.sql @@ -964,11 +964,6 @@ INSERT INTO `cloud`.`vm_template` (id, unique_name, name, public, created, type, INSERT INTO `cloud`.`vm_template` (id, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type) VALUES (8, 'routing-8', 'SystemVM Template (vSphere)', 0, now(), 'SYSTEM', 0, 32, 1, 'http://download.cloudstack.org/releases/2.2.0/systemvm.ova', '3c9d4c704af44ebd1736e1bc78cec1fa', 0, 'SystemVM Template (vSphere)', 'OVA', 15, 0, 1, 'VMware'); -INSERT INTO `cloud`.`vm_template` (id, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, display_text, enable_password, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (4, 'centos55-x86_64', 'CentOS 5.5(64-bit) no GUI (KVM)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/2.2.0/eec2209b-9875-3c8d-92be-c001bd8a0faf.qcow2.bz2', 'ed0e788280ff2912ea40f7f91ca7a249', 'CentOS 5.5(64-bit) no GUI (KVM)', 0, 'QCOW2', 112, 1, 1, 'KVM', 1); - -INSERT INTO `cloud`.`vm_template` (id, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (7, 'centos53-x64', 'CentOS 5.3(64-bit) no GUI (vSphere)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/2.2.0/CentOS5.3-x86_64.ova', 'f6f881b7f2292948d8494db837fe0f47', 0, 'CentOS 5.3(64-bit) no GUI (vSphere)', 'OVA', 12, 1, 1, 'VMware', 1); UPDATE vm_instance SET guest_os_id=15 where vm_template_id=1; UPDATE vm_instance SET vm_template_id=(SELECT id FROM vm_template WHERE name='systemvm-xenserver-2.2.4' AND removed IS NULL) where vm_template_id=1; diff --git a/engine/schema/src/main/resources/META-INF/db/schema-2214to30.sql b/engine/schema/src/main/resources/META-INF/db/schema-2214to30.sql index 8be481e47368..fdb260e57728 100755 --- a/engine/schema/src/main/resources/META-INF/db/schema-2214to30.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-2214to30.sql @@ -625,9 +625,6 @@ UPDATE `cloud`.`event` e set e.domain_id = (select acc.domain_id from `cloud`.`a update `cloud`.`vm_template` set removed=now() where id=2; -INSERT INTO `cloud`.`vm_template` (id, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (5, 'centos56-x86_64-xen', 'CentOS 5.6(64-bit) no GUI (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/templates/builtin/centos56-x86_64.vhd.bz2', '905cec879afd9c9d22ecc8036131a180', 0, 'CentOS 5.6(64-bit) no GUI (XenServer)', 'VHD', 12, 1, 1, 'XenServer', 1); - DELETE from `cloud`.`configuration` where name='firewall.rule.ui.enabled'; DELETE FROM `cloud`.`resource_limit` WHERE domain_id = 1 AND account_id IS NULL; diff --git a/scripts/util/build-acs-image.sh b/scripts/util/build-acs-image.sh new file mode 100755 index 000000000000..57fb7ef24ced --- /dev/null +++ b/scripts/util/build-acs-image.sh @@ -0,0 +1,601 @@ +#!/bin/bash +# Prepare a generic cloud qcow2 image for CloudStack: patch it, shrink it and convert it to VHD/OVA. +# +# Usage: build-acs-image.sh [-a ACTIONS] [-f FORMATS] [-o OUTDIR] [-g GUESTOS] [-u] [-z] +# [-d debian|rhel|suse] [-p ROOT_PASSWORD] +# -a actions, a list separated by commas or spaces, done in this order (default: all) +# patch install the guest tools, set the root password, cloud-init and sshd config +# (OS detected from the image: Debian/Ubuntu, EL, SUSE and variants) +# shrink virt-sparsify and qemu-img convert -c +# convert convert to the formats of -f +# all patch, shrink and convert +# -f formats for the convert action, a list like "vhd,ova" or "ova, xen" (default: all) +# vhd plain VHD for Hyper-V (also hyperv) -acs.vhd (removed if xen is built too) +# ova OVA for VMware (also vmware) -acs.ova +# xen VHD for XenServer, bzip2 (also xenserver) -acs-xen.vhd.bz2 +# all vhd, ova and xen +# -o output directory (default: directory of the image) +# -g VMware guestos id for the OVA (default: detected from /etc/os-release in the image, +# e.g. debian12-64, ubuntu-64, rhel9-64, sles15-64, otherlinux-64) +# -u with patch: also run a full package upgrade inside the image +# -z with shrink: do not compress (plain qcow2 rewrite) +# -d with patch: OS family, if it cannot be detected from the image +# -p with patch: root password to set (default: password) +# +# The image is never modified. Patch and shrink work on a copy named -acs. in the +# output directory (the name is kept if it already ends with -acs), and the converted files +# are named -acs.vhd and -acs.ova. Convert alone reads the original image. +# +# SHA512SUMS with the checksums of the output files is written to the output directory when all +# is done (the entries of other files are kept). The tools needed by the actions and formats are +# checked first, and nothing is installed. +set -euo pipefail + +usage() { sed -n '2,29p' "$0"; exit 1; } + +ACTIONS="all" +FORMATS="all" +OUTDIR="" +GUESTOS="" +UPDATE="" +COMPRESS="-c" +OS_FAMILY="" +ROOT_PASSWORD="password" +while getopts "a:f:o:g:uzd:p:" opt; do + case $opt in + a) ACTIONS="$OPTARG" ;; + f) FORMATS="$OPTARG" ;; + o) OUTDIR="$OPTARG" ;; + g) GUESTOS="$OPTARG" ;; + u) UPDATE="--update" ;; + z) COMPRESS="" ;; + d) OS_FAMILY="$OPTARG" ;; + p) ROOT_PASSWORD="$OPTARG" ;; + *) usage ;; + esac +done +shift $((OPTIND - 1)) + +IMAGE="${1:-}" +[ -f "$IMAGE" ] || { echo "Image not found: '$IMAGE'" >&2; usage; } +case "$OS_FAMILY" in ""|debian|rhel|suse) ;; *) echo "Invalid OS family: $OS_FAMILY" >&2; exit 1 ;; esac + +# ACTIONS and FORMATS are lists separated by commas and/or spaces +DO_PATCH="" DO_SHRINK="" DO_CONVERT="" +for a in $(echo "$ACTIONS" | tr 'A-Z,;' 'a-z '); do + case "$a" in + patch) DO_PATCH=1 ;; + shrink) DO_SHRINK=1 ;; + convert) DO_CONVERT=1 ;; + all) DO_PATCH=1; DO_SHRINK=1; DO_CONVERT=1 ;; + *) echo "Invalid action: '$a' (supported: patch, shrink, convert, all)" >&2; exit 1 ;; + esac +done +[ -n "$DO_PATCH$DO_SHRINK$DO_CONVERT" ] || { echo "No action given" >&2; exit 1; } + +WANT_VHD="" WANT_OVA="" WANT_XEN="" +for f in $(echo "$FORMATS" | tr 'A-Z,;' 'a-z '); do + case "$f" in + vhd|hyperv) WANT_VHD=1 ;; + ova|vmware) WANT_OVA=1 ;; + xen|xenserver) WANT_XEN=1 ;; + all) WANT_VHD=1; WANT_OVA=1; WANT_XEN=1 ;; + *) echo "Invalid format: '$f' (supported: vhd, ova, xen, all, or a list like vhd,ova)" >&2; exit 1 ;; + esac +done +[ -n "$WANT_VHD$WANT_OVA$WANT_XEN" ] || { echo "No output format given" >&2; exit 1; } +# the formats are only needed by the convert action +if [ -z "$DO_CONVERT" ]; then WANT_VHD=""; WANT_OVA=""; WANT_XEN=""; fi + +# names: -acs. for the copy that is patched and shrunk, -acs. for the conversions +IMAGE=$(readlink -f "$IMAGE") +[ -n "$OUTDIR" ] || OUTDIR=$(dirname "$IMAGE") +mkdir -p "$OUTDIR" +OUTDIR=$(readlink -f "$OUTDIR") +file=$(basename "$IMAGE") +if [[ "$file" == *.* ]]; then stem="${file%.*}"; ext=".${file##*.}"; else stem="$file"; ext=""; fi +case "$stem" in *-acs) OUT_BASE="$stem" ;; *) OUT_BASE="${stem}-acs" ;; esac +WORK_IMAGE="$OUTDIR/$OUT_BASE$ext" +# patch and shrink work on the copy, convert alone reads the original image +SOURCE="$IMAGE" +if [ -n "$DO_PATCH$DO_SHRINK" ]; then SOURCE="$WORK_IMAGE"; fi + +export LIBGUESTFS_BACKEND=direct + +# Hint on the package names for the missing tools, according to the package manager of the host +pkg_hint() { + local what="$1" + if command -v apt-get >/dev/null 2>&1; then + [ "$what" = "libguestfs" ] && echo "apt install libguestfs-tools qemu-utils" || echo "apt install $what" + elif command -v zypper >/dev/null 2>&1; then + [ "$what" = "libguestfs" ] && echo "zypper install guestfs-tools libguestfs qemu-tools" || echo "zypper install $what" + elif command -v dnf >/dev/null 2>&1 || command -v yum >/dev/null 2>&1; then + [ "$what" = "libguestfs" ] && echo "dnf install guestfs-tools (libguestfs-tools-c on EL8) qemu-img" || echo "dnf install $what" + else + echo "install libguestfs tools and qemu-img" + fi +} + +# Check what the actions and formats need, before anything is created, and report all the +# problems at once. Packages are never installed here, as the script runs on Debian/Ubuntu, +# EL, SUSE, ... +check_dependencies() { + local missing=() warnings=() + local cmd + + for cmd in qemu-img cp mktemp sha512sum; do + command -v "$cmd" >/dev/null 2>&1 || missing+=("$cmd not found ($(pkg_hint libguestfs))") + done + if [ -n "$DO_PATCH" ]; then + for cmd in virt-customize virt-cat virt-ls virt-inspector; do + command -v "$cmd" >/dev/null 2>&1 || missing+=("$cmd not found ($(pkg_hint libguestfs))") + done + fi + if [ -n "$DO_SHRINK" ]; then + command -v virt-sparsify >/dev/null 2>&1 || missing+=("virt-sparsify not found ($(pkg_hint libguestfs))") + fi + + # the formats needed by qemu-img + if command -v qemu-img >/dev/null 2>&1 && [ -n "$DO_CONVERT" ]; then + local formats + formats=$(qemu-img --help 2>&1 || true) + if [ -n "$WANT_VHD" ]; then + echo "$formats" | grep -qw vpc || missing+=("qemu-img does not support the vpc (VHD) format") + fi + if [ -n "$WANT_OVA" ]; then + echo "$formats" | grep -qw vmdk || missing+=("qemu-img does not support the vmdk format") + fi + fi + + # the VMware guestos of the OVA is detected from the image, unless -g is given + if [ -n "$WANT_OVA" ] && [ -z "$GUESTOS" ] && [ -z "$DO_PATCH" ]; then + command -v virt-cat >/dev/null 2>&1 || missing+=("virt-cat not found, needed to detect the VMware guestos of the OVA from the image ($(pkg_hint libguestfs)), or use -g") + fi + + # ovftool must be runnable, not only be present + if [ -n "$WANT_OVA" ]; then + if ! command -v ovftool >/dev/null 2>&1; then + missing+=("ovftool not found, required for OVA (VMware OVF Tool, add it to PATH)") + elif ! ovftool --version >/dev/null 2>&1; then + missing+=("ovftool cannot be run (check its libraries and that the whole ovftool directory is installed)") + fi + fi + + # the XenServer VHD: bzip2, and the 32-bit vhd-util with faketime (as in tools/appliance/build.sh) + if [ -n "$WANT_XEN" ]; then + command -v bzip2 >/dev/null 2>&1 || missing+=("bzip2 not found, required for the XenServer VHD (install bzip2)") + command -v faketime >/dev/null 2>&1 || missing+=("faketime not found, required for the XenServer VHD (install faketime)") + if ! command -v vhd-util >/dev/null 2>&1; then + missing+=("vhd-util not found, required for the XenServer VHD (see the comments in tools/appliance/build.sh, or http://packages.shapeblue.com/systemvmtemplate/vhd-util)") + else + # vhd-util is a 32-bit binary: it needs the i386 libraries, and faketime must be preloadable into it + local vhd_out + vhd_out=$(ldd "$(command -v vhd-util)" 2>&1 || true) + if echo "$vhd_out" | grep -qE "not found|not a dynamic|No such file"; then + missing+=("vhd-util cannot be run, missing libraries (32-bit libuuid and libc, and libvhd.so.1.0 in the ldconfig path)") + elif command -v faketime >/dev/null 2>&1; then + vhd_out=$(faketime '2010-01-01' vhd-util 2>&1 || true) + echo "$vhd_out" | grep -q "cannot be preloaded" && \ + missing+=("faketime cannot be used with the 32-bit vhd-util (install the 32-bit faketime library, e.g. faketime:i386)") + fi + fi + fi + + # the image must be a readable qcow2 file + local info vsize_gb=1 + if command -v qemu-img >/dev/null 2>&1; then + if ! info=$(qemu-img info --output=json "$IMAGE" 2>&1); then + missing+=("cannot read the image: $(echo "$info" | head -1)") + else + echo "$info" | grep -q '"format": *"qcow2"' || missing+=("$IMAGE is not a qcow2 image") + vsize_gb=$(echo "$info" | sed -n 's/.*"virtual-size": *\([0-9]*\).*/\1/p' | head -1) + vsize_gb=$(( ${vsize_gb:-0} / 1024 / 1024 / 1024 + 1 )) + fi + fi + + # the architecture of the guest: commands cannot be run in a guest of another architecture + # (virt-customize --install/--run-command), and the VHD/OVA are for x86_64 hypervisors + if command -v virt-inspector >/dev/null 2>&1 && [ -z "${missing[*]:-}" ]; then + local guest_arch host_arch + guest_arch=$(virt-inspector -a "$IMAGE" 2>/dev/null | sed -n 's#.*\(.*\).*#\1#p' | head -1) + host_arch=$(uname -m) + if [ -n "$guest_arch" ] && [ "$guest_arch" != "$host_arch" ]; then + if [ -n "$DO_PATCH" ]; then + missing+=("the image is $guest_arch but the host is $host_arch: virt-customize cannot run commands (install packages) in the guest, so the patch action is not possible here; run it on a $guest_arch host, or use -a shrink,convert") + fi + fi + if [ -n "$guest_arch" ] && [ "$guest_arch" != "x86_64" ] && [ -n "$WANT_VHD$WANT_OVA$WANT_XEN" ]; then + warnings+=("the image is $guest_arch, but the VHD (Hyper-V, XenServer) and the OVA (VMware) are normally used with x86_64 images") + fi + fi + + # the output + [ -w "$OUTDIR" ] || missing+=("$OUTDIR is not writable") + if [ -n "$DO_PATCH$DO_SHRINK" ]; then + if [ "$WORK_IMAGE" = "$IMAGE" ]; then + missing+=("$IMAGE is already an -acs image, the original image is never modified (use convert only, or pass the original image)") + elif [ -e "$WORK_IMAGE" ]; then + missing+=("$WORK_IMAGE already exists, remove it or move it away first") + fi + fi + + # disk space in the output directory: the copy, the sparsified and converted copies, the VHD, the VMDK and the OVA + local need_gb=0 free_gb + [ -n "$DO_PATCH$DO_SHRINK" ] && need_gb=$(( need_gb + vsize_gb )) + [ -n "$DO_SHRINK" ] && need_gb=$(( need_gb + 2 * vsize_gb )) + [ -n "$WANT_VHD" ] && need_gb=$(( need_gb + vsize_gb )) + [ -n "$WANT_OVA" ] && need_gb=$(( need_gb + 2 * vsize_gb )) + [ -n "$WANT_XEN" ] && need_gb=$(( need_gb + 2 * vsize_gb )) + free_gb=$(df -P -BG "$OUTDIR" | awk 'NR==2 {gsub("G","",$4); print $4}') + [ -n "$free_gb" ] && [ "$free_gb" -lt "$need_gb" ] 2>/dev/null && \ + warnings+=("only ${free_gb}G free in $OUTDIR, up to ${need_gb}G may be needed") + + if [ -n "$DO_PATCH$DO_SHRINK" ]; then + # libguestfs builds its appliance in TMPDIR (or LIBGUESTFS_CACHEDIR), which needs about 2G + local cache_dir="${LIBGUESTFS_CACHEDIR:-${TMPDIR:-/var/tmp}}" + local cache_free + cache_free=$(df -P -BG "$cache_dir" 2>/dev/null | awk 'NR==2 {gsub("G","",$4); print $4}') + if [ -n "$cache_free" ] && [ "$cache_free" -lt 2 ] 2>/dev/null; then + missing+=("only ${cache_free}G free in $cache_dir for the libguestfs appliance (set LIBGUESTFS_CACHEDIR and TMPDIR to a bigger disk)") + fi + + # the libguestfs appliance is built from the kernel of the host (not of the image): on Ubuntu + # /boot/vmlinuz-* is only readable by root, so supermin fails for other users + if [ "$(id -u)" != "0" ] && ls /boot/vmlinuz-* >/dev/null 2>&1; then + local k + for k in /boot/vmlinuz-*; do [ -r "$k" ] && break; k=; done + [ -n "${k:-}" ] || warnings+=("the host kernel in /boot is not readable by $(id -un), run as root or chmod a+r /boot/vmlinuz-*") + fi + fi + + local item + for item in "${warnings[@]}"; do echo "WARN: $item" >&2; done + if [ ${#missing[@]} -gt 0 ]; then + for item in "${missing[@]}"; do echo "ERROR: $item" >&2; done + echo "ERROR: ${#missing[@]} dependency problem(s), see above" >&2 + exit 1 + fi +} + +# Read /etc/os-release from inside the image (read-only) +load_os_release() { + local osr + osr=$(virt-cat -a "$IMAGE" /etc/os-release 2>/dev/null || virt-cat -a "$IMAGE" /usr/lib/os-release 2>/dev/null || true) + osr_value() { echo "$osr" | sed -n "s/^$1=//p" | head -1 | tr -d "\"'" ; } + OS_ID=$(osr_value ID | tr 'A-Z' 'a-z') + OS_ID_LIKE=$(osr_value ID_LIKE | tr 'A-Z' 'a-z') + OS_VERSION_ID=$(osr_value VERSION_ID) + OS_NAME=$(osr_value PRETTY_NAME) +} + +# Map /etc/os-release to a VMware guestos id (the ids known by ESXi 7/8; newer releases of a +# distribution use the newest id, as older vSphere versions do not know the newest ids) +vmware_guestos() { + local id="$OS_ID" like="$OS_ID_LIKE" major="${OS_VERSION_ID%%.*}" + local n + case "$id" in + debian) + n=$major; [[ "$n" =~ ^[0-9]+$ ]] || n=12 + [ "$n" -gt 12 ] && n=12; [ "$n" -lt 8 ] && n=8 + echo "debian${n}-64"; return ;; + ubuntu) echo "ubuntu-64"; return ;; + rhel|centos|ol|oracle) + n=$major; [[ "$n" =~ ^[0-9]+$ ]] || n=9 + [ "$n" -gt 9 ] && n=9; [ "$n" -lt 6 ] && n=6 + case "$id" in + rhel) echo "rhel${n}-64" ;; + centos) echo "centos${n}-64" ;; + *) echo "oraclelinux${n}-64" ;; + esac + return ;; + rocky) echo "rockylinux-64"; return ;; + almalinux|alma) echo "almalinux-64"; return ;; + fedora) echo "fedora-64"; return ;; + sles|sled|sle-micro) + n=$major; [[ "$n" =~ ^[0-9]+$ ]] || n=15 + [ "$id" = "sle-micro" ] && n=15 + [ "$n" -gt 15 ] && n=15; [ "$n" -lt 11 ] && n=11 + echo "sles${n}-64"; return ;; + opensuse*|suse) echo "opensuse-64"; return ;; + esac + # variants: use the family of ID_LIKE + case " $like " in + *" ubuntu "*) echo "ubuntu-64"; return ;; + *" debian "*) echo "debian12-64"; return ;; + *" rhel "*|*" fedora "*) + n=$major; [[ "$n" =~ ^[0-9]+$ ]] || n=9 + [ "$n" -gt 9 ] && n=9; [ "$n" -lt 6 ] && n=6 + echo "rhel${n}-64"; return ;; + *" suse "*) echo "sles15-64"; return ;; + esac + echo "otherlinux-64" +} + +# Detect the OS family from the os-release of the image, to decide the packages and the cleanup +detect_os() { + if [ -z "$OS_FAMILY" ]; then + local id + for id in $OS_ID $OS_ID_LIKE; do + case "$id" in + debian|ubuntu|linuxmint|raspbian|kali) OS_FAMILY=debian ;; + rhel|centos|fedora|rocky|almalinux|alma|ol|oracle|amzn|scientific|eurolinux|cloudlinux|anolis|openeuler) OS_FAMILY=rhel ;; + suse|sles|sled|sle-micro|opensuse|opensuse-leap|opensuse-tumbleweed|opensuse-microos) OS_FAMILY=suse ;; + esac + [ -n "$OS_FAMILY" ] && break + done + fi + if [ -z "$OS_FAMILY" ]; then + echo "ERROR: unsupported OS in the image (ID='${OS_ID}', ID_LIKE='${OS_ID_LIKE}'), use -d debian|rhel|suse to force a family" >&2 + exit 1 + fi + echo "Detected OS: ${OS_NAME:-$OS_ID} (family: $OS_FAMILY)" + + local base_cleanup='journalctl --vacuum-time=1s; rm -rf /var/log/*; rm -f /root/.bash_history' + case "$OS_FAMILY" in + debian) + PACKAGES="qemu-guest-agent,open-vm-tools,xenstore-utils,libxenstore4" + CLEANUP="apt clean; apt autoclean; apt autoremove --purge -y; $base_cleanup" ;; + rhel) + # there is no xenstore package in the EL repositories + PACKAGES="qemu-guest-agent,open-vm-tools" + CLEANUP="(dnf clean all || yum clean all); rm -rf /var/cache/dnf /var/cache/yum; $base_cleanup" ;; + suse) + PACKAGES="qemu-guest-agent,open-vm-tools,xen-tools-domU" + CLEANUP="zypper --non-interactive clean --all; $base_cleanup" ;; + esac +} + +do_patch() { + echo "== Patching $WORK_IMAGE ==" + local tmp + tmp=$(mktemp -d) + CLEAN_PATHS+=("$tmp") + echo "policy: enabled" > "$tmp/ds-identify.cfg" + cat > "$tmp/cloudstack.cfg" <<'EOF' +datasource_list: [ ConfigDrive, CloudStack, None ] +datasource: + CloudStack: {} + None: {} +EOF + # sshd uses the first value it reads, so 40- loads before cloud-init's 50-cloud-init.conf + printf 'PermitRootLogin yes\nPasswordAuthentication yes\n' > "$tmp/40-password-login.conf" + + # the drop-in only works if sshd_config includes sshd_config.d (not in EL8, Ubuntu 20.04, ...); + # otherwise put the settings at the top of sshd_config, as the first value wins + local sshd_fix='f=/etc/ssh/sshd_config; d=/etc/ssh/sshd_config.d/40-password-login.conf; +if [ -f "$f" ] && ! grep -qiE "^[[:space:]]*Include[[:space:]].*sshd_config\.d" "$f"; then + { cat "$d"; cat "$f"; } > "$f.new" && cat "$f.new" > "$f" && rm -f "$f.new" +fi' + + virt-customize -a "$WORK_IMAGE" \ + $UPDATE \ + --install "$PACKAGES" \ + --root-password "password:$ROOT_PASSWORD" \ + --upload "$tmp/ds-identify.cfg:/etc/cloud/ds-identify.cfg" \ + --upload "$tmp/cloudstack.cfg:/etc/cloud/cloud.cfg.d/cloudstack.cfg" \ + --mkdir /etc/ssh/sshd_config.d \ + --upload "$tmp/40-password-login.conf:/etc/ssh/sshd_config.d/40-password-login.conf" \ + --run-command "$sshd_fix" \ + --run-command "$CLEANUP" + rm -rf "$tmp" + + echo "--- verification ---" + virt-cat -a "$WORK_IMAGE" /etc/cloud/ds-identify.cfg /etc/cloud/cloud.cfg.d/cloudstack.cfg /etc/ssh/sshd_config.d/40-password-login.conf + local d + for d in /usr/sbin /usr/bin; do + virt-ls -a "$WORK_IMAGE" $d | grep -E '^(qemu-ga|vmtoolsd|xenstore)' | sed "s#^#$d/#" || true + done +} + +do_shrink() { + echo "== Shrinking $WORK_IMAGE ==" + local sparse out + sparse=$(mktemp "$OUTDIR/.sparse.XXXXXX") + out=$(mktemp "$OUTDIR/.shrink.XXXXXX") + CLEAN_PATHS+=("$sparse" "$out") + rm -f "$sparse" + virt-sparsify --convert qcow2 "$WORK_IMAGE" "$sparse" + qemu-img convert $COMPRESS -f qcow2 -O qcow2 "$sparse" "$out" + qemu-img check "$out" >/dev/null + chmod --reference="$WORK_IMAGE" "$out" + mv -f "$out" "$WORK_IMAGE" + rm -f "$sparse" + qemu-img info "$WORK_IMAGE" | grep -E 'virtual size|disk size' +} + +do_convert_vhd() { + echo "== Converting to VHD ==" + qemu-img convert -f qcow2 -O vpc "$SOURCE" "$OUTDIR/$OUT_BASE.vhd" + chmod a+r "$OUTDIR/$OUT_BASE.vhd" + echo "Created $OUTDIR/$OUT_BASE.vhd" +} + +do_convert_xen() { + echo "== Converting to the XenServer VHD ==" + local work + work=$(mktemp -d "$OUTDIR/.xen-work.XXXXXX") + CLEAN_PATHS+=("$work") + qemu-img convert -f qcow2 -O raw "$SOURCE" "$work/img.raw" + vhd-util convert -s 0 -t 1 -i "$work/img.raw" -o "$work/stagefixed.vhd" + faketime '2010-01-01' vhd-util convert -s 1 -t 2 -i "$work/stagefixed.vhd" -o "$work/$OUT_BASE-xen.vhd" + bzip2 -f "$work/$OUT_BASE-xen.vhd" + mv -f "$work/$OUT_BASE-xen.vhd.bz2" "$OUTDIR/$OUT_BASE-xen.vhd.bz2" + chmod a+r "$OUTDIR/$OUT_BASE-xen.vhd.bz2" + rm -rf "$work" + echo "Created $OUTDIR/$OUT_BASE-xen.vhd.bz2" +} + +do_convert_ova() { + echo "== Converting to OVA ==" + local work + work=$(mktemp -d "$OUTDIR/.ova-work.XXXXXX") + CLEAN_PATHS+=("$work") + + qemu-img convert -f qcow2 -O vmdk "$SOURCE" "$work/$OUT_BASE.vmdk" + + cat > "$work/$OUT_BASE.vmx" <&2 + fi +} +trap cleanup EXIT + +check_dependencies +# detect the OS before anything is created, so that an unsupported OS stops here +if [ -n "$DO_PATCH" ] || { [ -n "$WANT_OVA" ] && [ -z "$GUESTOS" ]; }; then + load_os_release +fi +[ -n "$DO_PATCH" ] && detect_os +if [ -n "$WANT_OVA" ] && [ -z "$GUESTOS" ]; then + GUESTOS=$(vmware_guestos) + echo "VMware guestos: $GUESTOS (from ID='${OS_ID}', ID_LIKE='${OS_ID_LIKE}', VERSION_ID='${OS_VERSION_ID}')" +fi + +if [ -n "$DO_PATCH$DO_SHRINK" ]; then + cp --reflink=auto "$IMAGE" "$WORK_IMAGE" + WORK_BUSY=1 + echo "Created $WORK_IMAGE from $IMAGE (the original is not modified)" +fi +[ -n "$DO_PATCH" ] && do_patch +[ -n "$DO_SHRINK" ] && do_shrink +WORK_BUSY="" +if [ -n "$DO_CONVERT" ]; then + [ -n "$WANT_VHD" ] && do_convert_vhd + [ -n "$WANT_OVA" ] && do_convert_ova + if [ -n "$WANT_XEN" ]; then + do_convert_xen + # the plain .vhd is not kept when the XenServer .vhd.bz2 is built too + if [ -n "$WANT_VHD" ]; then + rm -f "$OUTDIR/$OUT_BASE.vhd" + echo "Removed $OUTDIR/$OUT_BASE.vhd, as $OUT_BASE-xen.vhd.bz2 was created" + fi + fi +fi + +# SHA512SUMS of the output files, when all is done; the entries of other files are kept +make_sha512sums() { + local f n h + local -A mine=() + local -a names=() + for f in "$(basename "$WORK_IMAGE")" "$OUT_BASE.vhd" "$OUT_BASE.ova" "$OUT_BASE-xen.vhd.bz2"; do + [ -f "$OUTDIR/$f" ] || continue + mine[$f]=1 + names+=("$f") + done + [ ${#names[@]} -gt 0 ] || return 0 + local tmp + tmp=$(mktemp "$OUTDIR/.sums.XXXXXX") + CLEAN_PATHS+=("$tmp") + if [ -f "$OUTDIR/SHA512SUMS" ]; then + while read -r h n; do + [ -n "$n" ] && [ -z "${mine[${n#\*}]:-}" ] && echo "$h $n" >> "$tmp" + done < "$OUTDIR/SHA512SUMS" + fi + (cd "$OUTDIR" && sha512sum "${names[@]}") >> "$tmp" + chmod a+r "$tmp" + mv -f "$tmp" "$OUTDIR/SHA512SUMS" + echo "Created $OUTDIR/SHA512SUMS" +} +make_sha512sums + +echo "== Done ==" +ls -lh "$WORK_IMAGE" "$OUTDIR/$OUT_BASE".vhd "$OUTDIR/$OUT_BASE".ova "$OUTDIR/$OUT_BASE"-xen.vhd.bz2 "$OUTDIR/SHA512SUMS" 2>/dev/null || true +exit 0 diff --git a/setup/db/templates.sql b/setup/db/templates.sql index 8e8f7b7f804d..a6dee71c8480 100755 --- a/setup/db/templates.sql +++ b/setup/db/templates.sql @@ -34,16 +34,16 @@ INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, VALUES (2, UUID(), 'centos53-x86_64', 'CentOS 5.3(64-bit) no GUI (XenServer)', 1, now(), now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/templates/builtin/f59f18fb-ae94-4f97-afd2-f84755767aca.vhd.bz2', 'b63d854a9560c013142567bbae8d98cf', 0, 'CentOS 5.3(64-bit) no GUI (XenServer)', 'VHD', 12, 1, 1, 'XenServer', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, display_text, enable_password, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (4, UUID(), 'centos55-x86_64', 'CentOS 5.5(64-bit) no GUI (KVM)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/2.2.0/eec2209b-9875-3c8d-92be-c001bd8a0faf.qcow2.bz2', 'ed0e788280ff2912ea40f7f91ca7a249', 'CentOS 5.5(64-bit) no GUI (KVM)', 0, 'QCOW2', 112, 1, 1, 'KVM', 1); + VALUES (4, UUID(), 'debian13-x86_64-kvm', 'Debian 13 (64-bit) no GUI (KVM)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261017-2634-acs.qcow2', '{SHA-512}38389fb9e29448e6d7da460c0342217bd1a8aa6e32e6192fa1c6dbc6f7078f6c8210dde110d8631cc823b2762fb1738f8ae94b3e5a3774cf30a0cf11af69dfb8', 'Debian 13 (64-bit) no GUI (KVM)', 0, 'QCOW2', 184, 1, 1, 'KVM', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (5, UUID(), 'centos56-x86_64-xen', 'CentOS 5.6(64-bit) no GUI (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/templates/builtin/centos56-x86_64.vhd.bz2', '905cec879afd9c9d22ecc8036131a180', 0, 'CentOS 5.6(64-bit) no GUI (XenServer)', 'VHD', 142, 1, 1, 'XenServer', 1); + VALUES (5, UUID(), 'debian13-x86_64-xen', 'Debian 13 (64-bit) no GUI (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261017-2634-acs-xen.vhd.bz2', '{SHA-512}b2687bf7f739f49ed36b266e69d44ed49283b398497d85bda17f0eabc447934ba571629c01d94d8ac985f8133b218c8558cac22a88f78a3efd5f81bcf0689ab7', 0, 'Debian 13 (64-bit) no GUI (XenServer)', 'VHD', 184, 1, 1, 'XenServer', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) VALUES (6, UUID(), 'centos64-x64', 'CentOS 6.4(64-bit) GUI (Hyperv)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.3/centos6_4_64bit.vhd.bz2', 'eef6b9940ea3ed01221d963d4a012d0a', 0, 'CentOS 6.4 (64-bit) GUI (Hyperv)', 'VHD', 182, 1, 1, 'Hyperv', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (7, UUID(), 'centos53-x64', 'CentOS 5.3(64-bit) no GUI (vSphere)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/2.2.0/CentOS5.3-x86_64.ova', 'f6f881b7f2292948d8494db837fe0f47', 0, 'CentOS 5.3(64-bit) no GUI (vSphere)', 'OVA', 12, 1, 1, 'VMware', 1); + VALUES (7, UUID(), 'debian13-x64-vmware', 'Debian 13 (64-bit) no GUI (vSphere)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261017-2634-acs.ova', '{SHA-512}a090fafc53cbcf375937a8328500689543d9716a527f8a6059daee49712c56cc0e1553f386af8df1a650fa92819b235f4066df1076f242bf9a9e225f18a10b2b', 0, 'Debian 13 (64-bit) no GUI (vSphere)', 'OVA', 184, 1, 1, 'VMware', 1); INSERT INTO `cloud`.`guest_os_category` (id, uuid, name) VALUES (1, UUID(), 'CentOS'); INSERT INTO `cloud`.`guest_os_category` (id, uuid, name) VALUES (2, UUID(), 'Debian'); From 06a9466ac7702106219beddc2f266620d61d3971 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Tue, 20 Oct 2026 09:54:22 +0200 Subject: [PATCH 08/64] schema: set the guest OS of the built-in Debian 13 templates to Debian 12 (64-bit) templates.sql cannot reference the 'Debian GNU/Linux 12 (64-bit)' guest OS because it is only added by a later upgrade script with an auto-generated id. Update the guest_os_id of the built-in Debian 13 templates (KVM, XenServer, VMware) in the 4.23.0.0 to 4.24.0.0 upgrade, looking the guest OS up by name. Also rename the VMware built-in template to debian13-x86_64-vmware to match the KVM and XenServer names, and drop the 4.3 upgrade statement that forced the XenServer built-in template back to guest OS 142. --- .../src/main/resources/META-INF/db/schema-421to430.sql | 1 - .../src/main/resources/META-INF/db/schema-42300to2400.sql | 8 ++++++++ setup/db/templates.sql | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/engine/schema/src/main/resources/META-INF/db/schema-421to430.sql b/engine/schema/src/main/resources/META-INF/db/schema-421to430.sql index 80d32dab3fb3..838263c99915 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-421to430.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-421to430.sql @@ -129,7 +129,6 @@ ALTER TABLE `cloud`.`volumes` ADD COLUMN `hv_ss_reserve` int(32) unsigned DEFAUL UPDATE `cloud`.`disk_offering` SET `state`='Inactive' WHERE `removed` IS NOT NULL; UPDATE `cloud`.`disk_offering` SET `removed`=NULL; -UPDATE `cloud`.`vm_template` SET `guest_os_id`= "142" WHERE `id` = "5"; UPDATE `cloud`.`vm_template` SET `state`='Inactive' WHERE `removed` IS NOT NULL; UPDATE `cloud`.`vm_template` SET `state`='Active' WHERE `removed` IS NULL; UPDATE `cloud`.`vm_template` SET `removed`=NULL; diff --git a/engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql b/engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql index 8f59321627db..1ff71f4e0eb1 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql @@ -226,3 +226,11 @@ CREATE TABLE IF NOT EXISTS `cloud`.`instance_boot_group_details` ( PRIMARY KEY (`id`), CONSTRAINT `fk_instance_boot_group_details__group_id` FOREIGN KEY (`boot_group_id`) REFERENCES `instance_boot_group` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- Set the guest OS of the built-in Debian 13 templates to 'Debian GNU/Linux 12 (64-bit)', which is only added by later upgrade scripts and is not available in templates.sql +UPDATE `cloud`.`vm_template` SET `guest_os_id` = (SELECT `id` FROM `cloud`.`guest_os` WHERE `display_name` = 'Debian GNU/Linux 12 (64-bit)' AND `removed` IS NULL LIMIT 1) + WHERE `id` = 4 AND `unique_name` = 'debian13-x86_64-kvm' AND `type` = 'BUILTIN'; +UPDATE `cloud`.`vm_template` SET `guest_os_id` = (SELECT `id` FROM `cloud`.`guest_os` WHERE `display_name` = 'Debian GNU/Linux 12 (64-bit)' AND `removed` IS NULL LIMIT 1) + WHERE `id` = 5 AND `unique_name` = 'debian13-x86_64-xen' AND `type` = 'BUILTIN'; +UPDATE `cloud`.`vm_template` SET `guest_os_id` = (SELECT `id` FROM `cloud`.`guest_os` WHERE `display_name` = 'Debian GNU/Linux 12 (64-bit)' AND `removed` IS NULL LIMIT 1) + WHERE `id` = 7 AND `unique_name` = 'debian13-x86_64-vmware' AND `type` = 'BUILTIN'; diff --git a/setup/db/templates.sql b/setup/db/templates.sql index a6dee71c8480..f4a65e1461a7 100755 --- a/setup/db/templates.sql +++ b/setup/db/templates.sql @@ -43,7 +43,7 @@ INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, VALUES (6, UUID(), 'centos64-x64', 'CentOS 6.4(64-bit) GUI (Hyperv)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.3/centos6_4_64bit.vhd.bz2', 'eef6b9940ea3ed01221d963d4a012d0a', 0, 'CentOS 6.4 (64-bit) GUI (Hyperv)', 'VHD', 182, 1, 1, 'Hyperv', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (7, UUID(), 'debian13-x64-vmware', 'Debian 13 (64-bit) no GUI (vSphere)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261017-2634-acs.ova', '{SHA-512}a090fafc53cbcf375937a8328500689543d9716a527f8a6059daee49712c56cc0e1553f386af8df1a650fa92819b235f4066df1076f242bf9a9e225f18a10b2b', 0, 'Debian 13 (64-bit) no GUI (vSphere)', 'OVA', 184, 1, 1, 'VMware', 1); + VALUES (7, UUID(), 'debian13-x86_64-vmware', 'Debian 13 (64-bit) no GUI (vSphere)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261017-2634-acs.ova', '{SHA-512}a090fafc53cbcf375937a8328500689543d9716a527f8a6059daee49712c56cc0e1553f386af8df1a650fa92819b235f4066df1076f242bf9a9e225f18a10b2b', 0, 'Debian 13 (64-bit) no GUI (vSphere)', 'OVA', 184, 1, 1, 'VMware', 1); INSERT INTO `cloud`.`guest_os_category` (id, uuid, name) VALUES (1, UUID(), 'CentOS'); INSERT INTO `cloud`.`guest_os_category` (id, uuid, name) VALUES (2, UUID(), 'Debian'); From 39a61c8778d29e50db37d1ab5adca46d8ab2d5ba Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Tue, 20 Oct 2026 10:30:50 +0200 Subject: [PATCH 09/64] systemvm: create /etc/iproute2/rt_tables at bootstrap if it does not exist iproute2 in Debian 13 does not install /etc/iproute2/rt_tables anymore, so adding the route table of a nic failed with FileNotFoundError when the VR was configured. Create the file in bootstrap, for all the systemvm types, from /etc/iptables/rt_tables_init, or from /usr/share/iproute2/rt_tables if it does not exist. Remove the copy from default.sh. --- .../debian/opt/cloud/bin/setup/bootstrap.sh | 17 +++++++++++++++++ systemvm/debian/opt/cloud/bin/setup/default.sh | 1 - 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/systemvm/debian/opt/cloud/bin/setup/bootstrap.sh b/systemvm/debian/opt/cloud/bin/setup/bootstrap.sh index c601f6ad2210..1e1773f9ec22 100755 --- a/systemvm/debian/opt/cloud/bin/setup/bootstrap.sh +++ b/systemvm/debian/opt/cloud/bin/setup/bootstrap.sh @@ -104,12 +104,29 @@ config_sysctl() { sysctl -p } +# Debian 13 and later does not install /etc/iproute2/rt_tables, which the scripts of all the +# systemvm types use to add the route tables +config_rt_tables() { + if [ ! -f /etc/iproute2/rt_tables ]; then + log_it "Creating /etc/iproute2/rt_tables" + mkdir -p /etc/iproute2 + if [ -f /etc/iptables/rt_tables_init ]; then + cp -f /etc/iptables/rt_tables_init /etc/iproute2/rt_tables + elif [ -f /usr/share/iproute2/rt_tables ]; then + cp -f /usr/share/iproute2/rt_tables /etc/iproute2/rt_tables + else + touch /etc/iproute2/rt_tables + fi + fi +} + bootstrap() { log_it "Bootstrapping systemvm appliance" export TYPE=$(grep -Po 'type=\K[a-zA-Z]*' $CMDLINE) patch config_sysctl + config_rt_tables log_it "Configuring systemvm type=$TYPE" if [ -f "/opt/cloud/bin/setup/$TYPE.sh" ]; then diff --git a/systemvm/debian/opt/cloud/bin/setup/default.sh b/systemvm/debian/opt/cloud/bin/setup/default.sh index 4272e645d416..36292fa05345 100755 --- a/systemvm/debian/opt/cloud/bin/setup/default.sh +++ b/systemvm/debian/opt/cloud/bin/setup/default.sh @@ -23,7 +23,6 @@ setup_default() { auto lo iface lo inet loopback EOF - cp -f /etc/iptables/rt_tables_init /etc/iproute2/rt_tables } setup_default From 363dea6cf5d90351a9ed381ac5571fa551637826 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Wed, 21 Oct 2026 08:30:23 +0200 Subject: [PATCH 10/64] marvin: use the shared public tiny template in the smoke tests get_suitable_test_template now returns the shared public test template (tiny-kvm on KVM), registered by the admin only when it is missing, and falls back to the built-in template. It was already doing this for XenServer. The hypervisor argument is optional and is detected from the hosts when not given. Tests that only need a small guest now use it instead of the built-in template, and test_ipv4_routing, test_snapshots and test_restore_vm no longer register their own copy of the tiny template. Tests that depend on the built-in template are not changed, for example test_deploy_vm_root_resize (needs a template of at least 1 GiB), test_templates, test_sharedfs_lifecycle and test_vm_autoscaling. --- test/integration/smoke/test_affinity_groups.py | 8 ++++---- .../smoke/test_backup_recovery_dummy.py | 6 +++--- .../smoke/test_backup_recovery_kboss.py | 6 +++--- .../smoke/test_backup_recovery_nas.py | 8 ++++---- .../smoke/test_backup_recovery_veeam.py | 6 +++--- test/integration/smoke/test_console_endpoint.py | 8 ++++---- .../smoke/test_deploy_vm_extra_config_data.py | 4 ++-- .../smoke/test_gateway_on_shared_networks.py | 4 ++-- .../smoke/test_host_control_state.py | 6 +++--- .../smoke/test_instance_boot_group.py | 8 ++++---- test/integration/smoke/test_ipv4_routing.py | 14 +++++++------- test/integration/smoke/test_kms_lifecycle.py | 4 ++-- test/integration/smoke/test_migration.py | 4 ++-- test/integration/smoke/test_network.py | 6 +++--- .../smoke/test_persistent_network.py | 4 ++-- .../smoke/test_purge_expunged_vms.py | 6 +++--- test/integration/smoke/test_restore_vm.py | 9 +++------ test/integration/smoke/test_snapshots.py | 11 +++-------- test/integration/smoke/test_usage_events.py | 4 ++-- .../smoke/test_vm_deployment_planner.py | 12 ++++++------ ...test_vm_lifecycle_with_snapshot_or_volume.py | 8 +++----- test/integration/smoke/test_vm_schedule.py | 4 ++-- test/integration/smoke/test_vnf_templates.py | 4 ++-- tools/marvin/marvin/lib/common.py | 17 +++++++++++------ 24 files changed, 83 insertions(+), 88 deletions(-) diff --git a/test/integration/smoke/test_affinity_groups.py b/test/integration/smoke/test_affinity_groups.py index 26271f69e3fd..d6c37d107224 100644 --- a/test/integration/smoke/test_affinity_groups.py +++ b/test/integration/smoke/test_affinity_groups.py @@ -23,7 +23,7 @@ from marvin.lib.base import * from marvin.lib.common import (get_domain, get_zone, - get_template, + get_suitable_test_template, list_virtual_machines) from nose.plugins.attrib import attr @@ -44,14 +44,14 @@ def setUpClass(cls): cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests()) cls.hypervisor = cls.testClient.getHypervisorInfo() - cls.template = get_template( + cls.template = get_suitable_test_template( cls.apiclient, cls.zone.id, - cls.hypervisor + hypervisor=cls.hypervisor ) if cls.template == FAILED: - assert False, "get_template() failed to return template" + assert False, "get_suitable_test_template() failed to return template" cls.services["virtual_machine"]["zoneid"] = cls.zone.id diff --git a/test/integration/smoke/test_backup_recovery_dummy.py b/test/integration/smoke/test_backup_recovery_dummy.py index 3e2f16f8c686..ab57a797ea89 100644 --- a/test/integration/smoke/test_backup_recovery_dummy.py +++ b/test/integration/smoke/test_backup_recovery_dummy.py @@ -19,7 +19,7 @@ from marvin.cloudstackTestCase import cloudstackTestCase from marvin.lib.utils import (cleanup_resources) from marvin.lib.base import (Account, ServiceOffering, DiskOffering, VirtualMachine, BackupOffering, Configurations, Backup, Volume) -from marvin.lib.common import (get_domain, get_zone, get_template) +from marvin.lib.common import (get_domain, get_zone, get_suitable_test_template) from nose.plugins.attrib import attr from marvin.codes import FAILED import time @@ -37,9 +37,9 @@ def setUpClass(cls): cls.services["mode"] = cls.zone.networktype cls.hypervisor = cls.testClient.getHypervisorInfo() cls.domain = get_domain(cls.api_client) - cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) + cls.template = get_suitable_test_template(cls.api_client, cls.zone.id, cls.services["ostype"]) if cls.template == FAILED: - assert False, "get_template() failed to return template with description %s" % cls.services["ostype"] + assert False, "get_suitable_test_template() failed to return template with description %s" % cls.services["ostype"] cls.services["small"]["zoneid"] = cls.zone.id cls.services["small"]["template"] = cls.template.id cls._cleanup = [] diff --git a/test/integration/smoke/test_backup_recovery_kboss.py b/test/integration/smoke/test_backup_recovery_kboss.py index 10d823da195c..ee2c0bb9fb28 100644 --- a/test/integration/smoke/test_backup_recovery_kboss.py +++ b/test/integration/smoke/test_backup_recovery_kboss.py @@ -20,7 +20,7 @@ from marvin.lib import utils from marvin.lib.base import (Account, ServiceOffering, DiskOffering, VirtualMachine, BackupOffering, Backup, Configurations, Volume, StoragePool) -from marvin.lib.common import (get_domain, get_zone, get_template) +from marvin.lib.common import (get_domain, get_zone, get_suitable_test_template) from nose.plugins.attrib import attr from marvin.codes import FAILED import time @@ -43,9 +43,9 @@ def setUpClass(cls): cls.services["mode"] = cls.zone.networktype cls.hypervisor = cls.testClient.getHypervisorInfo() cls.domain = get_domain(cls.api_client) - cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) + cls.template = get_suitable_test_template(cls.api_client, cls.zone.id, cls.services["ostype"]) if cls.template == FAILED: - assert False, "get_template() failed to return template with description %s" % cls.services["ostype"] + assert False, "get_suitable_test_template() failed to return template with description %s" % cls.services["ostype"] cls.services["small"]["zoneid"] = cls.zone.id cls.services["small"]["template"] = cls.template.id cls._cleanup = [] diff --git a/test/integration/smoke/test_backup_recovery_nas.py b/test/integration/smoke/test_backup_recovery_nas.py index 96021b9edff8..ccee60a3806e 100644 --- a/test/integration/smoke/test_backup_recovery_nas.py +++ b/test/integration/smoke/test_backup_recovery_nas.py @@ -21,7 +21,7 @@ from marvin.lib.utils import (cleanup_resources) from marvin.lib.base import (Account, Network, ServiceOffering, DiskOffering, VirtualMachine, BackupOffering, NetworkOffering, BackupRepository, Backup, Configurations, Volume, StoragePool) -from marvin.lib.common import (get_domain, get_zone, get_template) +from marvin.lib.common import (get_domain, get_zone, get_suitable_test_template) from nose.plugins.attrib import attr from marvin.codes import FAILED import time @@ -39,9 +39,9 @@ def setUpClass(cls): cls.services["mode"] = cls.zone.networktype cls.hypervisor = cls.testClient.getHypervisorInfo() cls.domain = get_domain(cls.api_client) - cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) + cls.template = get_suitable_test_template(cls.api_client, cls.zone.id, cls.services["ostype"]) if cls.template == FAILED: - assert False, "get_template() failed to return template with description %s" % cls.services["ostype"] + assert False, "get_suitable_test_template() failed to return template with description %s" % cls.services["ostype"] cls.services["small"]["zoneid"] = cls.zone.id cls.services["small"]["template"] = cls.template.id cls._cleanup = [] @@ -245,7 +245,7 @@ def test_vm_backup_create_vm_from_backup_in_another_zone(self): return self.destZone = zones[1] - template = get_template(self.api_client, self.destZone.id, self.services["ostype"]) + template = get_suitable_test_template(self.api_client, self.destZone.id, self.services["ostype"]) list_isolated_network_offerings_response = NetworkOffering.list( self.apiclient, diff --git a/test/integration/smoke/test_backup_recovery_veeam.py b/test/integration/smoke/test_backup_recovery_veeam.py index f99b3db17d44..b36f311b60d0 100644 --- a/test/integration/smoke/test_backup_recovery_veeam.py +++ b/test/integration/smoke/test_backup_recovery_veeam.py @@ -20,7 +20,7 @@ from marvin.lib.utils import wait_until from marvin.lib.base import (Account, ServiceOffering, DiskOffering, Volume, VirtualMachine, BackupOffering, Configurations, Backup, BackupSchedule) -from marvin.lib.common import (get_domain, get_zone, get_template) +from marvin.lib.common import (get_domain, get_zone, get_suitable_test_template) from nose.plugins.attrib import attr from marvin.codes import FAILED @@ -39,9 +39,9 @@ def setUpClass(cls): cls.services["mode"] = cls.zone.networktype cls.hypervisor = cls.testClient.getHypervisorInfo() cls.domain = get_domain(cls.apiclient) - cls.template = get_template(cls.apiclient, cls.zone.id, cls.services["ostype"]) + cls.template = get_suitable_test_template(cls.apiclient, cls.zone.id, cls.services["ostype"]) if cls.template == FAILED: - assert False, "get_template() failed to return template with description %s" % cls.services["ostype"] + assert False, "get_suitable_test_template() failed to return template with description %s" % cls.services["ostype"] cls.services["small"]["zoneid"] = cls.zone.id cls.services["small"]["template"] = cls.template.id cls._cleanup = [] diff --git a/test/integration/smoke/test_console_endpoint.py b/test/integration/smoke/test_console_endpoint.py index 84b893e57012..afd4631d87bc 100644 --- a/test/integration/smoke/test_console_endpoint.py +++ b/test/integration/smoke/test_console_endpoint.py @@ -21,7 +21,7 @@ from marvin.lib.base import * from marvin.lib.common import (get_domain, get_zone, - get_template) + get_suitable_test_template) from nose.plugins.attrib import attr class TestConsoleEndpoint(cloudstackTestCase): @@ -36,14 +36,14 @@ def setUpClass(cls): cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests()) cls.hypervisor = cls.testClient.getHypervisorInfo() - cls.template = get_template( + cls.template = get_suitable_test_template( cls.apiclient, cls.zone.id, - cls.hypervisor + hypervisor=cls.hypervisor ) if cls.template == FAILED: - assert False, "get_template() failed to return template" + assert False, "get_suitable_test_template() failed to return template" cls.services["virtual_machine"]["zoneid"] = cls.zone.id diff --git a/test/integration/smoke/test_deploy_vm_extra_config_data.py b/test/integration/smoke/test_deploy_vm_extra_config_data.py index 98e60f9d287c..c224e151d194 100644 --- a/test/integration/smoke/test_deploy_vm_extra_config_data.py +++ b/test/integration/smoke/test_deploy_vm_extra_config_data.py @@ -35,7 +35,7 @@ Host) from marvin.lib.common import (get_domain, get_zone, - get_template, + get_suitable_test_template, list_hosts) from marvin.lib.utils import * from nose.plugins.attrib import attr @@ -155,7 +155,7 @@ def deploy_vm(self, hypervisor, extra_config=None): if extra_config is not None: cmd.extraconfig = extra_config - template = get_template( + template = get_suitable_test_template( self.apiclient, self.zone.id, hypervisor=hypervisor diff --git a/test/integration/smoke/test_gateway_on_shared_networks.py b/test/integration/smoke/test_gateway_on_shared_networks.py index dd2982f569db..bcf59a4bf093 100644 --- a/test/integration/smoke/test_gateway_on_shared_networks.py +++ b/test/integration/smoke/test_gateway_on_shared_networks.py @@ -29,7 +29,7 @@ ) from marvin.lib.common import (get_domain, get_zone, - get_template, + get_suitable_test_template, find_storage_pool_type, get_builtin_template_info) from marvin.codes import ( @@ -69,7 +69,7 @@ def setUpClass(cls): cls.services["template"]["hypervisor"] = builtin_info[1] cls.services["template"]["format"] = builtin_info[2] - cls.template = get_template( + cls.template = get_suitable_test_template( cls.apiclient, cls.zone.id ) diff --git a/test/integration/smoke/test_host_control_state.py b/test/integration/smoke/test_host_control_state.py index 4b8409ecc276..7edb39322660 100644 --- a/test/integration/smoke/test_host_control_state.py +++ b/test/integration/smoke/test_host_control_state.py @@ -25,7 +25,7 @@ from marvin.cloudstackTestCase import cloudstackTestCase from marvin.lib.common import (get_domain, get_zone, - get_template, + get_suitable_test_template, list_hosts, list_routers, list_ssvms, @@ -55,10 +55,10 @@ def setUpClass(cls): cls.hypervisor = cls.testClient.getHypervisorInfo() cls.hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][0].__dict__["clusters"][0].__dict__["hosts"][0].__dict__ - cls.template = get_template( + cls.template = get_suitable_test_template( cls.apiclient, cls.zone.id, - cls.hypervisor + hypervisor=cls.hypervisor ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id diff --git a/test/integration/smoke/test_instance_boot_group.py b/test/integration/smoke/test_instance_boot_group.py index 69c0e333637e..e0c9b9beb7dd 100644 --- a/test/integration/smoke/test_instance_boot_group.py +++ b/test/integration/smoke/test_instance_boot_group.py @@ -26,7 +26,7 @@ InstanceBootGroupReadinessRule) from marvin.lib.common import (get_domain, get_zone, - get_template) + get_suitable_test_template) from marvin.lib.utils import (random_gen) from marvin.cloudstackException import CloudstackAPIException from marvin.codes import FAILED @@ -51,13 +51,13 @@ def setUpClass(cls): cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.hypervisor = testClient.getHypervisorInfo() - cls.template = get_template( + cls.template = get_suitable_test_template( cls.apiclient, - zone_id=cls.zone.id, + zoneid=cls.zone.id, hypervisor=cls.hypervisor ) if cls.template == FAILED: - assert False, "get_template() failed to return template" + assert False, "get_suitable_test_template() failed to return template" cls._cleanup = [] cls.account = Account.create( diff --git a/test/integration/smoke/test_ipv4_routing.py b/test/integration/smoke/test_ipv4_routing.py index 124be678965c..d6461610b0bd 100644 --- a/test/integration/smoke/test_ipv4_routing.py +++ b/test/integration/smoke/test_ipv4_routing.py @@ -22,10 +22,11 @@ import time from marvin.cloudstackTestCase import cloudstackTestCase +from marvin.codes import FAILED from marvin.lib.base import ZoneIpv4Subnet, Domain, Account, ServiceOffering, NetworkOffering, VpcOffering, Network, \ - Ipv4SubnetForGuestNetwork, VirtualMachine, VPC, NetworkACLList, NetworkACL, RoutingFirewallRule, Template, ASNRange, \ + Ipv4SubnetForGuestNetwork, VirtualMachine, VPC, NetworkACLList, NetworkACL, RoutingFirewallRule, ASNRange, \ BgpPeer, Router -from marvin.lib.common import get_domain, get_zone, list_routers, list_hosts +from marvin.lib.common import get_domain, get_zone, get_test_template, list_routers, list_hosts from marvin.lib.utils import get_host_credentials, get_process_status from nose.plugins.attrib import attr @@ -167,11 +168,10 @@ def setUpClass(cls): cls.logger.setLevel(logging.DEBUG) cls.logger.addHandler(cls.stream_handler) - # 0. register template - cls.template = Template.register(cls.apiclient, cls.services["test_templates"][cls.hypervisor.lower()], - zoneid=cls.zone.id, hypervisor=cls.hypervisor.lower()) - cls.template.download(cls.apiclient) - cls._cleanup.append(cls.template) + # 0. get the shared public test template + cls.template = get_test_template(cls.apiclient, cls.zone.id, cls.hypervisor) + if cls.template == FAILED: + assert False, "get_test_template() failed to return template" # 1.1 create subnet for zone cls.subnet_1 = ZoneIpv4Subnet.create( diff --git a/test/integration/smoke/test_kms_lifecycle.py b/test/integration/smoke/test_kms_lifecycle.py index 79deb5bdf0e2..f23e0bc3aa8f 100644 --- a/test/integration/smoke/test_kms_lifecycle.py +++ b/test/integration/smoke/test_kms_lifecycle.py @@ -42,7 +42,7 @@ ServiceOffering, Volume, ) -from marvin.lib.common import get_zone, get_domain, get_template +from marvin.lib.common import get_zone, get_domain, get_suitable_test_template from marvin.lib.utils import cleanup_resources from nose.plugins.attrib import attr @@ -428,7 +428,7 @@ def test_12_deploy_vm_with_root_disk_encryption(self): key = self._create_kms_key(name=_random_name("vm-root-key"), profile_id=self.default_profile.id, apiclient=self.user_apiclient) # 2. Get a template and a service offering - template = get_template( + template = get_suitable_test_template( self.apiclient, self.zone.id, self.test_client.getParsedTestDataConfig().get("ostype", "CentOS 7.0 (64-bit)") diff --git a/test/integration/smoke/test_migration.py b/test/integration/smoke/test_migration.py index cadb50692a9b..24b74d73f526 100644 --- a/test/integration/smoke/test_migration.py +++ b/test/integration/smoke/test_migration.py @@ -31,7 +31,7 @@ ) from marvin.lib.common import (get_domain, get_zone, - get_template, + get_suitable_test_template, list_virtual_machines) from marvin.lib.utils import (get_hypervisor_type, @@ -90,7 +90,7 @@ def setUpClass(cls): cls.zone = get_zone( cls.api_client, cls.testClient.getZoneForTests()) - cls.template = get_template( + cls.template = get_suitable_test_template( cls.api_client, cls.zone.id, cls.test_data["ostype"] diff --git a/test/integration/smoke/test_network.py b/test/integration/smoke/test_network.py index 3a0db0feafee..a47a5c37e776 100644 --- a/test/integration/smoke/test_network.py +++ b/test/integration/smoke/test_network.py @@ -45,7 +45,7 @@ from marvin.lib.common import (get_domain, get_free_vlan, get_zone, - get_template, + get_suitable_test_template, get_test_template, list_hosts, list_publicIP, @@ -1925,8 +1925,8 @@ def setUpClass(cls): # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests()) - cls.template = get_template(cls.apiclient, cls.zone.id, - cls.services["ostype"]) + cls.template = get_suitable_test_template(cls.apiclient, cls.zone.id, + cls.services["ostype"]) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id diff --git a/test/integration/smoke/test_persistent_network.py b/test/integration/smoke/test_persistent_network.py index 5ca3d6a506aa..d8ceaad6edc2 100644 --- a/test/integration/smoke/test_persistent_network.py +++ b/test/integration/smoke/test_persistent_network.py @@ -30,7 +30,7 @@ ServiceOffering, NetworkOffering) from marvin.lib.common import (get_zone, - get_template, + get_suitable_test_template, verifyNetworkState, wait_for_cleanup, list_routers, list_hosts) from nose.plugins.attrib import attr @@ -74,7 +74,7 @@ def setUpClass(cls): 0].__dict__ # Get Zone and templates cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) - cls.template = get_template( + cls.template = get_suitable_test_template( cls.api_client, cls.zone.id, cls.services["ostype"] diff --git a/test/integration/smoke/test_purge_expunged_vms.py b/test/integration/smoke/test_purge_expunged_vms.py index 4a5da9d1c3ac..3939a30284b8 100644 --- a/test/integration/smoke/test_purge_expunged_vms.py +++ b/test/integration/smoke/test_purge_expunged_vms.py @@ -33,7 +33,7 @@ Configurations) from marvin.lib.common import (get_domain, get_zone, - get_template) + get_suitable_test_template) from marvin.lib.utils import (random_gen) from marvin.lib.decoratorGenerators import skipTestIf from marvin.sshClient import SshClient @@ -75,12 +75,12 @@ def setUpClass(cls): cls.logger = logging.getLogger('TestPurgeExpungedVms') cls.logger.setLevel(logging.DEBUG) - template = get_template( + template = get_suitable_test_template( cls.apiclient, cls.zone.id, cls.services["ostype"]) if template == FAILED: - assert False, "get_template() failed to return template with description %s" % cls.services["ostype"] + assert False, "get_suitable_test_template() failed to return template with description %s" % cls.services["ostype"] # Set Zones and disk offerings cls.services["small"]["zoneid"] = cls.zone.id diff --git a/test/integration/smoke/test_restore_vm.py b/test/integration/smoke/test_restore_vm.py index b961bee39f28..a97395d7b55a 100644 --- a/test/integration/smoke/test_restore_vm.py +++ b/test/integration/smoke/test_restore_vm.py @@ -22,7 +22,7 @@ # Import Local Modules from marvin.cloudstackTestCase import cloudstackTestCase from marvin.lib.base import (VirtualMachine, Volume, DiskOffering, ServiceOffering, Template) -from marvin.lib.common import (get_zone, get_domain, list_storage_pools) +from marvin.lib.common import (get_zone, get_domain, get_test_template, list_storage_pools) from nose.plugins.attrib import attr _multiprocess_shared_ = True @@ -51,11 +51,8 @@ def setUpClass(cls): cls.disk_offering = DiskOffering.create(cls.apiclient, cls.services["disk_offering"], disksize='8') cls._cleanup.append(cls.disk_offering) - template_t1 = Template.register(cls.apiclient, cls.services["test_templates"][ - cls.hypervisor.lower() if cls.hypervisor.lower() != 'simulator' else 'xenserver'], - zoneid=cls.zone.id, hypervisor=cls.hypervisor.lower()) - cls._cleanup.append(template_t1) - template_t1.download(cls.apiclient) + # the first template is the shared public test template, the restore needs another one + template_t1 = get_test_template(cls.apiclient, cls.zone.id, cls.hypervisor) cls.template_t1 = Template.list(cls.apiclient, templatefilter='all', id=template_t1.id)[0] template_t2 = Template.register(cls.apiclient, cls.services["test_templates"][ diff --git a/test/integration/smoke/test_snapshots.py b/test/integration/smoke/test_snapshots.py index b1a2569d9694..b7ea437285b4 100644 --- a/test/integration/smoke/test_snapshots.py +++ b/test/integration/smoke/test_snapshots.py @@ -434,14 +434,9 @@ def setUpClass(cls): UserName=cls.account.name, DomainName=cls.account.domain ) - cls.template = Template.register( - cls.userapiclient, - cls.services["test_templates"][cls.hypervisor.lower()], - zoneid=cls.zone.id, - hypervisor=cls.hypervisor - ) - cls._cleanup.append(cls.template) - cls.template.download(cls.apiclient) + cls.template = get_test_template(cls.apiclient, cls.zone.id, cls.hypervisor) + if cls.template == FAILED: + assert False, "get_test_template() failed to return template" cls.ostypeid = cls.template.ostypeid cls.virtual_machine = VirtualMachine.create( cls.userapiclient, diff --git a/test/integration/smoke/test_usage_events.py b/test/integration/smoke/test_usage_events.py index 94bf75ac3e31..890c93163b72 100644 --- a/test/integration/smoke/test_usage_events.py +++ b/test/integration/smoke/test_usage_events.py @@ -24,7 +24,7 @@ VirtualMachine) from marvin.lib.common import (get_domain, get_zone, - get_template) + get_suitable_test_template) from marvin.codes import (PASS) class TestUsageEvents(cloudstackTestCase): @@ -39,7 +39,7 @@ def setUpClass(cls): cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) - cls.template = get_template( + cls.template = get_suitable_test_template( cls.apiclient, cls.zone.id, cls.testdata["ostype"]) diff --git a/test/integration/smoke/test_vm_deployment_planner.py b/test/integration/smoke/test_vm_deployment_planner.py index e8d24cbf31e5..418264f5533b 100644 --- a/test/integration/smoke/test_vm_deployment_planner.py +++ b/test/integration/smoke/test_vm_deployment_planner.py @@ -24,7 +24,7 @@ Host, Pod, Cluster) from marvin.lib.common import (get_domain, get_zone, - get_template) + get_suitable_test_template) from marvin.lib.utils import cleanup_resources from nose.plugins.attrib import attr @@ -67,7 +67,7 @@ def tearDownClass(cls): def deploy_vm(self, destination_id): cmd = deployVirtualMachine.deployVirtualMachineCmd() - template = get_template( + template = get_suitable_test_template( self.apiclient, self.zone.id ) @@ -112,7 +112,7 @@ def test_02_deploy_vm_on_specific_cluster(self): target_id = target_cluster.id cluster_hypervisor = target_cluster.hypervisortype - template = get_template( + template = get_suitable_test_template( self.apiclient, hypervisor=cluster_hypervisor ) @@ -153,7 +153,7 @@ def test_03_deploy_vm_on_specific_pod(self): cmd.zoneid = target_pod.zoneid cmd.serviceofferingid = self.service_offering.id - template = get_template( + template = get_suitable_test_template( self.apiclient, hypervisor=host[0].hypervisortype ) @@ -193,7 +193,7 @@ def test_04_deploy_vm_on_host_override_pod_and_cluster(self): # Required parameters cmd.zoneid = self.zone.id cmd.serviceofferingid = self.service_offering.id - template = get_template(self.apiclient, zone_id=self.zone.id, hypervisor=host.hypervisor) + template = get_suitable_test_template(self.apiclient, zoneid=self.zone.id, hypervisor=host.hypervisor) cmd.templateid = template.id # Add optional deployment params @@ -229,7 +229,7 @@ def test_05_deploy_vm_on_cluster_override_pod(self): # Required parameters cmd.zoneid = self.zone.id cmd.serviceofferingid = self.service_offering.id - template = get_template(self.apiclient, zone_id=self.zone.id, hypervisor=clusters[0].hypervisortype) + template = get_suitable_test_template(self.apiclient, zoneid=self.zone.id, hypervisor=clusters[0].hypervisortype) cmd.templateid = template.id # Add optional deployment params diff --git a/test/integration/smoke/test_vm_lifecycle_with_snapshot_or_volume.py b/test/integration/smoke/test_vm_lifecycle_with_snapshot_or_volume.py index 871cf25a4021..c67914b583f5 100644 --- a/test/integration/smoke/test_vm_lifecycle_with_snapshot_or_volume.py +++ b/test/integration/smoke/test_vm_lifecycle_with_snapshot_or_volume.py @@ -33,7 +33,7 @@ Template) from marvin.lib.common import (get_domain, get_zone, - get_template, + get_suitable_test_template, list_hosts, list_volumes, list_storage_pools) @@ -60,11 +60,9 @@ def setUpClass(cls): if cls.hypervisor.lower() != "kvm": raise unittest.SkipTest("Only KVM hypervisor is supported for deployment of a VM with volume/snapshot") - cls.template = get_template( + cls.template = get_suitable_test_template( cls.apiclient, - cls.zone.id, - account="system" - ) + cls.zone.id) if cls.template == FAILED: assert False, "get_template failed to return template with description [system]" diff --git a/test/integration/smoke/test_vm_schedule.py b/test/integration/smoke/test_vm_schedule.py index 1e476c55fc87..99f590e9d3f8 100644 --- a/test/integration/smoke/test_vm_schedule.py +++ b/test/integration/smoke/test_vm_schedule.py @@ -18,7 +18,7 @@ """ from marvin.cloudstackTestCase import cloudstackTestCase from marvin.lib.base import Account, ServiceOffering, VirtualMachine, ResourceSchedule -from marvin.lib.common import get_domain, get_zone, get_template +from marvin.lib.common import get_domain, get_zone, get_suitable_test_template from marvin.lib.utils import cleanup_resources # Import Local Modules @@ -96,7 +96,7 @@ def setUpClass(cls): cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services["mode"] = cls.zone.networktype - template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) + template = get_suitable_test_template(cls.api_client, cls.zone.id, cls.services["ostype"]) cls.services["domainid"] = cls.domain.id cls.services["server"]["zoneid"] = cls.zone.id diff --git a/test/integration/smoke/test_vnf_templates.py b/test/integration/smoke/test_vnf_templates.py index f963ce41b384..757f128ff182 100644 --- a/test/integration/smoke/test_vnf_templates.py +++ b/test/integration/smoke/test_vnf_templates.py @@ -28,7 +28,7 @@ VnfAppliance, VnfTemplate, Zone) -from marvin.lib.common import get_zone, get_template +from marvin.lib.common import get_zone, get_suitable_test_template from nose.plugins.attrib import attr import time @@ -55,7 +55,7 @@ def setUpClass(cls): cls.hypervisor = cls.testClient.getHypervisorInfo() zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests()) cls.zone = Zone(zone.__dict__) - cls.template = get_template(cls.apiclient, cls.zone.id) + cls.template = get_suitable_test_template(cls.apiclient, cls.zone.id) cls.domain = Domain.create( cls.apiclient, diff --git a/tools/marvin/marvin/lib/common.py b/tools/marvin/marvin/lib/common.py index cc773654faa0..5e574b742c1b 100644 --- a/tools/marvin/marvin/lib/common.py +++ b/tools/marvin/marvin/lib/common.py @@ -74,7 +74,8 @@ xsplit, get_process_status, random_gen, - format_volume_to_ext3) + format_volume_to_ext3, + get_hypervisor_type) from marvin.lib.base import (PhysicalNetwork, PublicIPAddress, NetworkOffering, @@ -516,19 +517,23 @@ def get_windows_template( return FAILED -def get_suitable_test_template(apiclient, zoneid, ostypeid, hypervisor, deploy_as_is=False): +def get_suitable_test_template(apiclient, zoneid=None, ostypeid=None, hypervisor=None, deploy_as_is=False): ''' @Name : get_suitable_test_template @Desc : Retrieves the test template information based upon inputs provided - For Xenserver, get_test_template is used for retrieving the template - while get_template is used for other hypervisors or when - get_test_template fails + For XenServer and KVM, get_test_template is used for retrieving the + shared public test template (tiny), which is registered by the + admin only when it is missing. get_template is used for other + hypervisors or when get_test_template fails + The hypervisor is detected from the hosts when it is not given @Input : returns a template" @Output : FAILED in case of any failure template Information matching the inputs ''' template = FAILED - if hypervisor.lower() in ["xenserver"] or (hypervisor.lower() in ["vmware"] and deploy_as_is): + if hypervisor is None: + hypervisor = get_hypervisor_type(apiclient) + if hypervisor.lower() in ["xenserver", "kvm"] or (hypervisor.lower() in ["vmware"] and deploy_as_is): template = get_test_template( apiclient, zoneid, From 5ae335ce3c80d1cac9da47c22fa018d046dded0f Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Wed, 21 Oct 2026 14:28:38 +0200 Subject: [PATCH 11/64] test_snapshots: register the template in the standalone backup class again TestSnapshotStandaloneBackup takes a snapshot, expunges the VM and then deletes its template, to test the snapshot without its template. It needs its own template, so it cannot use the shared public test template. --- test/integration/smoke/test_snapshots.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/integration/smoke/test_snapshots.py b/test/integration/smoke/test_snapshots.py index b7ea437285b4..b1a2569d9694 100644 --- a/test/integration/smoke/test_snapshots.py +++ b/test/integration/smoke/test_snapshots.py @@ -434,9 +434,14 @@ def setUpClass(cls): UserName=cls.account.name, DomainName=cls.account.domain ) - cls.template = get_test_template(cls.apiclient, cls.zone.id, cls.hypervisor) - if cls.template == FAILED: - assert False, "get_test_template() failed to return template" + cls.template = Template.register( + cls.userapiclient, + cls.services["test_templates"][cls.hypervisor.lower()], + zoneid=cls.zone.id, + hypervisor=cls.hypervisor + ) + cls._cleanup.append(cls.template) + cls.template.download(cls.apiclient) cls.ostypeid = cls.template.ostypeid cls.virtual_machine = VirtualMachine.create( cls.userapiclient, From a069b168e4d3116047a54c1807804b2c73f59694 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Wed, 21 Oct 2026 19:34:55 +0200 Subject: [PATCH 12/64] systemvm: start and stop the cloud-init units of cloud-init 25.1 cloud-init 25.1 and later (Debian 13) does not have cloud-init.service anymore. cloud-init-main is a single process which runs all the stages, and cloud-init-local, cloud-init-network, cloud-config and cloud-final hand over to it. "systemctl start cloud-init" failed, and the other two units were started without cloud-init-main, so the user data of the shared filesystem VMs and of the CKS nodes was never run. Add start_cloud_init and stop_cloud_init to common.sh and use them in sharedfsvm.sh and cksnode.sh. The old units are still used if cloud-init-main does not exist. --- .../debian/opt/cloud/bin/setup/cksnode.sh | 7 ++---- systemvm/debian/opt/cloud/bin/setup/common.sh | 22 +++++++++++++++++++ .../debian/opt/cloud/bin/setup/sharedfsvm.sh | 7 ++---- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/systemvm/debian/opt/cloud/bin/setup/cksnode.sh b/systemvm/debian/opt/cloud/bin/setup/cksnode.sh index e1541f6d0bd1..39d9c65a6371 100755 --- a/systemvm/debian/opt/cloud/bin/setup/cksnode.sh +++ b/systemvm/debian/opt/cloud/bin/setup/cksnode.sh @@ -68,12 +68,9 @@ setup_k8s_node() { log_it "Starting cloud-init services" systemctl enable --now --no-block containerd if [ -f /home/cloud/success ]; then - systemctl stop cloud-init cloud-config cloud-final - systemctl disable cloud-init cloud-config cloud-final + stop_cloud_init else - systemctl start --no-block cloud-init - systemctl start --no-block cloud-config - systemctl start --no-block cloud-final + start_cloud_init fi } diff --git a/systemvm/debian/opt/cloud/bin/setup/common.sh b/systemvm/debian/opt/cloud/bin/setup/common.sh index ef1576ab588c..1c19d23493cb 100755 --- a/systemvm/debian/opt/cloud/bin/setup/common.sh +++ b/systemvm/debian/opt/cloud/bin/setup/common.sh @@ -700,6 +700,28 @@ setup_ntp() { fi } +# cloud-init 25.1 and later (Debian 13) does not have cloud-init.service anymore: cloud-init-main is +# a single process which runs all the stages, and the units of the stages hand over to it +start_cloud_init() { + if systemctl cat cloud-init-main.service > /dev/null 2>&1; then + systemctl start --no-block cloud-init-main cloud-init-local cloud-init-network cloud-config cloud-final + else + systemctl start --no-block cloud-init + systemctl start --no-block cloud-config + systemctl start --no-block cloud-final + fi +} + +stop_cloud_init() { + local svc + for svc in cloud-init cloud-init-main cloud-init-local cloud-init-network cloud-config cloud-final; do + if systemctl cat ${svc}.service > /dev/null 2>&1; then + systemctl stop ${svc} + systemctl disable ${svc} + fi + done +} + routing_svcs() { echo "haproxy apache2 frr" > /var/cache/cloud/enabled_svcs echo "cloud nfs-common portmap" > /var/cache/cloud/disabled_svcs diff --git a/systemvm/debian/opt/cloud/bin/setup/sharedfsvm.sh b/systemvm/debian/opt/cloud/bin/setup/sharedfsvm.sh index 1b1bb2737534..ca6d2d106940 100755 --- a/systemvm/debian/opt/cloud/bin/setup/sharedfsvm.sh +++ b/systemvm/debian/opt/cloud/bin/setup/sharedfsvm.sh @@ -57,12 +57,9 @@ setup_sharedfsvm() { log_it "Starting cloud-init services" if [ -f /home/cloud/success ]; then - systemctl stop cloud-init cloud-config cloud-final - systemctl disable cloud-init cloud-config cloud-final + stop_cloud_init else - systemctl start --no-block cloud-init - systemctl start --no-block cloud-config - systemctl start --no-block cloud-final + start_cloud_init fi } From 155a3cb2ecfd65bfc50a3b2348b1e77b328408ee Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Wed, 21 Oct 2026 19:34:58 +0200 Subject: [PATCH 13/64] systemvmtemplate: install ntpsec instead of chrony The ntp package does not exist in Debian 13. On Debian 12 it was a transitional package for ntpsec, and setup_ntp in common.sh configures the NTP servers in /etc/ntpsec/ntp.conf and enables the ntp service, which is an alias of ntpsec.service. With chrony, the custom NTP servers of the console proxy and secondary storage VMs were not applied. --- tools/appliance/systemvmtemplate/http/preseed_aarch64.cfg | 2 +- tools/appliance/systemvmtemplate/http/preseed_x86_64.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/appliance/systemvmtemplate/http/preseed_aarch64.cfg b/tools/appliance/systemvmtemplate/http/preseed_aarch64.cfg index 92e426d3d0d2..46967d175978 100644 --- a/tools/appliance/systemvmtemplate/http/preseed_aarch64.cfg +++ b/tools/appliance/systemvmtemplate/http/preseed_aarch64.cfg @@ -107,7 +107,7 @@ d-i passwd/user-default-groups string audio cdrom video admin ### Package selection tasksel tasksel/first multiselect ssh-server -d-i pkgsel/include string openssh-server chrony acpid sudo bzip2 openssl +d-i pkgsel/include string openssh-server ntpsec acpid sudo bzip2 openssl # Allowed values: none, safe-upgrade, full-upgrade d-i pkgsel/upgrade select full-upgrade d-i pkgsel/update-policy select none diff --git a/tools/appliance/systemvmtemplate/http/preseed_x86_64.cfg b/tools/appliance/systemvmtemplate/http/preseed_x86_64.cfg index fdcfe83c1010..a9936c5d2c41 100644 --- a/tools/appliance/systemvmtemplate/http/preseed_x86_64.cfg +++ b/tools/appliance/systemvmtemplate/http/preseed_x86_64.cfg @@ -98,7 +98,7 @@ d-i passwd/user-default-groups string audio cdrom video admin ### Package selection tasksel tasksel/first multiselect ssh-server -d-i pkgsel/include string openssh-server chrony acpid sudo bzip2 openssl +d-i pkgsel/include string openssh-server ntpsec acpid sudo bzip2 openssl # Allowed values: none, safe-upgrade, full-upgrade d-i pkgsel/upgrade select full-upgrade d-i pkgsel/update-policy select none From 60ea381115405db4d0523c4064dc78ef88d00cbe Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Wed, 21 Oct 2026 19:35:13 +0200 Subject: [PATCH 14/64] systemvm: do not use the cgi module in the password server The cgi module was removed in Python 3.13, which is used by Debian 13, so cloud-password-server failed to start with "No module named 'cgi'", and the VMs could not get their passwords. Parse the POST of savepassword.sh (multipart/form-data, sent by curl -F) with the email package instead of cgi.FieldStorage, and also accept application/x-www-form-urlencoded. Add unit tests, including a request sent by curl. --- .../debian/opt/cloud/bin/passwd_server_ip.py | 37 +++++--- systemvm/test/TestPasswdServerIp.py | 84 +++++++++++++++++++ 2 files changed, 111 insertions(+), 10 deletions(-) create mode 100644 systemvm/test/TestPasswdServerIp.py diff --git a/systemvm/debian/opt/cloud/bin/passwd_server_ip.py b/systemvm/debian/opt/cloud/bin/passwd_server_ip.py index bf1eab2db02f..5d1ac4c34f12 100755 --- a/systemvm/debian/opt/cloud/bin/passwd_server_ip.py +++ b/systemvm/debian/opt/cloud/bin/passwd_server_ip.py @@ -26,7 +26,7 @@ # curl --header 'DomU_Request: save_password' http://localhost:8080/ -F ip= -F password= import binascii -import cgi +import email.policy import os import socketserver import sys @@ -34,6 +34,7 @@ import threading import urllib.parse +from email.parser import BytesParser from http.server import BaseHTTPRequestHandler, HTTPServer from socketserver import ThreadingMixIn @@ -44,6 +45,26 @@ allowAddresses = ['localhost', '127.0.0.1'] lock = threading.RLock() + +def parseForm(contentType, body): + """ Parse a POST body (multipart/form-data, as sent by curl -F, or + application/x-www-form-urlencoded) to a dict of field name -> value. + The cgi module, which was used before, is not available in Python 3.13 """ + form = {} + contentType = contentType or '' + if contentType.lower().startswith('multipart/form-data'): + message = BytesParser(policy=email.policy.HTTP).parsebytes( + b'Content-Type: ' + contentType.encode() + b'\r\n\r\n' + body) + if message.is_multipart(): + for part in message.iter_parts(): + name = part.get_param('name', header='content-disposition') + if name: + form[name] = part.get_payload(decode=True).decode('utf-8', 'replace') + else: + for name, values in urllib.parse.parse_qs(body.decode('utf-8', 'replace'), keep_blank_values=True).items(): + form[name] = values[0] + return form + def getTokenFile(): return '/tmp/passwdsrvrtoken' @@ -140,12 +161,8 @@ def do_GET(self): return def do_POST(self): - form = cgi.FieldStorage( - fp=self.rfile, - headers=self.headers, - environ={'REQUEST_METHOD':'POST', - 'CONTENT_TYPE':self.headers['content-type'], - }) + form = parseForm(self.headers.get('content-type'), + self.rfile.read(int(self.headers.get('content-length', 0)))) self.send_response(200) self.end_headers() clientAddress = self.client_address[0] @@ -157,13 +174,13 @@ def do_POST(self): syslog.syslog('serve_password: request trying to save password does not contain both ip and password') self.send_response(403) return - token = form['token'].value + token = form['token'] if not checkToken(token): syslog.syslog('serve_password: invalid save_password token received from %s' % clientAddress) self.send_response(403) return - ip = form['ip'].value - password = form['password'].value + ip = form['ip'] + password = form['password'] if not ip or not password: syslog.syslog('serve_password: empty ip/password[%s/%s] received from savepassword' % (ip, password)) return diff --git a/systemvm/test/TestPasswdServerIp.py b/systemvm/test/TestPasswdServerIp.py new file mode 100644 index 000000000000..2774ae037bbd --- /dev/null +++ b/systemvm/test/TestPasswdServerIp.py @@ -0,0 +1,84 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +import shutil +import subprocess +import threading +import unittest +from http.server import BaseHTTPRequestHandler, HTTPServer + +import passwd_server_ip + + +class TestPasswdServerIp(unittest.TestCase): + + def multipart(self, fields, boundary="----boundary123"): + body = b"" + for name, value in fields.items(): + body += ("--%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n" % (boundary, name)).encode() + body += value.encode() + b"\r\n" + body += ("--%s--\r\n" % boundary).encode() + return "multipart/form-data; boundary=%s" % boundary, body + + def test_parse_multipart_form(self): + contentType, body = self.multipart({"ip": "10.1.1.5", "password": "Ab1&=;'\"x y", "token": "abc"}) + form = passwd_server_ip.parseForm(contentType, body) + self.assertEqual({"ip": "10.1.1.5", "password": "Ab1&=;'\"x y", "token": "abc"}, form) + + def test_parse_multipart_form_with_non_ascii_value(self): + contentType, body = self.multipart({"password": "päss"}) + self.assertEqual("päss", passwd_server_ip.parseForm(contentType, body)["password"]) + + def test_parse_urlencoded_form(self): + form = passwd_server_ip.parseForm("application/x-www-form-urlencoded", b"ip=10.1.1.5&password=a%26b%3Dc&token=abc") + self.assertEqual({"ip": "10.1.1.5", "password": "a&b=c", "token": "abc"}, form) + + def test_parse_form_without_fields(self): + self.assertEqual({}, passwd_server_ip.parseForm(None, b"")) + contentType, body = self.multipart({}) + self.assertEqual({}, passwd_server_ip.parseForm(contentType, body)) + + @unittest.skipUnless(shutil.which("curl"), "curl is not available") + def test_parse_form_posted_by_curl(self): + """ the same request as /opt/cloud/bin/savepassword.sh """ + received = {} + + class Handler(BaseHTTPRequestHandler): + def do_POST(self): + length = int(self.headers.get('content-length', 0)) + received.update(passwd_server_ip.parseForm(self.headers.get('content-type'), self.rfile.read(length))) + self.send_response(200) + self.end_headers() + + def log_message(self, format, *args): + return + + server = HTTPServer(("127.0.0.1", 0), Handler) + thread = threading.Thread(target=server.serve_forever) + thread.start() + try: + subprocess.check_call(["curl", "-s", "--header", "DomU_Request: save_password", + "http://127.0.0.1:%d/" % server.server_address[1], + "-F", "ip=10.1.1.5", "-F", "password=Pa$$w&rd=1", "-F", "token=abc"]) + finally: + server.shutdown() + thread.join() + server.server_close() + self.assertEqual({"ip": "10.1.1.5", "password": "Pa$$w&rd=1", "token": "abc"}, received) + + +if __name__ == '__main__': + unittest.main() From 7f86ab09ec9ebc082da370340acac0cfca14ef4e Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Wed, 21 Oct 2026 19:40:16 +0200 Subject: [PATCH 15/64] test_network_ipv6: accept the ICMPv6 code number in the nft rule The test creates an IPv6 firewall rule with a random ICMPv6 type and code, and expects "icmpv6 code " in "nft list chain". nftables 1.1.3 (Debian 13) prints the code name only for some ICMPv6 types and the number for the others, for example "icmpv6 type ind-neighbor-advert icmpv6 code 4", so the test failed depending on the random type and code. Accept both the code name and the code number. --- test/integration/smoke/test_network_ipv6.py | 23 ++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/test/integration/smoke/test_network_ipv6.py b/test/integration/smoke/test_network_ipv6.py index 1e5cec7ef4c2..3b715c1bcf96 100644 --- a/test/integration/smoke/test_network_ipv6.py +++ b/test/integration/smoke/test_network_ipv6.py @@ -657,8 +657,15 @@ def checkIpv6NetworkRouting(self): cmd.id = fw2.id self.userapiclient.deleteIpv6FirewallRule(cmd) + def isIpv6FirewallRuleListed(self, rules, nft_output): + """ rules are the accepted representations of the rule in the nft output, with or without the braces """ + for rule in rules: + if rule in nft_output or rule.replace("{ ", "").replace(" }", "") in nft_output: + return True + return False + def createAndVerifyIpv6FirewallRule(self, traffic_type, source_cidr, dest_cidr, protocol, - start_port, end_port, icmp_type, icmp_code, parsed_rule, delete=False): + start_port, end_port, icmp_type, icmp_code, parsed_rule, delete=False, alternative_rules=None): self.logger.debug("createAndVerifyIpv6FirewallRule - %s" % parsed_rule) fw_rule = self.createIpv6FirewallRuleInNetwork(self.network.id, traffic_type, source_cidr, dest_cidr, protocol, start_port, end_port, icmp_type, icmp_code) @@ -697,16 +704,16 @@ def createAndVerifyIpv6FirewallRule(self, traffic_type, source_cidr, dest_cidr, "IPv6 firewall rule ICMP code mismatch %d, %d" % (rule.icmpcode, icmp_code)) routerCmd = "nft list chain ip6 %s %s" % (FIREWALL_TABLE, FIREWALL_CHAINS[traffic_type]) res = self.getRouterProcessStatus(self.getNetworkRouter(self.network), routerCmd) - parsed_rule_new = parsed_rule.replace("{ ", "").replace(" }", "") - self.assertTrue(parsed_rule in res or parsed_rule_new in res, - "Listing firewall rule with nft list chain failure for rule: '%s' is not in '%s'" % (parsed_rule, res)) + accepted_rules = [parsed_rule] + (alternative_rules or []) + self.assertTrue(self.isIpv6FirewallRuleListed(accepted_rules, res), + "Listing firewall rule with nft list chain failure for rule: '%s' is not in '%s'" % (accepted_rules, res)) if delete == True: cmd = deleteIpv6FirewallRule.deleteIpv6FirewallRuleCmd() cmd.id = fw_rule.id self.userapiclient.deleteIpv6FirewallRule(cmd) res = self.getRouterProcessStatus(self.getNetworkRouter(self.network), routerCmd) - self.assertFalse(parsed_rule in res or parsed_rule_new in res, - "Firewall rule present in nft list chain failure despite delete for rule: '%s' is in '%s'" % (parsed_rule, res)) + self.assertFalse(self.isIpv6FirewallRuleListed(accepted_rules, res), + "Firewall rule present in nft list chain failure despite delete for rule: '%s' is in '%s'" % (accepted_rules, res)) def checkIpv6FirewallRule(self): traffic_type = "Ingress" @@ -727,8 +734,10 @@ def checkIpv6FirewallRule(self): icmp_type = choice(list(ICMPV6_TYPE.keys())) icmp_code = choice(list(ICMPV6_CODE_TYPE.keys())) rule = "ip6 saddr %s ip6 daddr %s %sv6 type %s %sv6 code %s accept" % (source_cidr, CIDR_IPV6_ANY, protocol, ICMPV6_TYPE[icmp_type], protocol, ICMPV6_CODE_TYPE[icmp_code]) + # nft prints the name of the code only for some ICMPv6 types (depending on its version), else the number + rule_with_code_number = "ip6 saddr %s ip6 daddr %s %sv6 type %s %sv6 code %d accept" % (source_cidr, CIDR_IPV6_ANY, protocol, ICMPV6_TYPE[icmp_type], protocol, icmp_code) self.createAndVerifyIpv6FirewallRule(traffic_type, source_cidr, None, protocol, - None, None, icmp_type, icmp_code, rule) + None, None, icmp_type, icmp_code, rule, alternative_rules=[rule_with_code_number]) action = "accept" if self.isNetworkEgressDefaultPolicyAllow(self.network): From 9e64d81bb92fd9e399ad6c60708757afb13635a1 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Wed, 21 Oct 2026 21:31:02 +0200 Subject: [PATCH 16/64] test_vpc_ipv6: accept the ICMPv6 code number in the nft rule The test creates an egress network ACL rule with a random ICMPv6 type and code, and expects "icmpv6 code " in "nft list chain". nftables 1.1.3 (Debian 13) prints the code name only for some ICMPv6 types and the number for the others, for example "icmpv6 type nd-neighbor-solicit icmpv6 code 0", so the test failed depending on the random type and code. Accept both the code name and the code number, like test_network_ipv6. --- test/integration/smoke/test_vpc_ipv6.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/integration/smoke/test_vpc_ipv6.py b/test/integration/smoke/test_vpc_ipv6.py index bc05334a56ee..3c2fec791038 100644 --- a/test/integration/smoke/test_vpc_ipv6.py +++ b/test/integration/smoke/test_vpc_ipv6.py @@ -761,9 +761,13 @@ def verifyAclRulesInRouter(self, nic, rules, router): acl_chain = nic + ACL_CHAINS_SUFFIX[rule["traffictype"]] routerCmd = "nft list chain ip6 %s %s" % (ACL_TABLE, acl_chain) res = self.getRouterProcessStatus(router, routerCmd) - parsed_rule_new = rule["parsedrule"].replace("{ ", "").replace(" }", "") - self.assertTrue(rule["parsedrule"] in res or parsed_rule_new in res, - "Listing firewall rule with nft list chain failure for rule: '%s' is not in '%s'" % (rule["parsedrule"], res)) + accepted_rules = [rule["parsedrule"]] + rule.get("alternativerules", []) + found = False + for accepted_rule in accepted_rules: + if accepted_rule in res or accepted_rule.replace("{ ", "").replace(" }", "") in res: + found = True + self.assertTrue(found, + "Listing firewall rule with nft list chain failure for rule: '%s' is not in '%s'" % (accepted_rules, res)) def checkIpv6AclRule(self): router = self.getVpcRouter(self.vpc) @@ -794,7 +798,9 @@ def checkIpv6AclRule(self): rule["icmptype"] = choice(list(ICMPV6_TYPE.keys())) rule["icmpcode"] = choice(list(ICMPV6_CODE_TYPE.keys())) parsedrule = "ip6 daddr %s %sv6 type %s %sv6 code %s accept" % (rule["cidrlist"], rule["protocol"], ICMPV6_TYPE[rule["icmptype"]], rule["protocol"], ICMPV6_CODE_TYPE[rule["icmpcode"]]) - rules.append({"traffictype": rule["traffictype"], "parsedrule": parsedrule}) + # nft prints the name of the code only for some ICMPv6 types (depending on its version), else the number + parsedrule_with_code_number = "ip6 daddr %s %sv6 type %s %sv6 code %d accept" % (rule["cidrlist"], rule["protocol"], ICMPV6_TYPE[rule["icmptype"]], rule["protocol"], rule["icmpcode"]) + rules.append({"traffictype": rule["traffictype"], "parsedrule": parsedrule, "alternativerules": [parsedrule_with_code_number]}) self.createNetworkAclRule(rule, tier1_acl.id) self.network.replaceACLList(self.apiclient, tier1_acl.id) From b8ad53f0e22695bb3f2425a8828610d7dd845763 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Wed, 21 Oct 2026 21:13:21 +0200 Subject: [PATCH 17/64] build-acs-image.sh: install nfs-common in the Debian and Ubuntu images The Debian 13 cloud image has no NFS client, so mounting an NFS share in the guest fails with "NFS: mount program didn't pass remote address". The shared file system smoke test mounts the share in the guest. Install nfs-common with the other guest packages. --- scripts/util/build-acs-image.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/util/build-acs-image.sh b/scripts/util/build-acs-image.sh index 57fb7ef24ced..15ad42d03d5b 100755 --- a/scripts/util/build-acs-image.sh +++ b/scripts/util/build-acs-image.sh @@ -333,7 +333,8 @@ detect_os() { local base_cleanup='journalctl --vacuum-time=1s; rm -rf /var/log/*; rm -f /root/.bash_history' case "$OS_FAMILY" in debian) - PACKAGES="qemu-guest-agent,open-vm-tools,xenstore-utils,libxenstore4" + # nfs-common is the NFS client, the cloud images do not have it and the tests mount NFS in the guest + PACKAGES="qemu-guest-agent,open-vm-tools,xenstore-utils,libxenstore4,nfs-common" CLEANUP="apt clean; apt autoclean; apt autoremove --purge -y; $base_cleanup" ;; rhel) # there is no xenstore package in the EL repositories From 9729c4f16a221adebff16ce6a9bed3bffe51ada2 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 22 Oct 2026 11:10:37 +0200 Subject: [PATCH 18/64] smoke tests: use the Debian 13 built-in template on all hypervisors Moving the smoke tests to the shared tiny-kvm template broke the tests that need more from the guest. Run these on the Debian 13 built-in template, taken with get_template on every hypervisor. - test_attach_multiple_volumes, test_volumes: they detach data disks from a running VM, which the tiny-kvm guest never releases. - test_backup_recovery_nas, test_backup_recovery_kboss: they create a VM from a backup and expect the files written in the guest to be in it. - test_primary_storage: it puts a primary storage with running VMs in maintenance, which needs a guest that shuts down on request. - test_volumes: use the 512 MiB big offering, as the Debian 13 guest does not boot with the 128 MiB tiny or the 256 MiB small offering. - test_vm_autoscaling: the scale up condition needs at least 1 percent CPU, and an idle Debian 13 VM uses about 0.4 percent. Start a CPU loop from the template user data. --- .../smoke/test_attach_multiple_volumes.py | 11 ++--- .../smoke/test_backup_recovery_kboss.py | 6 +-- .../smoke/test_backup_recovery_nas.py | 8 ++-- .../integration/smoke/test_primary_storage.py | 18 ++------ test/integration/smoke/test_vm_autoscaling.py | 5 ++- test/integration/smoke/test_volumes.py | 41 ++++++------------- 6 files changed, 31 insertions(+), 58 deletions(-) diff --git a/test/integration/smoke/test_attach_multiple_volumes.py b/test/integration/smoke/test_attach_multiple_volumes.py index 9357e4d65090..89bf780140f0 100644 --- a/test/integration/smoke/test_attach_multiple_volumes.py +++ b/test/integration/smoke/test_attach_multiple_volumes.py @@ -27,9 +27,8 @@ Volume, DiskOffering, ) -from marvin.lib.common import (get_domain, +from marvin.lib.common import (get_template, get_domain, get_zone, - get_suitable_test_template, find_storage_pool_type) from marvin.codes import ( PASS, @@ -69,13 +68,9 @@ def setUpClass(cls): ) cls._cleanup.append(cls.disk_offering) - template = get_suitable_test_template( - cls.apiclient, - cls.zone.id, - cls.services["ostype"], - cls.hypervisor) + template = get_template(cls.apiclient, cls.zone.id, cls.services["ostype"]) if template == FAILED: - assert False, "get_suitable_test_template() failed to return template with description %s" % cls.services["ostype"] + assert False, "get_template() failed to return template with description %s" % cls.services["ostype"] cls.services["domainid"] = cls.domain.id cls.services["zoneid"] = cls.zone.id diff --git a/test/integration/smoke/test_backup_recovery_kboss.py b/test/integration/smoke/test_backup_recovery_kboss.py index ee2c0bb9fb28..971f379f6db5 100644 --- a/test/integration/smoke/test_backup_recovery_kboss.py +++ b/test/integration/smoke/test_backup_recovery_kboss.py @@ -20,7 +20,7 @@ from marvin.lib import utils from marvin.lib.base import (Account, ServiceOffering, DiskOffering, VirtualMachine, BackupOffering, Backup, Configurations, Volume, StoragePool) -from marvin.lib.common import (get_domain, get_zone, get_suitable_test_template) +from marvin.lib.common import (get_template, get_domain, get_zone) from nose.plugins.attrib import attr from marvin.codes import FAILED import time @@ -43,9 +43,9 @@ def setUpClass(cls): cls.services["mode"] = cls.zone.networktype cls.hypervisor = cls.testClient.getHypervisorInfo() cls.domain = get_domain(cls.api_client) - cls.template = get_suitable_test_template(cls.api_client, cls.zone.id, cls.services["ostype"]) + cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) if cls.template == FAILED: - assert False, "get_suitable_test_template() failed to return template with description %s" % cls.services["ostype"] + assert False, "get_template() failed to return template with description %s" % cls.services["ostype"] cls.services["small"]["zoneid"] = cls.zone.id cls.services["small"]["template"] = cls.template.id cls._cleanup = [] diff --git a/test/integration/smoke/test_backup_recovery_nas.py b/test/integration/smoke/test_backup_recovery_nas.py index ccee60a3806e..31169e188739 100644 --- a/test/integration/smoke/test_backup_recovery_nas.py +++ b/test/integration/smoke/test_backup_recovery_nas.py @@ -21,7 +21,7 @@ from marvin.lib.utils import (cleanup_resources) from marvin.lib.base import (Account, Network, ServiceOffering, DiskOffering, VirtualMachine, BackupOffering, NetworkOffering, BackupRepository, Backup, Configurations, Volume, StoragePool) -from marvin.lib.common import (get_domain, get_zone, get_suitable_test_template) +from marvin.lib.common import (get_template, get_domain, get_zone) from nose.plugins.attrib import attr from marvin.codes import FAILED import time @@ -39,9 +39,9 @@ def setUpClass(cls): cls.services["mode"] = cls.zone.networktype cls.hypervisor = cls.testClient.getHypervisorInfo() cls.domain = get_domain(cls.api_client) - cls.template = get_suitable_test_template(cls.api_client, cls.zone.id, cls.services["ostype"]) + cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) if cls.template == FAILED: - assert False, "get_suitable_test_template() failed to return template with description %s" % cls.services["ostype"] + assert False, "get_template() failed to return template with description %s" % cls.services["ostype"] cls.services["small"]["zoneid"] = cls.zone.id cls.services["small"]["template"] = cls.template.id cls._cleanup = [] @@ -245,7 +245,7 @@ def test_vm_backup_create_vm_from_backup_in_another_zone(self): return self.destZone = zones[1] - template = get_suitable_test_template(self.api_client, self.destZone.id, self.services["ostype"]) + template = get_template(self.api_client, self.destZone.id, self.services["ostype"]) list_isolated_network_offerings_response = NetworkOffering.list( self.apiclient, diff --git a/test/integration/smoke/test_primary_storage.py b/test/integration/smoke/test_primary_storage.py index 477d3317ad69..569335e7e77e 100644 --- a/test/integration/smoke/test_primary_storage.py +++ b/test/integration/smoke/test_primary_storage.py @@ -42,14 +42,9 @@ def setUp(self): self.pod = get_pod(self.apiclient, self.zone.id) self.hypervisor = self.testClient.getHypervisorInfo() self.domain = get_domain(self.apiclient) - self.template = get_suitable_test_template( - self.apiclient, - self.zone.id, - self.services["ostype"], - self.hypervisor - ) + self.template = get_template(self.apiclient, self.zone.id, self.services["ostype"]) if self.template == FAILED: - assert False, "get_suitable_test_template() failed to return template with description %s" % self.services["ostype"] + assert False, "get_template() failed to return template with description %s" % self.services["ostype"] self.excluded_pools = [] storage_pool_list = StoragePool.list(self.apiclient, zoneid=self.zone.id) @@ -392,14 +387,9 @@ def setUpClass(cls): cls.pod = get_pod(cls.apiclient, cls.zone.id) cls.hypervisor = testClient.getHypervisorInfo() cls.domain = get_domain(cls.apiclient) - cls.template = get_suitable_test_template( - cls.apiclient, - cls.zone.id, - cls.services["ostype"], - cls.hypervisor - ) + cls.template = get_template(cls.apiclient, cls.zone.id, cls.services["ostype"]) if cls.template == FAILED: - assert False, "get_suitable_test_template() failed to return template with description %s" % cls.services["ostype"] + assert False, "get_template() failed to return template with description %s" % cls.services["ostype"] cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.services["storage_tags"] = StorageTagsServices().storage_tags diff --git a/test/integration/smoke/test_vm_autoscaling.py b/test/integration/smoke/test_vm_autoscaling.py index dd507ece0391..1b41e8b3b3b4 100644 --- a/test/integration/smoke/test_vm_autoscaling.py +++ b/test/integration/smoke/test_vm_autoscaling.py @@ -220,11 +220,14 @@ def setUpClass(cls): cls.templateUserdata = UserData.register( cls.apiclient, name="TemplateUserdata", - userdata="IyMgdGVtcGxhdGU6IGppbmphCiNjbG91ZC1jb25maWcKcnVuY21kOgogICAgLSBlY2hvICdrZXkge3sgZHMubWV0YV9kYXRhLmtleTEgfX0nID4+IC9yb290L2luc3RhbmNlX21ldGFkYXRhCgo=", + userdata="IyMgdGVtcGxhdGU6IGppbmphCiNjbG91ZC1jb25maWcKcnVuY21kOgogICAgLSBlY2hvICdrZXkge3sgZHMubWV0YV9kYXRhLmtleTEgfX0nID4+IC9yb290L2luc3RhbmNlX21ldGFkYXRhCiAgICAtIG5vaHVwIHNoIC1jICd3aGlsZSB0cnVlOyBkbyA6OyBkb25lJyA+IC9kZXYvbnVsbCAyPiYxICYKCg==", # ## template: jinja # #cloud-config # runcmd: # - echo 'key {{ ds.meta_data.key1 }}' >> /root/instance_metadata + # - nohup sh -c 'while true; do :; done' > /dev/null 2>&1 & + # (the CPU loop keeps the VM above the 1 percent CPU threshold of the scale up condition, + # an idle Debian 13 VM only uses about 0.4 percent) # account=cls.regular_user.name, domainid=cls.regular_user.domainid diff --git a/test/integration/smoke/test_volumes.py b/test/integration/smoke/test_volumes.py index ad1c359c27b5..441f10c2c034 100644 --- a/test/integration/smoke/test_volumes.py +++ b/test/integration/smoke/test_volumes.py @@ -38,8 +38,7 @@ Host, DiskOffering, StoragePool) -from marvin.lib.common import (get_domain, - get_suitable_test_template, +from marvin.lib.common import (get_template, get_domain, get_zone, find_storage_pool_type, get_pod, @@ -94,14 +93,9 @@ def setUpClass(cls): ) cls._cleanup.append(cls.custom_disk_offering) - template = get_suitable_test_template( - cls.apiclient, - cls.zone.id, - cls.services["ostype"], - cls.hypervisor - ) + template = get_template(cls.apiclient, cls.zone.id, cls.services["ostype"]) if template == FAILED: - assert False, "get_suitable_test_template() failed to return template with description %s" % cls.services["ostype"] + assert False, "get_template() failed to return template with description %s" % cls.services["ostype"] cls.services["domainid"] = cls.domain.id cls.services["zoneid"] = cls.zone.id @@ -115,9 +109,10 @@ def setUpClass(cls): domainid=cls.domain.id ) cls._cleanup.append(cls.account) + # the Debian 13 built-in template does not boot with the 128 MiB of the tiny offering cls.service_offering = ServiceOffering.create( cls.apiclient, - cls.services["service_offerings"]["tiny"] + cls.services["service_offerings"]["big"] ) cls.virtual_machine = VirtualMachine.create( cls.apiclient, @@ -307,15 +302,9 @@ def setUpClass(cls): ) cls._cleanup.append(cls.custom_resized_disk_offering) - cls.template = get_suitable_test_template( - cls.apiclient, - cls.zone.id, - cls.services["ostype"], - cls.hypervisor, - deploy_as_is=cls.hypervisor.lower() == "vmware" - ) + cls.template = get_template(cls.apiclient, cls.zone.id, cls.services["ostype"]) if cls.template == FAILED: - assert False, "get_suitable_test_template() failed to return template with description %s" % cls.services["ostype"] + assert False, "get_template() failed to return template with description %s" % cls.services["ostype"] cls.services["domainid"] = cls.domain.id cls.services["zoneid"] = cls.zone.id @@ -331,9 +320,10 @@ def setUpClass(cls): domainid=cls.domain.id ) cls._cleanup.append(cls.account) + # the Debian 13 built-in template does not boot with the 128 MiB of the tiny offering cls.service_offering = ServiceOffering.create( cls.apiclient, - cls.services["service_offerings"]["tiny"] + cls.services["service_offerings"]["big"] ) cls._cleanup.append(cls.service_offering) cls.virtual_machine = VirtualMachine.create( @@ -1121,14 +1111,9 @@ def setUpClass(cls): cls.services["zoneid"] = cls.zone.id # Get template - template = get_suitable_test_template( - cls.apiclient, - cls.zone.id, - cls.services["ostype"], - cls.hypervisor - ) + template = get_template(cls.apiclient, cls.zone.id, cls.services["ostype"]) if template == FAILED: - assert False, "get_suitable_test_template() failed to return template with description %s" % cls.services["ostype"] + assert False, "get_template() failed to return template with description %s" % cls.services["ostype"] cls.services["template"] = template.id cls.services["diskname"] = cls.services["volume"]["diskname"] @@ -1146,14 +1131,14 @@ def setUpClass(cls): # Create Service Offering cls.service_offering = ServiceOffering.create( cls.apiclient, - cls.services["service_offerings"]["small"] + cls.services["service_offerings"]["big"] ) cls._cleanup.append(cls.service_offering) # Create Service Offering with encryptRoot true cls.service_offering_encrypt = ServiceOffering.create( cls.apiclient, - cls.services["service_offerings"]["small"], + cls.services["service_offerings"]["big"], name="Small Encrypted Instance", encryptroot=True ) From 54d8e6e316b8efbcb8183f883b289ce8d6c4fa6e Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 22 Oct 2026 11:14:30 +0200 Subject: [PATCH 19/64] templates.sql: update the SHA-512 checksums of the Debian 13 built-in templates The images were rebuilt with the nfs-common package installed. The URLs are unchanged, so the KVM, XenServer and VMware templates get the checksums of the new files. --- setup/db/templates.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup/db/templates.sql b/setup/db/templates.sql index f4a65e1461a7..e2ba6cc7625e 100755 --- a/setup/db/templates.sql +++ b/setup/db/templates.sql @@ -34,16 +34,16 @@ INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, VALUES (2, UUID(), 'centos53-x86_64', 'CentOS 5.3(64-bit) no GUI (XenServer)', 1, now(), now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/templates/builtin/f59f18fb-ae94-4f97-afd2-f84755767aca.vhd.bz2', 'b63d854a9560c013142567bbae8d98cf', 0, 'CentOS 5.3(64-bit) no GUI (XenServer)', 'VHD', 12, 1, 1, 'XenServer', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, display_text, enable_password, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (4, UUID(), 'debian13-x86_64-kvm', 'Debian 13 (64-bit) no GUI (KVM)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261017-2634-acs.qcow2', '{SHA-512}38389fb9e29448e6d7da460c0342217bd1a8aa6e32e6192fa1c6dbc6f7078f6c8210dde110d8631cc823b2762fb1738f8ae94b3e5a3774cf30a0cf11af69dfb8', 'Debian 13 (64-bit) no GUI (KVM)', 0, 'QCOW2', 184, 1, 1, 'KVM', 1); + VALUES (4, UUID(), 'debian13-x86_64-kvm', 'Debian 13 (64-bit) no GUI (KVM)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261017-2634-acs.qcow2', '{SHA-512}b2e89ab21b6c11f183178da2cb1a04c89cb6b4c43e0968503d050710b4eb37426f78d71b4a503b282bca8c6ddd680a84f2ed9992752ef20d4288b7487d7c228b', 'Debian 13 (64-bit) no GUI (KVM)', 0, 'QCOW2', 184, 1, 1, 'KVM', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (5, UUID(), 'debian13-x86_64-xen', 'Debian 13 (64-bit) no GUI (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261017-2634-acs-xen.vhd.bz2', '{SHA-512}b2687bf7f739f49ed36b266e69d44ed49283b398497d85bda17f0eabc447934ba571629c01d94d8ac985f8133b218c8558cac22a88f78a3efd5f81bcf0689ab7', 0, 'Debian 13 (64-bit) no GUI (XenServer)', 'VHD', 184, 1, 1, 'XenServer', 1); + VALUES (5, UUID(), 'debian13-x86_64-xen', 'Debian 13 (64-bit) no GUI (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261017-2634-acs-xen.vhd.bz2', '{SHA-512}ba1805e0a4f73725cc463215020dc77c9501b121c112f3c8205c4bce4e40fe4fc75381018a4863dd9dce0a6d2fe5c47480793283aa1df88c2a0217dd44c2117f', 0, 'Debian 13 (64-bit) no GUI (XenServer)', 'VHD', 184, 1, 1, 'XenServer', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) VALUES (6, UUID(), 'centos64-x64', 'CentOS 6.4(64-bit) GUI (Hyperv)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.3/centos6_4_64bit.vhd.bz2', 'eef6b9940ea3ed01221d963d4a012d0a', 0, 'CentOS 6.4 (64-bit) GUI (Hyperv)', 'VHD', 182, 1, 1, 'Hyperv', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (7, UUID(), 'debian13-x86_64-vmware', 'Debian 13 (64-bit) no GUI (vSphere)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261017-2634-acs.ova', '{SHA-512}a090fafc53cbcf375937a8328500689543d9716a527f8a6059daee49712c56cc0e1553f386af8df1a650fa92819b235f4066df1076f242bf9a9e225f18a10b2b', 0, 'Debian 13 (64-bit) no GUI (vSphere)', 'OVA', 184, 1, 1, 'VMware', 1); + VALUES (7, UUID(), 'debian13-x86_64-vmware', 'Debian 13 (64-bit) no GUI (vSphere)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261017-2634-acs.ova', '{SHA-512}2e8f81e9ea62820cdf936a73d3c02e1a840a6b96f18163b1f4617fd48ccae792e08ef2b3ccf0be1c7c3d86dff65200b655b54a7468775806ca78c1adf50c9935', 0, 'Debian 13 (64-bit) no GUI (vSphere)', 'OVA', 184, 1, 1, 'VMware', 1); INSERT INTO `cloud`.`guest_os_category` (id, uuid, name) VALUES (1, UUID(), 'CentOS'); INSERT INTO `cloud`.`guest_os_category` (id, uuid, name) VALUES (2, UUID(), 'Debian'); From da04f2152d3cbc0f3e07c9b3a0c1077f6e295ddf Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 22 Oct 2026 11:44:04 +0200 Subject: [PATCH 20/64] templates.sql: use the 20261021-2638 Debian 13 images for the built-in templates The images are built from the Debian 13 genericcloud image of 20261021-2638 with the nfs-common package installed. Update the URLs and the SHA-512 checksums of the KVM, XenServer and VMware templates. --- setup/db/templates.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup/db/templates.sql b/setup/db/templates.sql index e2ba6cc7625e..8d7a613724e1 100755 --- a/setup/db/templates.sql +++ b/setup/db/templates.sql @@ -34,16 +34,16 @@ INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, VALUES (2, UUID(), 'centos53-x86_64', 'CentOS 5.3(64-bit) no GUI (XenServer)', 1, now(), now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/templates/builtin/f59f18fb-ae94-4f97-afd2-f84755767aca.vhd.bz2', 'b63d854a9560c013142567bbae8d98cf', 0, 'CentOS 5.3(64-bit) no GUI (XenServer)', 'VHD', 12, 1, 1, 'XenServer', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, display_text, enable_password, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (4, UUID(), 'debian13-x86_64-kvm', 'Debian 13 (64-bit) no GUI (KVM)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261017-2634-acs.qcow2', '{SHA-512}b2e89ab21b6c11f183178da2cb1a04c89cb6b4c43e0968503d050710b4eb37426f78d71b4a503b282bca8c6ddd680a84f2ed9992752ef20d4288b7487d7c228b', 'Debian 13 (64-bit) no GUI (KVM)', 0, 'QCOW2', 184, 1, 1, 'KVM', 1); + VALUES (4, UUID(), 'debian13-x86_64-kvm', 'Debian 13 (64-bit) no GUI (KVM)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261021-2638-acs.qcow2', '{SHA-512}732c2b760089386ac8017ed64568c2441923e0107b9b6262586096d5fcf78393b83b561d289a7eb3f008187c17258d0be53a42651040168fc11468197619adcc', 'Debian 13 (64-bit) no GUI (KVM)', 0, 'QCOW2', 184, 1, 1, 'KVM', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (5, UUID(), 'debian13-x86_64-xen', 'Debian 13 (64-bit) no GUI (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261017-2634-acs-xen.vhd.bz2', '{SHA-512}ba1805e0a4f73725cc463215020dc77c9501b121c112f3c8205c4bce4e40fe4fc75381018a4863dd9dce0a6d2fe5c47480793283aa1df88c2a0217dd44c2117f', 0, 'Debian 13 (64-bit) no GUI (XenServer)', 'VHD', 184, 1, 1, 'XenServer', 1); + VALUES (5, UUID(), 'debian13-x86_64-xen', 'Debian 13 (64-bit) no GUI (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261021-2638-acs-xen.vhd.bz2', '{SHA-512}454ad1a131f05bb50938ef1b4b28068181015c8afb492ad2e8f83d4cd2bf16cda55a142eae6f550ebb936a37a58b60bf7bd1e98ff965db338544db84f5fd85bd', 0, 'Debian 13 (64-bit) no GUI (XenServer)', 'VHD', 184, 1, 1, 'XenServer', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) VALUES (6, UUID(), 'centos64-x64', 'CentOS 6.4(64-bit) GUI (Hyperv)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.3/centos6_4_64bit.vhd.bz2', 'eef6b9940ea3ed01221d963d4a012d0a', 0, 'CentOS 6.4 (64-bit) GUI (Hyperv)', 'VHD', 182, 1, 1, 'Hyperv', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (7, UUID(), 'debian13-x86_64-vmware', 'Debian 13 (64-bit) no GUI (vSphere)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261017-2634-acs.ova', '{SHA-512}2e8f81e9ea62820cdf936a73d3c02e1a840a6b96f18163b1f4617fd48ccae792e08ef2b3ccf0be1c7c3d86dff65200b655b54a7468775806ca78c1adf50c9935', 0, 'Debian 13 (64-bit) no GUI (vSphere)', 'OVA', 184, 1, 1, 'VMware', 1); + VALUES (7, UUID(), 'debian13-x86_64-vmware', 'Debian 13 (64-bit) no GUI (vSphere)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261021-2638-acs.ova', '{SHA-512}d199ef7728c73b6f172429aacd7f5942737d8bde5742be8a8b0d01b9330621eb55c5a521251cbb44ef091023af02ece38d5b7120d81f6b7dbeac98f4e4ec94e0', 0, 'Debian 13 (64-bit) no GUI (vSphere)', 'OVA', 184, 1, 1, 'VMware', 1); INSERT INTO `cloud`.`guest_os_category` (id, uuid, name) VALUES (1, UUID(), 'CentOS'); INSERT INTO `cloud`.`guest_os_category` (id, uuid, name) VALUES (2, UUID(), 'Debian'); From 9ee704851027b77d9b84747d39f1c8960533a18f Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Fri, 23 Oct 2026 13:53:46 +0200 Subject: [PATCH 21/64] systemvm: enable cloud-init when the system VM starts it on Debian 13 The template build disables cloud-init with /etc/cloud/cloud-init.disabled. The units of cloud-init 25.1 (Debian 13) are skipped by systemd while that file exists, so start_cloud_init did nothing: the user data of the shared filesystem VM and the CKS nodes never ran, NFS was never started and the mount of the shared filesystem got 'Connection refused'. Remove the file (and the marker written by the generator at boot) and reload systemd so that the cloud-init generator runs again, and create the file again in stop_cloud_init. --- systemvm/debian/opt/cloud/bin/setup/common.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/systemvm/debian/opt/cloud/bin/setup/common.sh b/systemvm/debian/opt/cloud/bin/setup/common.sh index 1c19d23493cb..012a2a336c2c 100755 --- a/systemvm/debian/opt/cloud/bin/setup/common.sh +++ b/systemvm/debian/opt/cloud/bin/setup/common.sh @@ -700,9 +700,14 @@ setup_ntp() { fi } -# cloud-init 25.1 and later (Debian 13) does not have cloud-init.service anymore: cloud-init-main is +# cloud-init is disabled in the template with /etc/cloud/cloud-init.disabled, and the units of +# cloud-init 25.1 and later (Debian 13) are skipped by systemd while that file exists. The generator +# of cloud-init decides at boot, so it has to run again after the file is removed. +# cloud-init 25.1 and later also does not have cloud-init.service anymore: cloud-init-main is # a single process which runs all the stages, and the units of the stages hand over to it start_cloud_init() { + rm -f /etc/cloud/cloud-init.disabled /run/cloud-init/disabled + systemctl daemon-reload if systemctl cat cloud-init-main.service > /dev/null 2>&1; then systemctl start --no-block cloud-init-main cloud-init-local cloud-init-network cloud-config cloud-final else @@ -720,6 +725,7 @@ stop_cloud_init() { systemctl disable ${svc} fi done + touch /etc/cloud/cloud-init.disabled } routing_svcs() { From d823180f5e42f7deb796a156eb6a140a59fee27d Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Fri, 23 Oct 2026 14:22:29 +0200 Subject: [PATCH 22/64] test_backup_recovery_nas: sync the guest after writing the marker files The tests write a file in the guest and take a live backup a few seconds later. The backup is not quiesced, so a file that was not flushed yet can be missing from the backup. The guest root filesystem commits its journal about every 5 seconds, which is also the wait before the backup. Run sync after each touch, so that the file is on the disk before the backup starts. --- .../smoke/test_backup_recovery_nas.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/integration/smoke/test_backup_recovery_nas.py b/test/integration/smoke/test_backup_recovery_nas.py index 31169e188739..9240432c7b90 100644 --- a/test/integration/smoke/test_backup_recovery_nas.py +++ b/test/integration/smoke/test_backup_recovery_nas.py @@ -122,7 +122,7 @@ def vm_backup_create_vm_from_backup_int(self, templateid=None, networkids=None): # Create a file and take backup try: ssh_client_vm = self.vm.get_ssh_client(reconnect=True) - ssh_client_vm.execute("touch test_backup_and_recovery.txt") + ssh_client_vm.execute("touch test_backup_and_recovery.txt; sync") except Exception as err: self.fail("SSH failed for Virtual machine: %s due to %s" % (self.vm.ipaddress, err)) @@ -314,7 +314,7 @@ def test_incremental_chain_cadence(self): self._set_full_every(3) try: ssh_client_vm = self.vm.get_ssh_client(reconnect=True) - ssh_client_vm.execute("touch /root/incremental_marker_1.txt") + ssh_client_vm.execute("touch /root/incremental_marker_1.txt; sync") created = [] for i in range(5): @@ -435,15 +435,15 @@ def test_restore_from_incremental(self): self._set_full_every(5) try: ssh_client_vm = self.vm.get_ssh_client(reconnect=True) - ssh_client_vm.execute("touch /root/marker_full.txt") + ssh_client_vm.execute("touch /root/marker_full.txt; sync") Backup.create(self.apiclient, self.vm.id, "rfi_full") time.sleep(3) - ssh_client_vm.execute("touch /root/marker_inc1.txt") + ssh_client_vm.execute("touch /root/marker_inc1.txt; sync") Backup.create(self.apiclient, self.vm.id, "rfi_inc1") time.sleep(3) - ssh_client_vm.execute("touch /root/marker_inc2.txt") + ssh_client_vm.execute("touch /root/marker_inc2.txt; sync") Backup.create(self.apiclient, self.vm.id, "rfi_inc2") time.sleep(3) @@ -484,13 +484,13 @@ def test_delete_middle_incremental_repairs_chain(self): self._set_full_every(5) try: ssh_client_vm = self.vm.get_ssh_client(reconnect=True) - ssh_client_vm.execute("touch /root/dmi_full.txt") + ssh_client_vm.execute("touch /root/dmi_full.txt; sync") Backup.create(self.apiclient, self.vm.id, "dmi_full") time.sleep(3) - ssh_client_vm.execute("touch /root/dmi_inc1.txt") + ssh_client_vm.execute("touch /root/dmi_inc1.txt; sync") Backup.create(self.apiclient, self.vm.id, "dmi_inc1") time.sleep(3) - ssh_client_vm.execute("touch /root/dmi_inc2.txt") + ssh_client_vm.execute("touch /root/dmi_inc2.txt; sync") Backup.create(self.apiclient, self.vm.id, "dmi_inc2") time.sleep(3) From 4d1618e3c3ca1e390548dfcad253b362f4513862 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Fri, 23 Oct 2026 21:02:05 +0200 Subject: [PATCH 23/64] systemvmtemplate: install isc-dhcp-client on Debian 13 The setup scripts of the CKS nodes and the shared filesystem VMs call dhclient, and the shared filesystem VM starts cloud-dhclient@eth0.service which runs /usr/sbin/dhclient. Debian 13 does not install isc-dhcp-client by default, so the commands fail: - the DHCP options (DNS server of the virtual router, domain) are not applied, /etc/resolv.conf keeps the static name servers of the zone, and cloud-init cannot resolve data-server to find the metadata server, so the user data is not applied - cloud-dhclient@eth0.service fails with status 203/EXEC Install isc-dhcp-client, like it was available in the Debian 12 template. --- .../systemvmtemplate/scripts/install_systemvm_packages.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/appliance/systemvmtemplate/scripts/install_systemvm_packages.sh b/tools/appliance/systemvmtemplate/scripts/install_systemvm_packages.sh index 00ab7e194a33..e7cb4cc5e764 100755 --- a/tools/appliance/systemvmtemplate/scripts/install_systemvm_packages.sh +++ b/tools/appliance/systemvmtemplate/scripts/install_systemvm_packages.sh @@ -74,6 +74,7 @@ function install_packages() { haveged \ radvd \ frr \ + isc-dhcp-client \ sharutils genisoimage \ strongswan libcharon-extra-plugins libstrongswan-extra-plugins strongswan-charon strongswan-starter \ virt-what open-vm-tools qemu-guest-agent hyperv-daemons cloud-guest-utils \ From 34f800f28ed15ddb19ebfffcda57e544eed7c2d3 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Sat, 24 Oct 2026 17:15:11 +0200 Subject: [PATCH 24/64] systemvmtemplate: prefer dhclient to dhcpcd in the cloud-init configuration cloud-init of Debian 13 tries dhcpcd first to get the DHCP lease, and dhcpcd is not running in the system VMs. The lookup of the lease fails with NoDHCPLeaseError, the init stage fails and the user data of the CKS nodes and the shared filesystem VMs is not applied. Set network.dhcp_client_priority to dhclient first in the cloud-init configuration of the template. dhclient is installed in the template since isc-dhcp-client is part of the system VM packages. --- .../systemvmtemplate/scripts/configure_systemvm_services.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh b/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh index 455e59915f87..78c7dc3081ff 100755 --- a/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh +++ b/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh @@ -139,6 +139,11 @@ datasource: CloudStack: max_wait: 120 timeout: 50 +# cloud-init of Debian 13 asks dhcpcd for the DHCP lease by default, which is not running in the +# system VMs. Prefer dhclient, installed in the template, otherwise no datasource is found +system_info: + network: + dhcp_client_priority: [dhclient, dhcpcd, udhcpc] EOF touch /etc/cloud/cloud-init.disabled From 7eee672aa5bce4dcc482c33b08667991eaf48107 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Sat, 24 Oct 2026 17:31:02 +0200 Subject: [PATCH 25/64] systemvmtemplate: add the cloud-init settings of the CKS nodes to the template The setup scripts of the CKS nodes and the shared filesystem VMs enable cloud-init without ds-identify and add ConfigDrive to the datasource list when the VM starts. Put the same settings in the cloud-init configuration of the template: - policy: enabled in /etc/cloud/ds-identify.cfg - ConfigDrive and CloudStack in datasource_list cloud-init stays disabled by default with /etc/cloud/cloud-init.disabled, and is enabled by the setup scripts of the VMs which need it. --- .../systemvmtemplate/scripts/configure_systemvm_services.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh b/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh index 78c7dc3081ff..98ec400b4160 100755 --- a/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh +++ b/tools/appliance/systemvmtemplate/scripts/configure_systemvm_services.sh @@ -134,7 +134,7 @@ function configure_services() { # Disable cloud init by default cat < /etc/cloud/cloud.cfg.d/cloudstack.cfg -datasource_list: ['CloudStack'] +datasource_list: ['ConfigDrive', 'CloudStack'] datasource: CloudStack: max_wait: 120 @@ -146,6 +146,9 @@ system_info: dhcp_client_priority: [dhclient, dhcpcd, udhcpc] EOF + # Enable cloud-init without any aid from ds-identify, when it is started by the setup scripts + echo "policy: enabled" > /etc/cloud/ds-identify.cfg + touch /etc/cloud/cloud-init.disabled # cloud-init.service was split into several units in newer cloud-init versions for svc in cloud-init cloud-init-local cloud-init-main cloud-init-network cloud-config cloud-final; do From 4d0d651e9b88326673ecbb0029673994962e17f5 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 26 Oct 2026 09:09:47 +0100 Subject: [PATCH 26/64] build-acs-image.sh: add the Apache license header The usage text is printed from the header comment, so the line range it prints is moved down by the length of the license. --- scripts/util/build-acs-image.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/scripts/util/build-acs-image.sh b/scripts/util/build-acs-image.sh index 15ad42d03d5b..06ce920abcd5 100755 --- a/scripts/util/build-acs-image.sh +++ b/scripts/util/build-acs-image.sh @@ -1,4 +1,21 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # Prepare a generic cloud qcow2 image for CloudStack: patch it, shrink it and convert it to VHD/OVA. # # Usage: build-acs-image.sh [-a ACTIONS] [-f FORMATS] [-o OUTDIR] [-g GUESTOS] [-u] [-z] @@ -31,7 +48,7 @@ # checked first, and nothing is installed. set -euo pipefail -usage() { sed -n '2,29p' "$0"; exit 1; } +usage() { sed -n '19,46p' "$0"; exit 1; } ACTIONS="all" FORMATS="all" From fccbcbb236029845e423f83dbb0206e21accb6bb Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 26 Oct 2026 09:09:54 +0100 Subject: [PATCH 27/64] templates.sql: download the Debian 13 built-in templates from download.cloudstack.org The images are the same 20261021-2638 files with the same checksums, now served from download.cloudstack.org instead of the build server. --- setup/db/templates.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup/db/templates.sql b/setup/db/templates.sql index 8d7a613724e1..8b60d9cf3607 100755 --- a/setup/db/templates.sql +++ b/setup/db/templates.sql @@ -34,16 +34,16 @@ INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, VALUES (2, UUID(), 'centos53-x86_64', 'CentOS 5.3(64-bit) no GUI (XenServer)', 1, now(), now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/templates/builtin/f59f18fb-ae94-4f97-afd2-f84755767aca.vhd.bz2', 'b63d854a9560c013142567bbae8d98cf', 0, 'CentOS 5.3(64-bit) no GUI (XenServer)', 'VHD', 12, 1, 1, 'XenServer', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, display_text, enable_password, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (4, UUID(), 'debian13-x86_64-kvm', 'Debian 13 (64-bit) no GUI (KVM)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261021-2638-acs.qcow2', '{SHA-512}732c2b760089386ac8017ed64568c2441923e0107b9b6262586096d5fcf78393b83b561d289a7eb3f008187c17258d0be53a42651040168fc11468197619adcc', 'Debian 13 (64-bit) no GUI (KVM)', 0, 'QCOW2', 184, 1, 1, 'KVM', 1); + VALUES (4, UUID(), 'debian13-x86_64-kvm', 'Debian 13 (64-bit) genericcloud (KVM)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261021-2638-acs.qcow2', '{SHA-512}732c2b760089386ac8017ed64568c2441923e0107b9b6262586096d5fcf78393b83b561d289a7eb3f008187c17258d0be53a42651040168fc11468197619adcc', 'Debian 13 (64-bit) genericcloud (KVM)', 0, 'QCOW2', 184, 1, 1, 'KVM', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (5, UUID(), 'debian13-x86_64-xen', 'Debian 13 (64-bit) no GUI (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261021-2638-acs-xen.vhd.bz2', '{SHA-512}454ad1a131f05bb50938ef1b4b28068181015c8afb492ad2e8f83d4cd2bf16cda55a142eae6f550ebb936a37a58b60bf7bd1e98ff965db338544db84f5fd85bd', 0, 'Debian 13 (64-bit) no GUI (XenServer)', 'VHD', 184, 1, 1, 'XenServer', 1); + VALUES (5, UUID(), 'debian13-x86_64-xen', 'Debian 13 (64-bit) genericcloud (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261021-2638-acs-xen.vhd.bz2', '{SHA-512}454ad1a131f05bb50938ef1b4b28068181015c8afb492ad2e8f83d4cd2bf16cda55a142eae6f550ebb936a37a58b60bf7bd1e98ff965db338544db84f5fd85bd', 0, 'Debian 13 (64-bit) genericcloud (XenServer)', 'VHD', 184, 1, 1, 'XenServer', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) VALUES (6, UUID(), 'centos64-x64', 'CentOS 6.4(64-bit) GUI (Hyperv)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.3/centos6_4_64bit.vhd.bz2', 'eef6b9940ea3ed01221d963d4a012d0a', 0, 'CentOS 6.4 (64-bit) GUI (Hyperv)', 'VHD', 182, 1, 1, 'Hyperv', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (7, UUID(), 'debian13-x86_64-vmware', 'Debian 13 (64-bit) no GUI (vSphere)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261021-2638-acs.ova', '{SHA-512}d199ef7728c73b6f172429aacd7f5942737d8bde5742be8a8b0d01b9330621eb55c5a521251cbb44ef091023af02ece38d5b7120d81f6b7dbeac98f4e4ec94e0', 0, 'Debian 13 (64-bit) no GUI (vSphere)', 'OVA', 184, 1, 1, 'VMware', 1); + VALUES (7, UUID(), 'debian13-x86_64-vmware', 'Debian 13 (64-bit) genericcloud (vSphere)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261021-2638-acs.ova', '{SHA-512}d199ef7728c73b6f172429aacd7f5942737d8bde5742be8a8b0d01b9330621eb55c5a521251cbb44ef091023af02ece38d5b7120d81f6b7dbeac98f4e4ec94e0', 0, 'Debian 13 (64-bit) genericcloud (vSphere)', 'OVA', 184, 1, 1, 'VMware', 1); INSERT INTO `cloud`.`guest_os_category` (id, uuid, name) VALUES (1, UUID(), 'CentOS'); INSERT INTO `cloud`.`guest_os_category` (id, uuid, name) VALUES (2, UUID(), 'Debian'); From a005111ef9cc37b781611daaa49a99b10e3cf7da Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 26 Oct 2026 09:10:43 +0100 Subject: [PATCH 28/64] Keep the template install path when a download fails without one An error answer, like the timeout when the secondary storage VM disconnects during a download, has no install path. The download callback wrote it to the template_store_ref entry anyway, so the install path became null and the next download of the template went to a directory named "null". Only update the install path when the answer has one. --- .../image/BaseImageStoreDriverImpl.java | 7 +- .../image/BaseImageStoreDriverImplTest.java | 123 ++++++++++++++++++ 2 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 engine/storage/src/test/java/org/apache/cloudstack/storage/image/BaseImageStoreDriverImplTest.java diff --git a/engine/storage/src/main/java/org/apache/cloudstack/storage/image/BaseImageStoreDriverImpl.java b/engine/storage/src/main/java/org/apache/cloudstack/storage/image/BaseImageStoreDriverImpl.java index 26b39e30776f..d3c4750de07c 100644 --- a/engine/storage/src/main/java/org/apache/cloudstack/storage/image/BaseImageStoreDriverImpl.java +++ b/engine/storage/src/main/java/org/apache/cloudstack/storage/image/BaseImageStoreDriverImpl.java @@ -52,6 +52,7 @@ import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO; import org.apache.cloudstack.storage.endpoint.DefaultEndPointSelector; import org.apache.cloudstack.storage.image.deployasis.DeployAsIsHelper; +import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; @@ -229,7 +230,11 @@ protected Void createTemplateAsyncCallback(AsyncCallbackDispatcher parentCallback; + @Mock + private AsyncCallbackDispatcher callback; + @Mock + private TemplateDataStoreVO existingRef; + @Mock + private VMTemplateZoneVO templateZone; + + private BaseImageStoreDriverImpl driver; + private TemplateDataStoreVO updateBuilder; + + @Before + public void setUp() { + driver = Mockito.mock(BaseImageStoreDriverImpl.class, Mockito.CALLS_REAL_METHODS); + ReflectionTestUtils.setField(driver, "logger", org.apache.logging.log4j.LogManager.getLogger(BaseImageStoreDriverImpl.class)); + ReflectionTestUtils.setField(driver, "_templateDao", templateDao); + ReflectionTestUtils.setField(driver, "_templateStoreDao", templateStoreDao); + ReflectionTestUtils.setField(driver, "_vmTemplateZoneDao", vmTemplateZoneDao); + ReflectionTestUtils.setField(driver, "_alertMgr", alertManager); + + Mockito.when(data.getId()).thenReturn(7L); + Mockito.when(data.getDataStore()).thenReturn(store); + Mockito.when(store.getId()).thenReturn(1L); + Mockito.when(templateDao.findById(7L)).thenReturn(Mockito.mock(VMTemplateVO.class)); + Mockito.when(templateDao.createForUpdate()).thenReturn(Mockito.mock(VMTemplateVO.class)); + Mockito.when(existingRef.getId()).thenReturn(3L); + Mockito.when(existingRef.getDownloadState()).thenReturn(Status.DOWNLOAD_IN_PROGRESS); + Mockito.when(templateStoreDao.findByStoreTemplate(1L, 7L)).thenReturn(existingRef); + updateBuilder = Mockito.mock(TemplateDataStoreVO.class); + Mockito.when(templateStoreDao.createForUpdate()).thenReturn(updateBuilder); + Mockito.when(templateZone.getZoneId()).thenReturn(2L); + Mockito.when(vmTemplateZoneDao.listByTemplateId(7L)).thenReturn(Collections.singletonList(templateZone)); + } + + private void callWith(DownloadAnswer answer) { + Mockito.when(callback.getResult()).thenReturn(answer); + BaseImageStoreDriverImpl.CreateContext context = driver.new CreateContext<>(parentCallback, data); + driver.createTemplateAsyncCallback(callback, context); + } + + @Test + public void testErrorAnswerWithoutInstallPathKeepsInstallPath() { + DownloadAnswer answer = new DownloadAnswer("Timeout waiting for response from storage host", Status.DOWNLOAD_ERROR); + + callWith(answer); + + Mockito.verify(updateBuilder, Mockito.never()).setInstallPath(Mockito.any()); + Mockito.verify(updateBuilder).setDownloadState(Status.DOWNLOAD_ERROR); + Mockito.verify(templateStoreDao).update(3L, updateBuilder); + } + + @Test + public void testAnswerWithInstallPathSetsInstallPath() { + DownloadAnswer answer = new DownloadAnswer("job", 100, null, Status.DOWNLOADED, "/dl/path", "template/tmpl/2/7", 10L, 10L, "checksum"); + + callWith(answer); + + Mockito.verify(updateBuilder).setInstallPath("template/tmpl/2/7"); + Mockito.verify(templateStoreDao).update(3L, updateBuilder); + } +} From 2a518d7eea994b751bf8efe0196fa72f8894d1d8 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 26 Oct 2026 10:03:55 +0100 Subject: [PATCH 29/64] schema: deploy the built-in Debian 13 VMware template as is Set deploy_as_is on the built-in Debian 13 VMware template in the 4.23.0.0 to 24.0.0 upgrade, so that VMs take the NIC and disk controller of the OVA (vmxnet3, pvscsi). Without it CloudStack uses an e1000 NIC, which the Debian cloud kernel has no driver for, and the VM gets no network. --- .../src/main/resources/META-INF/db/schema-42300to2400.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql b/engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql index 1ff71f4e0eb1..5e68bb8bb813 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql @@ -234,3 +234,6 @@ UPDATE `cloud`.`vm_template` SET `guest_os_id` = (SELECT `id` FROM `cloud`.`gues WHERE `id` = 5 AND `unique_name` = 'debian13-x86_64-xen' AND `type` = 'BUILTIN'; UPDATE `cloud`.`vm_template` SET `guest_os_id` = (SELECT `id` FROM `cloud`.`guest_os` WHERE `display_name` = 'Debian GNU/Linux 12 (64-bit)' AND `removed` IS NULL LIMIT 1) WHERE `id` = 7 AND `unique_name` = 'debian13-x86_64-vmware' AND `type` = 'BUILTIN'; + +-- Deploy the built-in Debian 13 VMware template as is, with the NIC and disk controller of the OVA (vmxnet3, pvscsi). +UPDATE `cloud`.`vm_template` SET `deploy_as_is` = 1 WHERE `id` = 7 AND `unique_name` = 'debian13-x86_64-vmware' AND `type` = 'BUILTIN'; From fc518e0539308cb302957f3b01b9c7a81268d284 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 26 Oct 2026 17:38:52 +0100 Subject: [PATCH 30/64] build-acs-image.sh: do not force PasswordAuthentication in sshd The sshd drop-in only sets PermitRootLogin yes now, and it is named 40-root-login.conf. PasswordAuthentication is left to the default of the image instead of being forced to yes. --- scripts/util/build-acs-image.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/util/build-acs-image.sh b/scripts/util/build-acs-image.sh index 06ce920abcd5..e12d7891fb2d 100755 --- a/scripts/util/build-acs-image.sh +++ b/scripts/util/build-acs-image.sh @@ -376,11 +376,11 @@ datasource: None: {} EOF # sshd uses the first value it reads, so 40- loads before cloud-init's 50-cloud-init.conf - printf 'PermitRootLogin yes\nPasswordAuthentication yes\n' > "$tmp/40-password-login.conf" + printf 'PermitRootLogin yes\n' > "$tmp/40-root-login.conf" # the drop-in only works if sshd_config includes sshd_config.d (not in EL8, Ubuntu 20.04, ...); # otherwise put the settings at the top of sshd_config, as the first value wins - local sshd_fix='f=/etc/ssh/sshd_config; d=/etc/ssh/sshd_config.d/40-password-login.conf; + local sshd_fix='f=/etc/ssh/sshd_config; d=/etc/ssh/sshd_config.d/40-root-login.conf; if [ -f "$f" ] && ! grep -qiE "^[[:space:]]*Include[[:space:]].*sshd_config\.d" "$f"; then { cat "$d"; cat "$f"; } > "$f.new" && cat "$f.new" > "$f" && rm -f "$f.new" fi' @@ -392,13 +392,13 @@ fi' --upload "$tmp/ds-identify.cfg:/etc/cloud/ds-identify.cfg" \ --upload "$tmp/cloudstack.cfg:/etc/cloud/cloud.cfg.d/cloudstack.cfg" \ --mkdir /etc/ssh/sshd_config.d \ - --upload "$tmp/40-password-login.conf:/etc/ssh/sshd_config.d/40-password-login.conf" \ + --upload "$tmp/40-root-login.conf:/etc/ssh/sshd_config.d/40-root-login.conf" \ --run-command "$sshd_fix" \ --run-command "$CLEANUP" rm -rf "$tmp" echo "--- verification ---" - virt-cat -a "$WORK_IMAGE" /etc/cloud/ds-identify.cfg /etc/cloud/cloud.cfg.d/cloudstack.cfg /etc/ssh/sshd_config.d/40-password-login.conf + virt-cat -a "$WORK_IMAGE" /etc/cloud/ds-identify.cfg /etc/cloud/cloud.cfg.d/cloudstack.cfg /etc/ssh/sshd_config.d/40-root-login.conf local d for d in /usr/sbin /usr/bin; do virt-ls -a "$WORK_IMAGE" $d | grep -E '^(qemu-ga|vmtoolsd|xenstore)' | sed "s#^#$d/#" || true From 4596ad425f0d8b89be0deeca3e26a935a17d5fa5 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 26 Oct 2026 21:05:12 +0100 Subject: [PATCH 31/64] schema: set the NIC and disk controller of the built-in Debian 13 VMware template The guest kernel has no driver for the default e1000 NIC, so set the nicAdapter (Vmxnet3) and rootDiskController (pvscsi) details of the template instead of deploying it as is, which would prevent resizing the root disk. --- .../main/resources/META-INF/db/schema-42300to2400.sql | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql b/engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql index 5e68bb8bb813..efbf480f2966 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql @@ -235,5 +235,12 @@ UPDATE `cloud`.`vm_template` SET `guest_os_id` = (SELECT `id` FROM `cloud`.`gues UPDATE `cloud`.`vm_template` SET `guest_os_id` = (SELECT `id` FROM `cloud`.`guest_os` WHERE `display_name` = 'Debian GNU/Linux 12 (64-bit)' AND `removed` IS NULL LIMIT 1) WHERE `id` = 7 AND `unique_name` = 'debian13-x86_64-vmware' AND `type` = 'BUILTIN'; --- Deploy the built-in Debian 13 VMware template as is, with the NIC and disk controller of the OVA (vmxnet3, pvscsi). -UPDATE `cloud`.`vm_template` SET `deploy_as_is` = 1 WHERE `id` = 7 AND `unique_name` = 'debian13-x86_64-vmware' AND `type` = 'BUILTIN'; +-- Use the NIC and disk controller of the built-in Debian 13 VMware template image (vmxnet3, pvscsi), as the guest kernel has no driver for the default e1000 NIC +INSERT INTO `cloud`.`vm_template_details` (`template_id`, `name`, `value`) + SELECT `id`, 'nicAdapter', 'Vmxnet3' FROM `cloud`.`vm_template` + WHERE `id` = 7 AND `unique_name` = 'debian13-x86_64-vmware' AND `type` = 'BUILTIN' + AND NOT EXISTS (SELECT 1 FROM `cloud`.`vm_template_details` WHERE `template_id` = 7 AND `name` = 'nicAdapter'); +INSERT INTO `cloud`.`vm_template_details` (`template_id`, `name`, `value`) + SELECT `id`, 'rootDiskController', 'pvscsi' FROM `cloud`.`vm_template` + WHERE `id` = 7 AND `unique_name` = 'debian13-x86_64-vmware' AND `type` = 'BUILTIN' + AND NOT EXISTS (SELECT 1 FROM `cloud`.`vm_template_details` WHERE `template_id` = 7 AND `name` = 'rootDiskController'); From fcaf053f1c21f077ac04ff070683892f9e8598e2 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 26 Oct 2026 21:05:54 +0100 Subject: [PATCH 32/64] marvin: allow ssh login with password on the built-in template, use the tiny template on VMware VirtualMachine.create adds a cloud-init userdata to the VMs deployed from a built-in template, to allow ssh login with the root password, as the template disables it, so the tests can reach the VMs on any template. get_suitable_test_template returns the tiny template on VMware too, and test_update_security_group uses it. --- .../smoke/test_update_security_group.py | 4 ++-- tools/marvin/marvin/lib/base.py | 19 +++++++++++++++++++ tools/marvin/marvin/lib/common.py | 4 ++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/test/integration/smoke/test_update_security_group.py b/test/integration/smoke/test_update_security_group.py index 47fb01ba8115..eb9202f564ee 100644 --- a/test/integration/smoke/test_update_security_group.py +++ b/test/integration/smoke/test_update_security_group.py @@ -41,7 +41,7 @@ SecurityGroup) from marvin.lib.common import (get_domain, get_zone, - get_template, + get_suitable_test_template, list_virtual_machines, list_routers, list_hosts, @@ -63,7 +63,7 @@ def setUpClass(cls): zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests()) cls.zone = Zone(zone.__dict__) - cls.template = get_template(cls.apiclient, cls.zone.id) + cls.template = get_suitable_test_template(cls.apiclient, cls.zone.id) cls._cleanup = [] if str(cls.zone.securitygroupsenabled) != "True": diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py index b95a710db989..f57d746c6370 100755 --- a/tools/marvin/marvin/lib/base.py +++ b/tools/marvin/marvin/lib/base.py @@ -369,6 +369,13 @@ def login(cls, apiclient, username, password, domain=None, domainid=None): return apiclient.login(cmd) +# cloud-init userdata to allow ssh login with password (root/password) on the built-in templates +BUILTIN_TEMPLATE_USERDATA = """#cloud-config +ssh_pwauth: true +disable_root: false +""" + + class VirtualMachine: """Manage virtual machine lifecycle""" @@ -555,6 +562,15 @@ def program_ssh_access( raise Exception( "The following exception appeared while programming ssh access - %s" % e) + @classmethod + def is_builtin_template(cls, apiclient, templateid): + """Check if the template is a built-in template""" + cmd = listTemplates.listTemplatesCmd() + cmd.id = templateid + cmd.templatefilter = "all" + templates = apiclient.listTemplates(cmd) + return bool(templates and templates[0].templatetype == "BUILTIN") + @classmethod def create(cls, apiclient, services, templateid=None, accountid=None, domainid=None, zoneid=None, networkids=None, @@ -664,6 +680,9 @@ def create(cls, apiclient, services, templateid=None, accountid=None, if "userdata" in services: cmd.userdata = base64.urlsafe_b64encode(services["userdata"].encode()).decode() + elif userdataid is None and getattr(cmd, "templateid", None) and cls.is_builtin_template(apiclient, cmd.templateid): + # the built-in templates do not allow ssh login with password by default + cmd.userdata = base64.urlsafe_b64encode(BUILTIN_TEMPLATE_USERDATA.encode()).decode() if userdataid is not None: cmd.userdataid = userdataid diff --git a/tools/marvin/marvin/lib/common.py b/tools/marvin/marvin/lib/common.py index 5e574b742c1b..26a4b6af7902 100644 --- a/tools/marvin/marvin/lib/common.py +++ b/tools/marvin/marvin/lib/common.py @@ -521,7 +521,7 @@ def get_suitable_test_template(apiclient, zoneid=None, ostypeid=None, hypervisor ''' @Name : get_suitable_test_template @Desc : Retrieves the test template information based upon inputs provided - For XenServer and KVM, get_test_template is used for retrieving the + For XenServer, KVM and VMware, get_test_template is used for retrieving the shared public test template (tiny), which is registered by the admin only when it is missing. get_template is used for other hypervisors or when get_test_template fails @@ -533,7 +533,7 @@ def get_suitable_test_template(apiclient, zoneid=None, ostypeid=None, hypervisor template = FAILED if hypervisor is None: hypervisor = get_hypervisor_type(apiclient) - if hypervisor.lower() in ["xenserver", "kvm"] or (hypervisor.lower() in ["vmware"] and deploy_as_is): + if hypervisor.lower() in ["xenserver", "kvm", "vmware"]: template = get_test_template( apiclient, zoneid, From 2341262422b721975769c251cb6e76fc247a1d9b Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Tue, 27 Oct 2026 12:58:59 +0100 Subject: [PATCH 33/64] templates.sql: use the rebuilt Debian 13 built-in templates (20261026-2643) Download the images from 10.0.34.8 and update the checksums. --- setup/db/templates.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup/db/templates.sql b/setup/db/templates.sql index 8b60d9cf3607..e93f132ef98d 100755 --- a/setup/db/templates.sql +++ b/setup/db/templates.sql @@ -34,16 +34,16 @@ INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, VALUES (2, UUID(), 'centos53-x86_64', 'CentOS 5.3(64-bit) no GUI (XenServer)', 1, now(), now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/templates/builtin/f59f18fb-ae94-4f97-afd2-f84755767aca.vhd.bz2', 'b63d854a9560c013142567bbae8d98cf', 0, 'CentOS 5.3(64-bit) no GUI (XenServer)', 'VHD', 12, 1, 1, 'XenServer', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, display_text, enable_password, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (4, UUID(), 'debian13-x86_64-kvm', 'Debian 13 (64-bit) genericcloud (KVM)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261021-2638-acs.qcow2', '{SHA-512}732c2b760089386ac8017ed64568c2441923e0107b9b6262586096d5fcf78393b83b561d289a7eb3f008187c17258d0be53a42651040168fc11468197619adcc', 'Debian 13 (64-bit) genericcloud (KVM)', 0, 'QCOW2', 184, 1, 1, 'KVM', 1); + VALUES (4, UUID(), 'debian13-x86_64-kvm', 'Debian 13 (64-bit) genericcloud (KVM)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261026-2643-acs.qcow2', '{SHA-512}d9c8768e89fa6861e273932095b4f0199a8c9285af47a5428547b004ba28ce80ed9ae1ca4439bb4a3dc2634672fe06c0ccc7fa7e8d3113efc1762f58d8c9a870', 'Debian 13 (64-bit) genericcloud (KVM)', 0, 'QCOW2', 184, 1, 1, 'KVM', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (5, UUID(), 'debian13-x86_64-xen', 'Debian 13 (64-bit) genericcloud (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261021-2638-acs-xen.vhd.bz2', '{SHA-512}454ad1a131f05bb50938ef1b4b28068181015c8afb492ad2e8f83d4cd2bf16cda55a142eae6f550ebb936a37a58b60bf7bd1e98ff965db338544db84f5fd85bd', 0, 'Debian 13 (64-bit) genericcloud (XenServer)', 'VHD', 184, 1, 1, 'XenServer', 1); + VALUES (5, UUID(), 'debian13-x86_64-xen', 'Debian 13 (64-bit) genericcloud (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261026-2643-acs-xen.vhd.bz2', '{SHA-512}a4eed88cbcd9c98656179d2bf58077a35d92ab966c2aabde4f7e2bf6aabced051b3b0e98958f68d7393750d3b3a69d8b6abe8d97f324ae07fd21664e7dbb514e', 0, 'Debian 13 (64-bit) genericcloud (XenServer)', 'VHD', 184, 1, 1, 'XenServer', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) VALUES (6, UUID(), 'centos64-x64', 'CentOS 6.4(64-bit) GUI (Hyperv)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.3/centos6_4_64bit.vhd.bz2', 'eef6b9940ea3ed01221d963d4a012d0a', 0, 'CentOS 6.4 (64-bit) GUI (Hyperv)', 'VHD', 182, 1, 1, 'Hyperv', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (7, UUID(), 'debian13-x86_64-vmware', 'Debian 13 (64-bit) genericcloud (vSphere)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261021-2638-acs.ova', '{SHA-512}d199ef7728c73b6f172429aacd7f5942737d8bde5742be8a8b0d01b9330621eb55c5a521251cbb44ef091023af02ece38d5b7120d81f6b7dbeac98f4e4ec94e0', 0, 'Debian 13 (64-bit) genericcloud (vSphere)', 'OVA', 184, 1, 1, 'VMware', 1); + VALUES (7, UUID(), 'debian13-x86_64-vmware', 'Debian 13 (64-bit) genericcloud (vSphere)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261026-2643-acs.ova', '{SHA-512}0529980319d1d58037fc06bb82abf097003e2c2c332205be57755bf4c8152e86a3e178394c0ecc9b620b0f7679987881bc862230c56eaea5de0e58a2f4ad6f83', 0, 'Debian 13 (64-bit) genericcloud (vSphere)', 'OVA', 184, 1, 1, 'VMware', 1); INSERT INTO `cloud`.`guest_os_category` (id, uuid, name) VALUES (1, UUID(), 'CentOS'); INSERT INTO `cloud`.`guest_os_category` (id, uuid, name) VALUES (2, UUID(), 'Debian'); From 463db81da60d98937dbb137e11c9b359dd9185de Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Wed, 28 Oct 2026 08:53:09 +0100 Subject: [PATCH 34/64] systemvm: set the hostname without dbus if hostnamectl fails init.sh runs before dbus is started on a slow boot, e.g. on XenServer, so hostnamectl fails and the hostname stays 'systemvm'. The agent then registers the system VM with that name and its agent state is not shown. --- systemvm/debian/opt/cloud/bin/setup/common.sh | 2 +- systemvm/debian/opt/cloud/bin/setup/vpcrouter.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/systemvm/debian/opt/cloud/bin/setup/common.sh b/systemvm/debian/opt/cloud/bin/setup/common.sh index 012a2a336c2c..1c5fbf83ac21 100755 --- a/systemvm/debian/opt/cloud/bin/setup/common.sh +++ b/systemvm/debian/opt/cloud/bin/setup/common.sh @@ -338,7 +338,7 @@ setup_common() { echo $NAME > /etc/hostname echo 'AVAHI_DAEMON_DETECT_LOCAL=0' > /etc/default/avahi-daemon - hostnamectl set-hostname $NAME + hostnamectl set-hostname $NAME || hostname $NAME #Nameserver sed -i -e "/^nameserver.*$/d" /etc/resolv.conf # remove previous entries diff --git a/systemvm/debian/opt/cloud/bin/setup/vpcrouter.sh b/systemvm/debian/opt/cloud/bin/setup/vpcrouter.sh index 767f87848dd3..cae51742a347 100755 --- a/systemvm/debian/opt/cloud/bin/setup/vpcrouter.sh +++ b/systemvm/debian/opt/cloud/bin/setup/vpcrouter.sh @@ -27,7 +27,7 @@ setup_vpcrouter() { echo $NAME > /etc/hostname echo 'AVAHI_DAEMON_DETECT_LOCAL=0' > /etc/default/avahi-daemon - hostnamectl set-hostname $NAME + hostnamectl set-hostname $NAME || hostname $NAME #Nameserver sed -i -e "/^nameserver.*$/d" /etc/resolv.conf # remove previous entries From b84b3513b43b328e3bf47f21a45f8c47441ca5ea Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Tue, 27 Oct 2026 21:04:55 +0100 Subject: [PATCH 35/64] marvin: do not fail to deploy a VM from an ISO or as a normal user The check for a built-in template listed the template with the filter 'all', which fails for an ISO (incorrect format) and for a non-admin user. Use the filter 'executable' and consider the template as not built-in on any error. --- tools/marvin/marvin/lib/base.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py index f57d746c6370..02b3d3e29bf9 100755 --- a/tools/marvin/marvin/lib/base.py +++ b/tools/marvin/marvin/lib/base.py @@ -567,8 +567,12 @@ def is_builtin_template(cls, apiclient, templateid): """Check if the template is a built-in template""" cmd = listTemplates.listTemplatesCmd() cmd.id = templateid - cmd.templatefilter = "all" - templates = apiclient.listTemplates(cmd) + cmd.templatefilter = "executable" + try: + templates = apiclient.listTemplates(cmd) + except Exception: + # not a template (an ISO), or not visible to the user + return False return bool(templates and templates[0].templatetype == "BUILTIN") @classmethod From fae0338d7340b92a4e2dfdfeddf2152a340bc263 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Fri, 23 Oct 2026 16:48:07 +0200 Subject: [PATCH 36/64] test: fix smoke test failures on xen/vmware (#13628) * test: fix smoke test failures on xen/vmware * test: sleep 10 seconds before attaching volume in test_events_resource.py * test: add more time.sleep(10) * test: add more time.sleep(10) in test_vm_strict_host_tags.py * test: fix test_usage.py * test: move time.sleep(10) in test_host_maintenance.py * VMware: fix import DC * test: retry domain deletion in tearDown of test_deploy_vms_in_parallel.py * test: fix tests failures caused by others in drs and host maintenance --- test/integration/smoke/test_cluster_drs.py | 15 ++-- .../smoke/test_deploy_vms_in_parallel.py | 36 ++++++++++ .../integration/smoke/test_events_resource.py | 1 + .../smoke/test_host_maintenance.py | 69 ++++++++++++++++--- test/integration/smoke/test_kms_lifecycle.py | 5 ++ .../smoke/test_network_extension_namespace.py | 4 +- .../smoke/test_nonstrict_affinity_group.py | 7 +- test/integration/smoke/test_usage.py | 11 +-- test/integration/smoke/test_vm_life_cycle.py | 1 + .../smoke/test_vm_strict_host_tags.py | 4 ++ .../hypervisor/vmware/util/VmwareClient.java | 2 +- 11 files changed, 129 insertions(+), 26 deletions(-) diff --git a/test/integration/smoke/test_cluster_drs.py b/test/integration/smoke/test_cluster_drs.py index 53abe7fd8e31..42d71b8f556a 100644 --- a/test/integration/smoke/test_cluster_drs.py +++ b/test/integration/smoke/test_cluster_drs.py @@ -128,13 +128,13 @@ def migrateSvms(cls, cluster): responseS = cls.apiclient.listSystemVms(cmds) if isinstance(responseS, Iterable): for svm in responseS: - if svm.hostid != cls.hosts[0].id: + if svm.hostid != cls.hosts[0].id and svm.state == 'Running': systemVmIds.append(svm.id) cmdv = listRouters.listRoutersCmd() responseR = cls.apiclient.listRouters(cmdv) if isinstance(responseR, Iterable): for svm in responseR: - if svm.hostid != cls.hosts[0].id: + if svm.hostid != cls.hosts[0].id and svm.state == 'Running': systemVmIds.append(svm.id) numToMigrate = len(systemVmIds) cls.logger.debug(f'system vms and routers to migrate -- {numToMigrate}') @@ -142,8 +142,15 @@ def migrateSvms(cls, cluster): cmdM.hostId=cls.hosts[0].id for id in systemVmIds: cmdM.virtualmachineid=id - responseM = cls.apiclient.migrateSystemVm(cmdM) - cls.logger.debug(f'migrated {responseM}') + try: + responseM = cls.apiclient.migrateSystemVm(cmdM) + cls.logger.debug(f'migrated {responseM}') + except Exception as e: + # A system vm/router may have moved out of Running state (e.g. redundant + # router failover, or an in-progress restart from a previous test's cleanup) + # between the listSystemVms/listRouters call above and this migration attempt. + # Don't fail the whole test class setup for one such VM. + cls.logger.debug(f'Skipping migration of {id}, it may no longer be in Running state: {e}') @classmethod diff --git a/test/integration/smoke/test_deploy_vms_in_parallel.py b/test/integration/smoke/test_deploy_vms_in_parallel.py index 03049a29a914..6e977bb5cd76 100644 --- a/test/integration/smoke/test_deploy_vms_in_parallel.py +++ b/test/integration/smoke/test_deploy_vms_in_parallel.py @@ -18,6 +18,8 @@ """ P1 for Deploy VM from ISO """ # Import Local Modules +import time + from nose.plugins.attrib import attr from marvin.cloudstackTestCase import cloudstackTestCase from marvin.lib.base import (Account, @@ -123,6 +125,40 @@ def update_resource_limit(self, max=1): ) def tearDown(self): + # Deleting the account only soft-deletes it; the account row (and + # its "needs cleanup" state) is purged asynchronously by the + # account.cleanup.interval background task. Deleting the domain + # right after the account can therefore race with that task and + # fail with "Can't delete the domain yet because it has N + # accounts to cleanup". Delete the account first, then retry the + # domain deletion for a bit to ride out that race. + try: + self.cleanup_resources(self.apiclient, [self.account]) + except Exception as e: + self.debug("Warning: Exception during account cleanup : %s" % e) + + retries_left = 15 + while True: + try: + self.domain.delete(self.apiclient) + break + except Exception as e: + retries_left -= 1 + if "accounts to cleanup" not in str(e): + raise Exception("Warning: Exception during cleanup : %s" % e) + if retries_left <= 0: + # The account cleanup task can get permanently stuck detaching + # the account's data volume from an already-expunged VM (a + # known server-side race between VM expunge and account + # cleanup, unrelated to what this test verifies). Don't fail + # the test on that; just leave the domain/account behind for + # cleanup to retry indefinitely, and log it for visibility. + self.debug("Warning: giving up on domain cleanup, leaving it " + "behind for a later cleanup attempt: %s" % e) + break + time.sleep(5) + + self.cleanup = [] super(TestDeployVMsInParallel, self).tearDown() @attr( diff --git a/test/integration/smoke/test_events_resource.py b/test/integration/smoke/test_events_resource.py index dac95f8c090a..fce0e6d7370f 100644 --- a/test/integration/smoke/test_events_resource.py +++ b/test/integration/smoke/test_events_resource.py @@ -147,6 +147,7 @@ def test_01_events_resource(self): diskofferingid=self.disk_offering.id ) self.cleanup.append(volume) + time.sleep(10) virtual_machine.attach_volume( self.apiclient, volume diff --git a/test/integration/smoke/test_host_maintenance.py b/test/integration/smoke/test_host_maintenance.py index 9a84f325ede7..4b11d8eeb817 100644 --- a/test/integration/smoke/test_host_maintenance.py +++ b/test/integration/smoke/test_host_maintenance.py @@ -27,6 +27,8 @@ from distutils.util import strtobool from marvin.sshClient import SshClient +import time + _multiprocess_shared_ = False MIN_VMS_FOR_TEST = 3 @@ -43,23 +45,40 @@ def get_ssh_client(self, ip, username, password, retries=10): return ssh_client - def wait_until_host_is_in_state(self, hostid, resourcestate, interval=3, retries=20): + def wait_until_host_is_in_state(self, hostid, resourcestate, interval=3, retries=20, abort_states=None): + """ + Wait until the host reaches resourcestate. If abort_states is given and the host lands + in one of those states instead, skip the test immediately rather than waiting out the + full timeout: ErrorInPrepareForMaintenance/ErrorInMaintenance while waiting for + "Maintenance" usually means the hypervisor refused to migrate a VM off this host (most + commonly because the hosts in the cluster have incompatible CPUs), which is an + environment limitation, not something this test can exercise meaningfully. + """ def check_resource_state(): response = Host.list( self.apiclient, id=hostid ) if isinstance(response, list): - if response[0].resourcestate == resourcestate: + current_state = response[0].resourcestate + if current_state == resourcestate: self.logger.debug('Host with id %s is in resource state = %s' % (hostid, resourcestate)) return True, None - else: - self.logger.debug("Waiting for host " + hostid + - " to reach state " + resourcestate + - ", with current state " + response[0].resourcestate) + if abort_states and current_state in abort_states: + self.logger.debug('Host with id %s entered abort state = %s' % (hostid, current_state)) + return True, current_state + self.logger.debug("Waiting for host " + hostid + + " to reach state " + resourcestate + + ", with current state " + current_state) return False, None - done, _ = wait_until(interval, retries, check_resource_state) + done, abort_state = wait_until(interval, retries, check_resource_state) + if abort_state: + raise unittest.SkipTest( + "Host %s entered resource state %s while waiting to reach %s -- the hypervisor " + "rejected the VM migration needed for this test (commonly caused by incompatible " + "CPUs between hosts in the cluster). Skipping this migration-dependent test." + % (hostid, abort_state, resourcestate)) if not done: raise Exception("Failed to wait for host %s to be on resource state %s" % (hostid, resourcestate)) return True @@ -82,6 +101,20 @@ def cancel_host_maintenance(self, hostid): return res def revert_host_state_on_failure(self, hostId): + # updateHost(allocationstate=Enable) only has a transition defined from the + # Disabled resource state. If a migration failed while putting the host into + # maintenance, the host is left in one of the maintenance-related error states + # (PrepareForMaintenance, ErrorInPrepareForMaintenance, Maintenance, + # ErrorInMaintenance) instead, and only cancelHostMaintenance (AdminCancelMaintenance) + # can move it back to Enabled from there. Recover via whichever API actually applies. + host = Host.list(self.apiclient, id=hostId)[0] + if host.resourcestate == "Enabled": + return + if host.resourcestate in ("PrepareForMaintenance", "ErrorInPrepareForMaintenance", + "Maintenance", "ErrorInMaintenance"): + self.cancel_host_maintenance(hostId) + self.wait_until_host_is_in_state(hostId, "Enabled", 5, 60) + return cmd = updateHost.updateHostCmd() cmd.id = hostId cmd.allocationstate = "Enable" @@ -245,7 +278,9 @@ def hostPrepareAndCancelMaintenance(self, target_host_id, other_host_id): self.prepare_host_for_maintenance(target_host_id) migrations_finished = wait_until(5, 200, self.migrationsFinished, target_host_id) - self.wait_until_host_is_in_state(target_host_id, "Maintenance", 5, 200) + self.wait_until_host_is_in_state( + target_host_id, "Maintenance", 5, 200, + abort_states=("ErrorInPrepareForMaintenance", "ErrorInMaintenance")) vm_count_after_maintenance = self.noOfVMsOnHost(target_host_id) @@ -299,11 +334,15 @@ def test_01_cancel_host_maintenace_with_no_migration_jobs(self): else: raise unittest.SkipTest("VMs are still migrating so reverse migration /maintenace skipped") + except unittest.SkipTest: + self.revert_host_state_on_failure(listHost[0].id) + self.revert_host_state_on_failure(listHost[1].id) + raise except Exception as e: self.revert_host_state_on_failure(listHost[0].id) self.revert_host_state_on_failure(listHost[1].id) self.logger.debug("Exception {}".format(e)) - self.fail("Host maintenance test failed {}".format(e[0])) + self.fail("Host maintenance test failed {}".format(str(e))) @attr( @@ -350,6 +389,8 @@ def test_02_cancel_host_maintenace_with_migration_jobs(self): self.logger.debug("Creating vms = {}".format(no_vm_req)) self.vmlist = self.createVMs(listHost[0].id, no_vm_req) + time.sleep(10) + try: migrations_finished = self.hostPrepareAndCancelMaintenance(listHost[0].id, listHost[1].id) @@ -358,11 +399,15 @@ def test_02_cancel_host_maintenace_with_migration_jobs(self): else: raise unittest.SkipTest("VMs are still migrating so reverse migration /maintenace skipped") + except unittest.SkipTest: + self.revert_host_state_on_failure(listHost[0].id) + self.revert_host_state_on_failure(listHost[1].id) + raise except Exception as e: self.revert_host_state_on_failure(listHost[0].id) self.revert_host_state_on_failure(listHost[1].id) self.logger.debug("Exception {}".format(e)) - self.fail("Host maintenance test failed {}".format(e[0])) + self.fail("Host maintenance test failed {}".format(str(e))) @attr( tags=[ @@ -414,6 +459,8 @@ def test_03_cancel_host_maintenace_with_migration_jobs_failure(self): self.logger.debug("Creating vms = {}".format(no_vm_req)) self.vmlist = self.createVMs(listHost[0].id, no_vm_req, "taggedsmall") + time.sleep(10) + # Attempt putting host in maintenance and check if ErrorInMaintenance state is reached self.prepare_host_for_maintenance(target_host_id) error_in_maintenance_reached = self.wait_until_host_is_in_state(target_host_id, "ErrorInMaintenance", 5, 300) @@ -431,7 +478,7 @@ def test_03_cancel_host_maintenace_with_migration_jobs_failure(self): self.revert_host_state_on_failure(listHost[1].id) Host.update(self.apiclient, id=target_host_id, hosttags="") self.logger.debug("Exception {}".format(e)) - self.fail("Host maintenance test failed {}".format(e[0])) + self.fail("Host maintenance test failed {}".format(str(e))) class TestHostMaintenanceAgents(TestHostMaintenanceBase): diff --git a/test/integration/smoke/test_kms_lifecycle.py b/test/integration/smoke/test_kms_lifecycle.py index f23e0bc3aa8f..ede5dede7524 100644 --- a/test/integration/smoke/test_kms_lifecycle.py +++ b/test/integration/smoke/test_kms_lifecycle.py @@ -65,6 +65,7 @@ def setUpClass(cls): cls.apiclient = cls.test_client.getApiClient() cls.zone = get_zone(cls.apiclient, cls.test_client.getZoneForTests()) cls.domain = get_domain(cls.apiclient) + cls.hypervisor = cls.test_client.getHypervisorInfo() cls._cleanup = [] @@ -424,6 +425,10 @@ def test_12_deploy_vm_with_root_disk_encryption(self): Test: deploy a VM with its root disk encrypted using a KMS key. Verify that the VM starts and the root volume has the KMS key ID. """ + + if self.hypervisor.lower() != 'kvm': + raise self.skipTest("Skipping test case for non-kvm hypervisor") + # 1. Create a KMS key for the user key = self._create_kms_key(name=_random_name("vm-root-key"), profile_id=self.default_profile.id, apiclient=self.user_apiclient) diff --git a/test/integration/smoke/test_network_extension_namespace.py b/test/integration/smoke/test_network_extension_namespace.py index 5452cd4ac9d0..f2484d73d8c1 100644 --- a/test/integration/smoke/test_network_extension_namespace.py +++ b/test/integration/smoke/test_network_extension_namespace.py @@ -859,6 +859,8 @@ def _check_kvm_host_prerequisites(self, tools=None): excluded from the check — the connectivity failure will surface naturally when the test later tries to deploy scripts. """ + if self.hv.lower() != 'kvm': + raise self.skipTest("Skipping test case for non-kvm hypervisor") if tools is None: tools = ['arping', 'dnsmasq', 'haproxy'] if not self.kvm_host_configs: @@ -2387,7 +2389,7 @@ def _mk_action(name, parameters = []): @attr(tags=["advanced", "smoke"], required_hardware="true") def test_09_vpc_source_nat_ip_update(self): """Update VPC source NAT IP and verify old/new source NAT flags flip correctly.""" - self._check_kvm_host_prerequisites(['arping']) + self._check_kvm_host_prerequisites(['ip', 'arping', 'dnsmasq', 'haproxy']) svc = VPC_NETWORK_SERVICES _nw_offering, ext_name = self._setup_extension_nsp_offering( diff --git a/test/integration/smoke/test_nonstrict_affinity_group.py b/test/integration/smoke/test_nonstrict_affinity_group.py index 1b9b0c02c709..3e9890daf6b7 100644 --- a/test/integration/smoke/test_nonstrict_affinity_group.py +++ b/test/integration/smoke/test_nonstrict_affinity_group.py @@ -20,6 +20,7 @@ """ import logging +import time from marvin.codes import FAILED from nose.plugins.attrib import attr @@ -38,7 +39,6 @@ from marvin.lib.common import (get_domain, get_zone, - get_template, get_test_template) @@ -209,6 +209,9 @@ def test_01_non_strict_host_anti_affinity(self): vm_2_host_id, msg="Both VMs of affinity group %s are on the same host" % self.affinity_group.name) + + time.sleep(10) + # 4. Migrate vm-2 to same host as vm-1 self.virtual_machine_2.migrate( self.apiclient, @@ -362,6 +365,8 @@ def test_02_non_strict_host_affinity(self): vm_12_host_id, msg="Both VMs of affinity group %s are on the different host" % self.affinity_group.name) + time.sleep(10) + # 4. Migrate vm-12 to different host as vm-11 self.virtual_machine_12.migrate( self.apiclient diff --git a/test/integration/smoke/test_usage.py b/test/integration/smoke/test_usage.py index fef0d8fe3c1e..501070980652 100644 --- a/test/integration/smoke/test_usage.py +++ b/test/integration/smoke/test_usage.py @@ -43,6 +43,7 @@ list_storage_pools, find_storage_pool_type) +import time class Services: @@ -782,6 +783,7 @@ def test_01_volume_usage(self): ) rool_volume_pool = rool_volume_pool_response[0] try: + time.sleep(10) self.virtual_machine.attach_volume(self.apiclient,volume_uploaded) except Exception as e: self.debug("Exception %s: " % e) @@ -1744,16 +1746,9 @@ def setUpClass(cls): domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) - cls.public_ip = PublicIPAddress.create( - cls.api_client, - accountid=cls.virtual_machine.account, - zoneid=cls.virtual_machine.zoneid, - domainid=cls.virtual_machine.domainid, - services=cls.services["server"] - ) src_nat_list = PublicIPAddress.list( cls.api_client, - accountid=cls.virtual_machine.account, + account=cls.virtual_machine.account, zoneid=cls.virtual_machine.zoneid, domainid=cls.virtual_machine.domainid, issourcenat=True diff --git a/test/integration/smoke/test_vm_life_cycle.py b/test/integration/smoke/test_vm_life_cycle.py index 8df0b994a555..2bb4effb704d 100644 --- a/test/integration/smoke/test_vm_life_cycle.py +++ b/test/integration/smoke/test_vm_life_cycle.py @@ -858,6 +858,7 @@ def test_11_destroy_vm_and_volumes(self): zoneid=self.zone.id ) + time.sleep(10) small_virtual_machine.attach_volume(self.apiclient, vol1) self.debug("Destroy VM - ID: %s" % small_virtual_machine.id) diff --git a/test/integration/smoke/test_vm_strict_host_tags.py b/test/integration/smoke/test_vm_strict_host_tags.py index aac3e1ea65f2..26d36d7b5c36 100644 --- a/test/integration/smoke/test_vm_strict_host_tags.py +++ b/test/integration/smoke/test_vm_strict_host_tags.py @@ -22,6 +22,7 @@ from marvin.lib.common import (get_domain, get_zone) from nose.plugins.attrib import attr +import time class TestVMDeploymentPlannerStrictTags(cloudstackTestCase): @@ -529,6 +530,8 @@ def test_01_migrate_vm_strict_tags_success(self): self.cleanup.append(vm) self.assertEqual(self.host_h1.id, vm.hostid, "VM instance was not deployed on target host ID") Host.update(self.apiclient, id=self.host_h2.id, hosttags="h1,t1,v1") + + time.sleep(10) # Wait for VM to boot into OS before migrating the VM vm.migrate(self.apiclient, self.host_h2.id) migrated_vm = VirtualMachine.list(self.apiclient, id=vm.id, listall=True)[0] self.assertEqual(migrated_vm.hostid, self.host_h2.id, "VM was not migratd") @@ -545,6 +548,7 @@ def test_02_migrate_vm_strict_tags_failure(self): self.assertEqual(self.host_h1.id, vm.hostid, "VM instance was not deployed on target host ID") Host.update(self.apiclient, id=self.host_h2.id, hosttags="h2,t2,v2") try: + time.sleep(10) # Wait for VM to boot into OS before migrating the VM vm.migrate(self.apiclient, self.host_h2.id) VirtualMachine.list(self.apiclient, id=vm.id, listall=True)[0] self.fail("VM should not be migrated") diff --git a/vmware-base/src/main/java/com/cloud/hypervisor/vmware/util/VmwareClient.java b/vmware-base/src/main/java/com/cloud/hypervisor/vmware/util/VmwareClient.java index 0e46f2e03cd6..15e26f399f1b 100644 --- a/vmware-base/src/main/java/com/cloud/hypervisor/vmware/util/VmwareClient.java +++ b/vmware-base/src/main/java/com/cloud/hypervisor/vmware/util/VmwareClient.java @@ -128,9 +128,9 @@ private static void trustAllHttpsCertificates() throws Exception { javax.net.ssl.TrustManager tm = new TrustAllTrustManager(); trustAllCerts[0] = tm; javax.net.ssl.SSLContext sc = SSLUtils.getSSLContext(); + sc.init(null, trustAllCerts, null); javax.net.ssl.SSLSessionContext sslsc = sc.getServerSessionContext(); sslsc.setSessionTimeout(0); - sc.init(null, trustAllCerts, null); javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(new SecureSSLSocketFactory(sc)); } From fba819d4c19e7a79758e49bc9c1cae55b0a299b6 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 29 Oct 2026 08:10:02 +0100 Subject: [PATCH 37/64] build-acs-image.sh: install xe-guest-utilities in the Debian and EL images The XenServer/XCP-ng guest agent is needed to attach volumes to a running VM (PV drivers are not detected without it). The packages are downloaded from the GitHub release on the build host. On Debian the deb provides the xenstore tools, so xenstore-utils and libxenstore4 are no longer installed. --- scripts/util/build-acs-image.sh | 42 +++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/scripts/util/build-acs-image.sh b/scripts/util/build-acs-image.sh index e12d7891fb2d..41cf8edd87fe 100755 --- a/scripts/util/build-acs-image.sh +++ b/scripts/util/build-acs-image.sh @@ -21,7 +21,8 @@ # Usage: build-acs-image.sh [-a ACTIONS] [-f FORMATS] [-o OUTDIR] [-g GUESTOS] [-u] [-z] # [-d debian|rhel|suse] [-p ROOT_PASSWORD] # -a actions, a list separated by commas or spaces, done in this order (default: all) -# patch install the guest tools, set the root password, cloud-init and sshd config +# patch install the guest tools (including xe-guest-utilities for XenServer on Debian/Ubuntu +# and EL), set the root password, cloud-init and sshd config # (OS detected from the image: Debian/Ubuntu, EL, SUSE and variants) # shrink virt-sparsify and qemu-img convert -c # convert convert to the formats of -f @@ -147,6 +148,7 @@ check_dependencies() { for cmd in virt-customize virt-cat virt-ls virt-inspector; do command -v "$cmd" >/dev/null 2>&1 || missing+=("$cmd not found ($(pkg_hint libguestfs))") done + command -v curl >/dev/null 2>&1 || missing+=("curl not found, needed to download xe-guest-utilities ($(pkg_hint curl))") fi if [ -n "$DO_SHRINK" ]; then command -v virt-sparsify >/dev/null 2>&1 || missing+=("virt-sparsify not found ($(pkg_hint libguestfs))") @@ -347,15 +349,25 @@ detect_os() { fi echo "Detected OS: ${OS_NAME:-$OS_ID} (family: $OS_FAMILY)" + XE_GUEST_UTILITIES_VERSION="10.0.0-1" # xe-guest-utilities (the XenServer/XCP-ng guest agent) + XE_PACKAGES=() XE_INSTALL="" + local base_cleanup='journalctl --vacuum-time=1s; rm -rf /var/log/*; rm -f /root/.bash_history' case "$OS_FAMILY" in debian) - # nfs-common is the NFS client, the cloud images do not have it and the tests mount NFS in the guest - PACKAGES="qemu-guest-agent,open-vm-tools,xenstore-utils,libxenstore4,nfs-common" + # nfs-common is the NFS client, the cloud images do not have it and the tests mount NFS in the guest; + # the xenstore tools come with xe-guest-utilities (xenstore-utils would conflict with its files) + PACKAGES="qemu-guest-agent,open-vm-tools,nfs-common" + XE_PACKAGES=("xe-guest-utilities_${XE_GUEST_UTILITIES_VERSION}_amd64.deb") + # no service is started in the image build, and the init script is enabled by the package + XE_INSTALL='printf "#!/bin/sh\nexit 101\n" > /usr/sbin/policy-rc.d; chmod +x /usr/sbin/policy-rc.d; dpkg -i /tmp/xe-pkgs/*.deb; rc=$?; rm -rf /usr/sbin/policy-rc.d /tmp/xe-pkgs; exit $rc' CLEANUP="apt clean; apt autoclean; apt autoremove --purge -y; $base_cleanup" ;; rhel) - # there is no xenstore package in the EL repositories + # there is no xenstore package in the EL repositories, xe-guest-utilities has the xenstore tools PACKAGES="qemu-guest-agent,open-vm-tools" + # the xenstore tools are a separate package here, as in the deb + XE_PACKAGES=("xe-guest-utilities-${XE_GUEST_UTILITIES_VERSION}.x86_64.rpm" "xe-guest-utilities-xenstore-${XE_GUEST_UTILITIES_VERSION}.x86_64.rpm") + XE_INSTALL='rpm -Uvh /tmp/xe-pkgs/*.rpm; rc=$?; rm -rf /tmp/xe-pkgs; exit $rc' CLEANUP="(dnf clean all || yum clean all); rm -rf /var/cache/dnf /var/cache/yum; $base_cleanup" ;; suse) PACKAGES="qemu-guest-agent,open-vm-tools,xen-tools-domU" @@ -385,9 +397,29 @@ if [ -f "$f" ] && ! grep -qiE "^[[:space:]]*Include[[:space:]].*sshd_config\.d" { cat "$d"; cat "$f"; } > "$f.new" && cat "$f.new" > "$f" && rm -f "$f.new" fi' + # xe-guest-utilities is for x86_64 guests only, it is downloaded here as the guest may have no network + local xe_args=() + if [ ${#XE_PACKAGES[@]} -gt 0 ]; then + local guest_arch + guest_arch=$(virt-inspector -a "$IMAGE" 2>/dev/null | sed -n 's#.*\(.*\).*#\1#p' | head -1) + if [ "$guest_arch" = "x86_64" ]; then + xe_args=(--mkdir /tmp/xe-pkgs) + local pkg + for pkg in "${XE_PACKAGES[@]}"; do + echo "Downloading $pkg" + curl -fsSL -o "$tmp/$pkg" "https://github.com/xenserver/xe-guest-utilities/releases/download/v10.0.0/$pkg" + xe_args+=(--upload "$tmp/$pkg:/tmp/xe-pkgs/$pkg") + done + xe_args+=(--run-command "$XE_INSTALL") + else + echo "WARN: the image is '$guest_arch', xe-guest-utilities is not installed" >&2 + fi + fi + virt-customize -a "$WORK_IMAGE" \ $UPDATE \ --install "$PACKAGES" \ + "${xe_args[@]}" \ --root-password "password:$ROOT_PASSWORD" \ --upload "$tmp/ds-identify.cfg:/etc/cloud/ds-identify.cfg" \ --upload "$tmp/cloudstack.cfg:/etc/cloud/cloud.cfg.d/cloudstack.cfg" \ @@ -401,7 +433,7 @@ fi' virt-cat -a "$WORK_IMAGE" /etc/cloud/ds-identify.cfg /etc/cloud/cloud.cfg.d/cloudstack.cfg /etc/ssh/sshd_config.d/40-root-login.conf local d for d in /usr/sbin /usr/bin; do - virt-ls -a "$WORK_IMAGE" $d | grep -E '^(qemu-ga|vmtoolsd|xenstore)' | sed "s#^#$d/#" || true + virt-ls -a "$WORK_IMAGE" $d | grep -E '^(qemu-ga|vmtoolsd|xenstore|xe-daemon)' | sed "s#^#$d/#" || true done } From 045f6a4976d0518922c25fe9903a05e5e0268fd8 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 29 Oct 2026 13:15:56 +0100 Subject: [PATCH 38/64] build-acs-image.sh: run set-passwords and ssh on every boot cloud-init applies set-passwords and ssh (the public keys of the instance) once per instance, so the password and the SSH key pair reset in CloudStack are not applied when the VM is started again. Set both modules to always in cloud.cfg. The ssh module deletes and regenerates the host keys whenever it runs, so set ssh_deletekeys to false to keep them across the boots. --- scripts/util/build-acs-image.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/util/build-acs-image.sh b/scripts/util/build-acs-image.sh index 41cf8edd87fe..c44aa7172c18 100755 --- a/scripts/util/build-acs-image.sh +++ b/scripts/util/build-acs-image.sh @@ -386,6 +386,7 @@ datasource_list: [ ConfigDrive, CloudStack, None ] datasource: CloudStack: {} None: {} +ssh_deletekeys: false EOF # sshd uses the first value it reads, so 40- loads before cloud-init's 50-cloud-init.conf printf 'PermitRootLogin yes\n' > "$tmp/40-root-login.conf" @@ -397,6 +398,11 @@ if [ -f "$f" ] && ! grep -qiE "^[[:space:]]*Include[[:space:]].*sshd_config\.d" { cat "$d"; cat "$f"; } > "$f.new" && cat "$f.new" > "$f" && rm -f "$f.new" fi' + # run set-passwords and ssh (the public keys) on every boot instead of once per instance, so that the + # password and the SSH key pair reset in CloudStack are applied at the next start; the host keys are + # kept (ssh_deletekeys: false above), as the ssh module would otherwise replace them on every boot + local cloud_cfg_fix='sed -i -E "s/^([[:space:]]*)- (set[-_]passwords|ssh)[[:space:]]*$/\1- [\2, always]/" /etc/cloud/cloud.cfg' + # xe-guest-utilities is for x86_64 guests only, it is downloaded here as the guest may have no network local xe_args=() if [ ${#XE_PACKAGES[@]} -gt 0 ]; then @@ -426,11 +432,13 @@ fi' --mkdir /etc/ssh/sshd_config.d \ --upload "$tmp/40-root-login.conf:/etc/ssh/sshd_config.d/40-root-login.conf" \ --run-command "$sshd_fix" \ + --run-command "$cloud_cfg_fix" \ --run-command "$CLEANUP" rm -rf "$tmp" echo "--- verification ---" virt-cat -a "$WORK_IMAGE" /etc/cloud/ds-identify.cfg /etc/cloud/cloud.cfg.d/cloudstack.cfg /etc/ssh/sshd_config.d/40-root-login.conf + virt-cat -a "$WORK_IMAGE" /etc/cloud/cloud.cfg | grep -E 'set[-_]passwords|- (\[)?ssh\b' || true local d for d in /usr/sbin /usr/bin; do virt-ls -a "$WORK_IMAGE" $d | grep -E '^(qemu-ga|vmtoolsd|xenstore|xe-daemon)' | sed "s#^#$d/#" || true From 2a5ba6c951bb45e66e1af75808d6993a2f27b8c9 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 29 Oct 2026 13:17:07 +0100 Subject: [PATCH 39/64] marvin: retry attach and detach volume until the XenServer PV drivers are detected XenServer and XCP-ng refuse to hot-attach or hot-detach a volume until the guest tools report in, which is about 45 seconds after the start of a Debian 13 guest. The tests attach a volume right after the VM is Running or restarted, so retry for up to 3 minutes when the error is about the PV drivers. --- tools/marvin/marvin/lib/base.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py index 02b3d3e29bf9..3be8c9012b46 100755 --- a/tools/marvin/marvin/lib/base.py +++ b/tools/marvin/marvin/lib/base.py @@ -979,13 +979,26 @@ def attach_volume(self, apiclient, volume, deviceid=None): if deviceid is not None: cmd.deviceid = deviceid - return apiclient.attachVolume(cmd) + return self._retry_until_pv_drivers(apiclient.attachVolume, cmd) + + @staticmethod + def _retry_until_pv_drivers(api, cmd, timeout=180): + """XenServer/XCP-ng refuses to hot-attach or hot-detach a volume until the guest tools report in, + which is some time after the VM is Running or restarted (about 45 seconds for a Debian 13 guest)""" + while True: + try: + return api(cmd) + except Exception as e: + if "PV drivers" not in str(e) or timeout <= 0: + raise + time.sleep(10) + timeout -= 10 def detach_volume(self, apiclient, volume): """Detach volume to instance""" cmd = detachVolume.detachVolumeCmd() cmd.id = volume.id - return apiclient.detachVolume(cmd) + return self._retry_until_pv_drivers(apiclient.detachVolume, cmd) def add_nic(self, apiclient, networkId, ipaddress=None, macaddress=None, dhcpoptions=None): """Add a NIC to a VM""" From e7ab16eeb89d908f7f05e698756743c0f3a448d0 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 29 Oct 2026 13:17:07 +0100 Subject: [PATCH 40/64] test_primary_storage: use 512 MiB service offerings The Debian 13 built-in template does not boot with the 128 MiB of the tiny offering, so the volume cannot be attached to the VM. --- test/integration/smoke/test_primary_storage.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/integration/smoke/test_primary_storage.py b/test/integration/smoke/test_primary_storage.py index 569335e7e77e..9dc5c37f9ab6 100644 --- a/test/integration/smoke/test_primary_storage.py +++ b/test/integration/smoke/test_primary_storage.py @@ -315,9 +315,10 @@ def test_01_add_primary_storage_disabled_host(self): domainid=self.domain.id ) + # the Debian 13 built-in template does not boot with the 128 MiB of the tiny offering service_offering = ServiceOffering.create( self.apiclient, - self.services["service_offerings"]["tiny"] + dict(self.services["service_offerings"]["tiny"], memory=512) ) self.cleanup.append(service_offering) @@ -423,15 +424,16 @@ def setUpClass(cls): assert storage_response.id == cls.storage_pool_1.id and storage_response.type == cls.storage_pool_1.type # Create Service Offerings with different Storage Tags + # (the Debian 13 built-in template does not boot with the 128 MiB of the tiny offering) cls.service_offering_1 = ServiceOffering.create( cls.apiclient, - cls.services["service_offerings"]["tiny"], + dict(cls.services["service_offerings"]["tiny"], memory=512), tags=cls.services["storage_tags"]["a"] ) cls._cleanup.append(cls.service_offering_1) cls.service_offering_2 = ServiceOffering.create( cls.apiclient, - cls.services["service_offerings"]["tiny"], + dict(cls.services["service_offerings"]["tiny"], memory=512), tags=cls.services["storage_tags"]["b"] ) cls._cleanup.append(cls.service_offering_2) From 7073eca2a7f0e7052e132dfd334adb4455fb567c Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 29 Oct 2026 08:24:35 +0100 Subject: [PATCH 41/64] test_scale_vm: use a 4 GiB disk offering --- test/integration/smoke/test_scale_vm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/smoke/test_scale_vm.py b/test/integration/smoke/test_scale_vm.py index 73aeedac36fa..f0593376f121 100644 --- a/test/integration/smoke/test_scale_vm.py +++ b/test/integration/smoke/test_scale_vm.py @@ -159,7 +159,7 @@ def setUp(self): self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() self.cleanup = [] - self.services["disk_offering"]["disksize"] = 2 + self.services["disk_offering"]["disksize"] = 4 if self.unsupportedHypervisor: self.skipTest("Skipping test because unsupported hypervisor\ From 23866cc083959435bc1e3be15e28abf16711b687 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 29 Oct 2026 13:17:08 +0100 Subject: [PATCH 42/64] test_scale_vm: fix the tests on the Debian 13 built-in template Use 512 MiB and 1024 MiB service offerings, as the guest does not have enough memory with 256 MiB when the dynamic scaling is enabled. Check the open-vm-tools service too, as the guest does not have the vmware-tools service, so all the tests were skipped on VMware. --- test/integration/smoke/test_scale_vm.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/test/integration/smoke/test_scale_vm.py b/test/integration/smoke/test_scale_vm.py index f0593376f121..6786733a1e79 100644 --- a/test/integration/smoke/test_scale_vm.py +++ b/test/integration/smoke/test_scale_vm.py @@ -102,15 +102,20 @@ def setUpClass(cls): ) cls._cleanup.append(cls.account) + # the Debian 13 built-in template needs more memory than the 256 MiB of the default small offering + # (with dynamic scaling, the memory hot-add leaves too little for the guest) + small_offering_data = dict(cls.services["service_offerings"]["small"], memory=512) + big_offering_data = dict(cls.services["service_offerings"]["big"], memory=1024) + cls.small_offering = ServiceOffering.create( cls.apiclient, - cls.services["service_offerings"]["small"] + small_offering_data ) cls._cleanup.append(cls.small_offering) cls.big_offering = ServiceOffering.create( cls.apiclient, - cls.services["service_offerings"]["big"] + big_offering_data ) cls._cleanup.append(cls.big_offering) @@ -122,13 +127,13 @@ def setUpClass(cls): cls.small_offering_dynamic_scaling_disabled = ServiceOffering.create( cls.apiclient, - cls.services["service_offerings"]["small"], + small_offering_data, dynamicscalingenabled=False ) cls.big_offering_dynamic_scaling_disabled = ServiceOffering.create( cls.apiclient, - cls.services["service_offerings"]["small"], + small_offering_data, dynamicscalingenabled=False ) @@ -219,7 +224,7 @@ def test_01_scale_vm(self): if self.hypervisor.lower() == "vmware": sshClient = self.virtual_machine.get_ssh_client() result = str( - sshClient.execute("service vmware-tools status")).lower() + sshClient.execute("service vmware-tools status || systemctl status open-vm-tools")).lower() self.debug("and result is: %s" % result) if "running" not in result: self.skipTest("Skipping scale VM operation because\ @@ -353,7 +358,7 @@ def test_02_scale_vm_negative_offering_disable_scaling(self): if self.hypervisor.lower() == "vmware": sshClient = self.virtual_machine_with_service_offering_dynamic_scaling_disabled.get_ssh_client() result = str( - sshClient.execute("service vmware-tools status")).lower() + sshClient.execute("service vmware-tools status || systemctl status open-vm-tools")).lower() self.debug("and result is: %s" % result) if "running" not in result: self.skipTest("Skipping scale VM operation because\ @@ -462,7 +467,7 @@ def test_03_scale_vm_negative_vm_disable_scaling(self): if self.hypervisor.lower() == "vmware": sshClient = self.virtual_machine_not_dynamically_scalable.get_ssh_client() result = str( - sshClient.execute("service vmware-tools status")).lower() + sshClient.execute("service vmware-tools status || systemctl status open-vm-tools")).lower() self.debug("and result is: %s" % result) if "running" not in result: self.skipTest("Skipping scale VM operation because\ @@ -553,7 +558,7 @@ def test_04_scale_vm_with_user_account(self): if self.hypervisor.lower() == "vmware": sshClient = self.virtual_machine_in_user_account.get_ssh_client() result = str( - sshClient.execute("service vmware-tools status")).lower() + sshClient.execute("service vmware-tools status || systemctl status open-vm-tools")).lower() self.debug("and result is: %s" % result) if "running" not in result: self.skipTest("Skipping scale VM operation because\ @@ -737,7 +742,7 @@ def test_05_scale_vm_dont_allow_disk_offering_change(self): if self.hypervisor.lower() == "vmware": sshClient = self.virtual_machine_test.get_ssh_client() result = str( - sshClient.execute("service vmware-tools status")).lower() + sshClient.execute("service vmware-tools status || systemctl status open-vm-tools")).lower() self.debug("and result is: %s" % result) if "running" not in result: self.skipTest("Skipping scale VM operation because\ From 0f1900338abe8f37d58b3d9e7c772000ced9d0ce Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 29 Oct 2026 14:05:42 +0100 Subject: [PATCH 43/64] templates.sql: update the checksums of the Debian 13 built-in templates The images are rebuilt with the changes of build-acs-image.sh: set-passwords and ssh run on every boot, and xe-guest-utilities is installed. --- setup/db/templates.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup/db/templates.sql b/setup/db/templates.sql index e93f132ef98d..5e98fede0ce3 100755 --- a/setup/db/templates.sql +++ b/setup/db/templates.sql @@ -34,16 +34,16 @@ INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, VALUES (2, UUID(), 'centos53-x86_64', 'CentOS 5.3(64-bit) no GUI (XenServer)', 1, now(), now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/templates/builtin/f59f18fb-ae94-4f97-afd2-f84755767aca.vhd.bz2', 'b63d854a9560c013142567bbae8d98cf', 0, 'CentOS 5.3(64-bit) no GUI (XenServer)', 'VHD', 12, 1, 1, 'XenServer', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, display_text, enable_password, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (4, UUID(), 'debian13-x86_64-kvm', 'Debian 13 (64-bit) genericcloud (KVM)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261026-2643-acs.qcow2', '{SHA-512}d9c8768e89fa6861e273932095b4f0199a8c9285af47a5428547b004ba28ce80ed9ae1ca4439bb4a3dc2634672fe06c0ccc7fa7e8d3113efc1762f58d8c9a870', 'Debian 13 (64-bit) genericcloud (KVM)', 0, 'QCOW2', 184, 1, 1, 'KVM', 1); + VALUES (4, UUID(), 'debian13-x86_64-kvm', 'Debian 13 (64-bit) genericcloud (KVM)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261026-2643-acs.qcow2', '{SHA-512}bd95d28cc1e42e2f9d54c16c1015fee0204677dc6122c9a10bec8aaf0b3730b426f47e1c50e046f21add95f917344fe07089d791eb996fbd996257879022aafe', 'Debian 13 (64-bit) genericcloud (KVM)', 0, 'QCOW2', 184, 1, 1, 'KVM', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (5, UUID(), 'debian13-x86_64-xen', 'Debian 13 (64-bit) genericcloud (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261026-2643-acs-xen.vhd.bz2', '{SHA-512}a4eed88cbcd9c98656179d2bf58077a35d92ab966c2aabde4f7e2bf6aabced051b3b0e98958f68d7393750d3b3a69d8b6abe8d97f324ae07fd21664e7dbb514e', 0, 'Debian 13 (64-bit) genericcloud (XenServer)', 'VHD', 184, 1, 1, 'XenServer', 1); + VALUES (5, UUID(), 'debian13-x86_64-xen', 'Debian 13 (64-bit) genericcloud (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261026-2643-acs-xen.vhd.bz2', '{SHA-512}1126134bdec1db47a34a0ca320b2f7d51e3d2fd2f7c3194ed855e592a3c92a7327edeafe8e8f05a1f2faac8a586d76d38c4003a669a7f28bda891c54261ad94c', 0, 'Debian 13 (64-bit) genericcloud (XenServer)', 'VHD', 184, 1, 1, 'XenServer', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) VALUES (6, UUID(), 'centos64-x64', 'CentOS 6.4(64-bit) GUI (Hyperv)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.3/centos6_4_64bit.vhd.bz2', 'eef6b9940ea3ed01221d963d4a012d0a', 0, 'CentOS 6.4 (64-bit) GUI (Hyperv)', 'VHD', 182, 1, 1, 'Hyperv', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (7, UUID(), 'debian13-x86_64-vmware', 'Debian 13 (64-bit) genericcloud (vSphere)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261026-2643-acs.ova', '{SHA-512}0529980319d1d58037fc06bb82abf097003e2c2c332205be57755bf4c8152e86a3e178394c0ecc9b620b0f7679987881bc862230c56eaea5de0e58a2f4ad6f83', 0, 'Debian 13 (64-bit) genericcloud (vSphere)', 'OVA', 184, 1, 1, 'VMware', 1); + VALUES (7, UUID(), 'debian13-x86_64-vmware', 'Debian 13 (64-bit) genericcloud (vSphere)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261026-2643-acs.ova', '{SHA-512}01500faa467c718561624ae697d1866476792c265714d2a742ae0ffba39108c8f245897d3eba6623ef3cecbf410fae490ee47f41b4b1a237eb586f4a79e5c165', 0, 'Debian 13 (64-bit) genericcloud (vSphere)', 'OVA', 184, 1, 1, 'VMware', 1); INSERT INTO `cloud`.`guest_os_category` (id, uuid, name) VALUES (1, UUID(), 'CentOS'); INSERT INTO `cloud`.`guest_os_category` (id, uuid, name) VALUES (2, UUID(), 'Debian'); From 8c18e6e0ac04f3d9c67d2a7e8b0a88a578208602 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Fri, 30 Oct 2026 10:36:25 +0100 Subject: [PATCH 44/64] marvin: do not add the default userdata to the VMs on the simulator Marvin adds a cloud-init userdata to the VMs deployed from a built-in template. There is no guest on the simulator to apply it, and the networks without the UserData service (L2, persistent, ...) reject it. Add it only when the built-in template is not a simulator template. --- tools/marvin/marvin/lib/base.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py index 3be8c9012b46..6a068322dece 100755 --- a/tools/marvin/marvin/lib/base.py +++ b/tools/marvin/marvin/lib/base.py @@ -563,8 +563,8 @@ def program_ssh_access( "The following exception appeared while programming ssh access - %s" % e) @classmethod - def is_builtin_template(cls, apiclient, templateid): - """Check if the template is a built-in template""" + def needs_default_userdata(cls, apiclient, templateid): + """Check if the template is a built-in template of a hypervisor, other than the simulator""" cmd = listTemplates.listTemplatesCmd() cmd.id = templateid cmd.templatefilter = "executable" @@ -573,7 +573,10 @@ def is_builtin_template(cls, apiclient, templateid): except Exception: # not a template (an ISO), or not visible to the user return False - return bool(templates and templates[0].templatetype == "BUILTIN") + if not templates or templates[0].templatetype != "BUILTIN": + return False + # there is no guest to apply the userdata on the simulator + return str(getattr(templates[0], "hypervisor", "")).lower() != "simulator" @classmethod def create(cls, apiclient, services, templateid=None, accountid=None, @@ -684,7 +687,7 @@ def create(cls, apiclient, services, templateid=None, accountid=None, if "userdata" in services: cmd.userdata = base64.urlsafe_b64encode(services["userdata"].encode()).decode() - elif userdataid is None and getattr(cmd, "templateid", None) and cls.is_builtin_template(apiclient, cmd.templateid): + elif userdataid is None and getattr(cmd, "templateid", None) and cls.needs_default_userdata(apiclient, cmd.templateid): # the built-in templates do not allow ssh login with password by default cmd.userdata = base64.urlsafe_b64encode(BUILTIN_TEMPLATE_USERDATA.encode()).decode() From b63ef06f405f39ed2470501615aa92104da20e6b Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 5 Nov 2026 18:00:14 +0100 Subject: [PATCH 45/64] test_hostha_kvm: wait up to 300 seconds for the HA state The host HA state transitions in the recovery tests complete within a few minutes when the host recovers, so a 200 second wait is too tight. --- test/integration/smoke/test_hostha_kvm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/smoke/test_hostha_kvm.py b/test/integration/smoke/test_hostha_kvm.py index 9b131558dc24..c4a804584a2c 100644 --- a/test/integration/smoke/test_hostha_kvm.py +++ b/test/integration/smoke/test_hostha_kvm.py @@ -190,7 +190,7 @@ def checkForState(expectedState): print("checkForState:: expected=%s, actual=%s" % (state, response.hostha)) return response.hostha.hastate == expectedState, None - res, _ = wait_until(interval, 200, checkForState, state) + res, _ = wait_until(interval, 300, checkForState, state) if not res: self.fail("Failed to see host ha state in :" + state) From 5448ee8b4ab9f06e687cba60a4df9dceacdfd313 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 5 Nov 2026 18:12:21 +0100 Subject: [PATCH 46/64] test_scale_vm: use get_template for all hypervisors Use get_template() in setUpClass for every hypervisor instead of get_test_template() for non-simulator/vmware hypervisors, and drop the xenserver-only template registration in the disk offering change test, so it runs on the built-in template like the other tests. Enable enable.dynamic.scale.vm in setUpClass before the VMs are deployed, so that they get a VCPUs-max that allows scaling up on XenServer. --- test/integration/smoke/test_scale_vm.py | 89 ++++++------------------- 1 file changed, 19 insertions(+), 70 deletions(-) diff --git a/test/integration/smoke/test_scale_vm.py b/test/integration/smoke/test_scale_vm.py index 6786733a1e79..663a0507b5a3 100644 --- a/test/integration/smoke/test_scale_vm.py +++ b/test/integration/smoke/test_scale_vm.py @@ -31,7 +31,6 @@ Volume) from marvin.lib.common import (get_zone, get_template, - get_test_template, get_domain) from nose.plugins.attrib import attr from marvin.sshClient import SshClient @@ -61,34 +60,19 @@ def setUpClass(cls): cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype - if cls.hypervisor.lower() in ['simulator', 'vmware']: - cls.template = get_template( - cls.apiclient, - cls.zone.id, - cls.services["ostype"] - ) - if cls.template == FAILED: - assert False, "get_template() failed to return template\ - with description %s" % cls.services["ostype"] - cls.template = Template.update( - cls.template, - cls.apiclient, - isdynamicallyscalable='true' - ) - else: - cls.template = get_test_template( - cls.apiclient, - cls.zone.id, - cls.hypervisor - ) - if cls.template == FAILED: - assert False, "get_test_template() failed to return template\ - with hypervisor %s" % cls.hypervisor - cls.template = Template.update( - cls.template, - cls.apiclient, - isdynamicallyscalable='true' - ) + cls.template = get_template( + cls.apiclient, + cls.zone.id, + cls.services["ostype"] + ) + if cls.template == FAILED: + assert False, "get_template() failed to return template\ + with description %s" % cls.services["ostype"] + cls.template = Template.update( + cls.template, + cls.apiclient, + isdynamicallyscalable='true' + ) # Set Zones and disk offerings cls.services["small"]["zoneid"] = cls.zone.id @@ -102,6 +86,12 @@ def setUpClass(cls): ) cls._cleanup.append(cls.account) + Configurations.update( + cls.apiclient, + name="enable.dynamic.scale.vm", + value="true" + ) + # the Debian 13 built-in template needs more memory than the 256 MiB of the default small offering # (with dynamic scaling, the memory hot-add leaves too little for the guest) small_offering_data = dict(cls.services["service_offerings"]["small"], memory=512) @@ -119,12 +109,6 @@ def setUpClass(cls): ) cls._cleanup.append(cls.big_offering) - Configurations.update( - cls.apiclient, - name="enable.dynamic.scale.vm", - value="true" - ) - cls.small_offering_dynamic_scaling_disabled = ServiceOffering.create( cls.apiclient, small_offering_data, @@ -670,41 +654,6 @@ def test_05_scale_vm_dont_allow_disk_offering_change(self): # scale up the VM to serviceoffering3 # Check disk offering of root volume to be diskoffering3 since setting allow.diskOffering.change.during.scale.vm is true template = self.template - if self.hypervisor.lower() in ['xenserver']: - test_template = get_test_template(self.apiclient, self.zone.id, self.hypervisor) - self.services["template_2"]["url"] = test_template["url"] - self.services["template_2"]["hypervisor"] = test_template["hypervisor"] - self.services["template_2"]["format"] = test_template["format"] - self.services["template_2"]["ostype"] = "CentOS 5.6 (64-bit)" - - try: - template = Template.register(self.apiclient, - self.services["template_2"], - zoneid=self.zone.id, - account=self.account.name, - domainid=self.account.domainid, - hypervisor=self.hypervisor - ) - - template.download(self.apiclient) - except Exception as e: - self.fail("Failed to register template: %s" % e) - - time.sleep(120) - - template = Template.update( - template, - self.apiclient, - isdynamicallyscalable='true' - ) - - templates = Template.list(self.apiclient, - templatefilter= \ - self.services["template_2"]["templatefilter"], - id=template.id, - ) - - template = templates[0] disk_offering = self.services["disk_offering"] disk_offering["name"] = "Disk Offering 1" From 2e470071c383683e1db5e37d28f44f4791d5ed8c Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 5 Nov 2026 20:33:54 +0100 Subject: [PATCH 47/64] vmware-base: fix template copy from secondary to primary (#13977) * vmware-base: fix template copy from secondary to primary * vmware-base: refactoring * test: revert curl commands to wget in test_routers_network_ops (PR 13977) Revert test_routers_network_ops.py back to wget commands after fixing underlying macchina VM file system corruption issue. Context: - Previous commit changed wget to curl due to libpcre.so.1 library error in macchina VMs - Error was: 'wget: /usr/lib/libpcre.so.1 is not an ELF file' - Root cause: file system corruption during template copy from secondary to primary storage - Fix: PR 13977 (vmware-base: fix template copy from secondary to primary) resolves the issue - This revert verifies wget is working correctly again after the underlying fix Changes: - Replace 'curl -v -m 1 -o index.html -sL www.google.com' back to 'wget -t 1 -T www.google.com' - Affects TestRedundantIsolateNetworks and TestIsolatedNetworks test classes - Apply timeout values of 5 or 1 second depending on test context --- .../smoke/test_routers_network_ops.py | 16 +-- .../hypervisor/vmware/util/VmwareContext.java | 109 +++++++++++++----- 2 files changed, 88 insertions(+), 37 deletions(-) diff --git a/test/integration/smoke/test_routers_network_ops.py b/test/integration/smoke/test_routers_network_ops.py index ac51d3736add..83fc9edf1d01 100644 --- a/test/integration/smoke/test_routers_network_ops.py +++ b/test/integration/smoke/test_routers_network_ops.py @@ -287,7 +287,7 @@ def test_01_RVR_Network_FW_PF_SSH_default_routes_egress_true(self): ) expected = 1 - ssh_command = "curl -v -m 1 -o index.html -sL www.google.com" + ssh_command = "wget -t 1 -T 5 www.google.com" check_string = "200 OK" result = check_router_command(virtual_machine, nat_rule.ipaddress, ssh_command, check_string, self) @@ -307,7 +307,7 @@ def test_01_RVR_Network_FW_PF_SSH_default_routes_egress_true(self): ) expected = 0 - ssh_command = "curl -v -m 1 -o index.html -sL www.google.com" + ssh_command = "wget -t 1 -T 1 www.google.com" check_string = "200 OK" result = check_router_command(virtual_machine, nat_rule.ipaddress, ssh_command, check_string, self) @@ -451,7 +451,7 @@ def test_02_RVR_Network_FW_PF_SSH_default_routes_egress_false(self): ) expected = 0 - ssh_command = "curl -v -m 1 -o index.html -sL www.google.com" + ssh_command = "wget -t 1 -T 1 www.google.com" check_string = "200 OK" result = check_router_command(virtual_machine, nat_rule.ipaddress, ssh_command, check_string, self) @@ -480,7 +480,7 @@ def test_02_RVR_Network_FW_PF_SSH_default_routes_egress_false(self): ) expected = 1 - ssh_command = "curl -v -m 1 -o index.html -sL www.google.com" + ssh_command = "wget -t 1 -T 5 www.google.com" check_string = "200 OK" result = check_router_command(virtual_machine, nat_rule.ipaddress, ssh_command, check_string, self) @@ -840,7 +840,7 @@ def test_01_isolate_network_FW_PF_default_routes_egress_true(self): ) expected = 1 - ssh_command = "curl -v -m 1 -o index.html -sL www.google.com" + ssh_command = "wget -t 1 -T 5 www.google.com" check_string = "200 OK" result = check_router_command(virtual_machine, nat_rule.ipaddress, ssh_command, check_string, self) @@ -860,7 +860,7 @@ def test_01_isolate_network_FW_PF_default_routes_egress_true(self): ) expected = 0 - ssh_command = "curl -v -m 1 -o index.html -sL www.google.com" + ssh_command = "wget -t 1 -T 1 www.google.com" check_string = "200 OK" result = check_router_command(virtual_machine, nat_rule.ipaddress, ssh_command, check_string, self) @@ -995,7 +995,7 @@ def test_02_isolate_network_FW_PF_default_routes_egress_false(self): ) expected = 0 - ssh_command = "curl -v -m 1 -o index.html -sL www.google.com" + ssh_command = "wget -t 1 -T 1 www.google.com" check_string = "200 OK" result = check_router_command(virtual_machine, nat_rule.ipaddress, ssh_command, check_string, self) @@ -1015,7 +1015,7 @@ def test_02_isolate_network_FW_PF_default_routes_egress_false(self): ) expected = 1 - ssh_command = "curl -v -m 1 -o index.html -sL www.google.com" + ssh_command = "wget -t 1 -T 5 www.google.com" check_string = "200 OK" result = check_router_command(virtual_machine, nat_rule.ipaddress, ssh_command, check_string, self) diff --git a/vmware-base/src/main/java/com/cloud/hypervisor/vmware/util/VmwareContext.java b/vmware-base/src/main/java/com/cloud/hypervisor/vmware/util/VmwareContext.java index c2b34aea5d93..3b7c0627fe33 100644 --- a/vmware-base/src/main/java/com/cloud/hypervisor/vmware/util/VmwareContext.java +++ b/vmware-base/src/main/java/com/cloud/hypervisor/vmware/util/VmwareContext.java @@ -23,6 +23,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; @@ -384,29 +385,29 @@ public void uploadFile(String httpMethod, String urlString, String localFileName conn.setRequestProperty("content-type", contentType); conn.setRequestProperty("content-length", Long.toString(new File(localFileName).length())); connectWithRetry(conn); - OutputStream out = null; - InputStream in = null; - BufferedReader br = null; try { - out = conn.getOutputStream(); - in = new FileInputStream(localFileName); + writeFileToConnection(conn, httpMethod, urlString, localFileName); + checkUploadResponse(conn, httpMethod, urlString, localFileName); + } finally { + conn.disconnect(); + } + } + + private void writeFileToConnection(HttpURLConnection conn, String httpMethod, String urlString, String localFileName) throws IOException { + long bytesWritten = 0; + try (OutputStream out = conn.getOutputStream(); + InputStream in = new FileInputStream(localFileName)) { byte[] buf = new byte[ChunkSize]; - int len = 0; + int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); + bytesWritten += len; } out.flush(); - } finally { - if (in != null) - in.close(); - - if (out != null) - out.close(); - - if (br != null) - br.close(); - conn.disconnect(); + } catch (IOException e) { + throw new IOException(String.format("Upload of %s to %s %s failed after writing %d of %d bytes: %s", + localFileName, httpMethod, urlString, bytesWritten, new File(localFileName).length(), e.getMessage()), e); } } @@ -442,32 +443,82 @@ public void uploadVmdkFile(String httpMethod, String urlString, String localFile conn.setRequestProperty("content-length", Long.toString(new File(localFileName).length())); connectWithRetry(conn); - BufferedOutputStream bos = null; - BufferedInputStream is = null; try { - bos = new BufferedOutputStream(conn.getOutputStream()); - is = new BufferedInputStream(new FileInputStream(localFileName)); - int bufferSize = ChunkSize; - byte[] buffer = new byte[bufferSize]; + writeVmdkFileToConnection(conn, httpMethod, urlString, localFileName, totalBytesUpdated, progressUpdater); + checkUploadResponse(conn, httpMethod, urlString, localFileName); + } finally { + conn.disconnect(); + } + } + + private void writeVmdkFileToConnection(HttpURLConnection conn, String httpMethod, String urlString, String localFileName, long totalBytesUpdated, + ActionDelegate progressUpdater) throws IOException { + long bytesWrittenThisCall = 0; + try (BufferedOutputStream bos = new BufferedOutputStream(conn.getOutputStream()); + BufferedInputStream is = new BufferedInputStream(new FileInputStream(localFileName))) { + byte[] buffer = new byte[ChunkSize]; while (true) { - int bytesRead = is.read(buffer, 0, bufferSize); + int bytesRead = is.read(buffer, 0, ChunkSize); if (bytesRead == -1) { break; } bos.write(buffer, 0, bytesRead); totalBytesUpdated += bytesRead; + bytesWrittenThisCall += bytesRead; bos.flush(); if (progressUpdater != null) progressUpdater.action(new Long(totalBytesUpdated)); } bos.flush(); - } finally { - if (is != null) - is.close(); - if (bos != null) - bos.close(); + } catch (IOException e) { + throw new IOException(String.format("Upload of %s to %s %s failed after writing %d of %d bytes for this file " + + "(%d bytes total written so far for this import): %s", + localFileName, httpMethod, urlString, bytesWrittenThisCall, new File(localFileName).length(), totalBytesUpdated, e.getMessage()), e); + } + } - conn.disconnect(); + /** + * HttpURLConnection does not surface a failed request just because the client finished writing the + * request body without an IOException: with chunked transfer encoding many HTTP servers, including + * ESXi's NFC endpoint, read and discard the whole body before responding with an error status (e.g. a + * VMFS file lock, an out-of-space datastore, or an authentication/session failure). Silently ignoring + * the response code is exactly how a rejected/short write can look like a "successful" upload to + * CloudStack. Surface the actual status code, reason phrase and (if any) response body so failures like + * "file locked" are visible in the CloudStack logs instead of only in vCenter/ESXi's own logs, if at all. + */ + private void checkUploadResponse(HttpURLConnection conn, String httpMethod, String urlString, String localFileName) throws IOException { + int responseCode; + try { + responseCode = conn.getResponseCode(); + } catch (IOException e) { + throw new IOException(String.format("Unable to read the response for %s %s (uploading %s): %s", + httpMethod, urlString, localFileName, e.getMessage()), e); + } + + if (responseCode < 200 || responseCode >= 300) { + String responseBody = readResponseBodyQuietly(conn); + boolean hasBody = responseBody != null && !responseBody.trim().isEmpty(); + throw new IOException(String.format( + "%s %s rejected the upload of %s with HTTP %d %s%s", + httpMethod, urlString, localFileName, responseCode, conn.getResponseMessage(), + hasBody ? (": " + responseBody) : "")); + } + } + + private String readResponseBodyQuietly(HttpURLConnection conn) { + InputStream errorStream = conn.getErrorStream(); + if (errorStream == null) { + return null; + } + try (BufferedReader reader = new BufferedReader(new InputStreamReader(errorStream, getCharSetFromConnection(conn)))) { + StringBuilder sb = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null && sb.length() < 1024) { + sb.append(line); + } + return sb.toString(); + } catch (IOException e) { + return null; } } From 83a4a1c2166a3da3a9a320a72d9858b3a9ffc9e8 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 5 Nov 2026 21:50:25 +0100 Subject: [PATCH 48/64] Modify vm_template updates to check guest OS existence Added EXISTS clause to ensure guest OS is available before updating vm_template records for Debian 13. --- .../main/resources/META-INF/db/schema-42300to2400.sql | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql b/engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql index efbf480f2966..27e66514a5a2 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql @@ -229,11 +229,14 @@ CREATE TABLE IF NOT EXISTS `cloud`.`instance_boot_group_details` ( -- Set the guest OS of the built-in Debian 13 templates to 'Debian GNU/Linux 12 (64-bit)', which is only added by later upgrade scripts and is not available in templates.sql UPDATE `cloud`.`vm_template` SET `guest_os_id` = (SELECT `id` FROM `cloud`.`guest_os` WHERE `display_name` = 'Debian GNU/Linux 12 (64-bit)' AND `removed` IS NULL LIMIT 1) - WHERE `id` = 4 AND `unique_name` = 'debian13-x86_64-kvm' AND `type` = 'BUILTIN'; + WHERE `id` = 4 AND `unique_name` = 'debian13-x86_64-kvm' AND `type` = 'BUILTIN' + AND EXISTS (SELECT 1 FROM `cloud`.`guest_os` WHERE `display_name` = 'Debian GNU/Linux 12 (64-bit)' AND `removed` IS NULL); UPDATE `cloud`.`vm_template` SET `guest_os_id` = (SELECT `id` FROM `cloud`.`guest_os` WHERE `display_name` = 'Debian GNU/Linux 12 (64-bit)' AND `removed` IS NULL LIMIT 1) - WHERE `id` = 5 AND `unique_name` = 'debian13-x86_64-xen' AND `type` = 'BUILTIN'; + WHERE `id` = 5 AND `unique_name` = 'debian13-x86_64-xen' AND `type` = 'BUILTIN' + AND EXISTS (SELECT 1 FROM `cloud`.`guest_os` WHERE `display_name` = 'Debian GNU/Linux 12 (64-bit)' AND `removed` IS NULL); UPDATE `cloud`.`vm_template` SET `guest_os_id` = (SELECT `id` FROM `cloud`.`guest_os` WHERE `display_name` = 'Debian GNU/Linux 12 (64-bit)' AND `removed` IS NULL LIMIT 1) - WHERE `id` = 7 AND `unique_name` = 'debian13-x86_64-vmware' AND `type` = 'BUILTIN'; + WHERE `id` = 7 AND `unique_name` = 'debian13-x86_64-vmware' AND `type` = 'BUILTIN' + AND EXISTS (SELECT 1 FROM `cloud`.`guest_os` WHERE `display_name` = 'Debian GNU/Linux 12 (64-bit)' AND `removed` IS NULL); -- Use the NIC and disk controller of the built-in Debian 13 VMware template image (vmxnet3, pvscsi), as the guest kernel has no driver for the default e1000 NIC INSERT INTO `cloud`.`vm_template_details` (`template_id`, `name`, `value`) From 993437e4c2299e1539a998f87d17293cdc987346 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Fri, 6 Nov 2026 16:56:37 +0100 Subject: [PATCH 49/64] templates.sql: download the Debian 13 built-in templates from download.cloudstack.org --- setup/db/templates.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup/db/templates.sql b/setup/db/templates.sql index 5e98fede0ce3..e838c1005161 100755 --- a/setup/db/templates.sql +++ b/setup/db/templates.sql @@ -34,16 +34,16 @@ INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, VALUES (2, UUID(), 'centos53-x86_64', 'CentOS 5.3(64-bit) no GUI (XenServer)', 1, now(), now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/templates/builtin/f59f18fb-ae94-4f97-afd2-f84755767aca.vhd.bz2', 'b63d854a9560c013142567bbae8d98cf', 0, 'CentOS 5.3(64-bit) no GUI (XenServer)', 'VHD', 12, 1, 1, 'XenServer', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, display_text, enable_password, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (4, UUID(), 'debian13-x86_64-kvm', 'Debian 13 (64-bit) genericcloud (KVM)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261026-2643-acs.qcow2', '{SHA-512}bd95d28cc1e42e2f9d54c16c1015fee0204677dc6122c9a10bec8aaf0b3730b426f47e1c50e046f21add95f917344fe07089d791eb996fbd996257879022aafe', 'Debian 13 (64-bit) genericcloud (KVM)', 0, 'QCOW2', 184, 1, 1, 'KVM', 1); + VALUES (4, UUID(), 'debian13-x86_64-kvm', 'Debian 13 (64-bit) genericcloud (KVM)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261026-2643-acs.qcow2', '{SHA-512}bd95d28cc1e42e2f9d54c16c1015fee0204677dc6122c9a10bec8aaf0b3730b426f47e1c50e046f21add95f917344fe07089d791eb996fbd996257879022aafe', 'Debian 13 (64-bit) genericcloud (KVM)', 0, 'QCOW2', 184, 1, 1, 'KVM', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (5, UUID(), 'debian13-x86_64-xen', 'Debian 13 (64-bit) genericcloud (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261026-2643-acs-xen.vhd.bz2', '{SHA-512}1126134bdec1db47a34a0ca320b2f7d51e3d2fd2f7c3194ed855e592a3c92a7327edeafe8e8f05a1f2faac8a586d76d38c4003a669a7f28bda891c54261ad94c', 0, 'Debian 13 (64-bit) genericcloud (XenServer)', 'VHD', 184, 1, 1, 'XenServer', 1); + VALUES (5, UUID(), 'debian13-x86_64-xen', 'Debian 13 (64-bit) genericcloud (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261026-2643-acs-xen.vhd.bz2', '{SHA-512}1126134bdec1db47a34a0ca320b2f7d51e3d2fd2f7c3194ed855e592a3c92a7327edeafe8e8f05a1f2faac8a586d76d38c4003a669a7f28bda891c54261ad94c', 0, 'Debian 13 (64-bit) genericcloud (XenServer)', 'VHD', 184, 1, 1, 'XenServer', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) VALUES (6, UUID(), 'centos64-x64', 'CentOS 6.4(64-bit) GUI (Hyperv)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.3/centos6_4_64bit.vhd.bz2', 'eef6b9940ea3ed01221d963d4a012d0a', 0, 'CentOS 6.4 (64-bit) GUI (Hyperv)', 'VHD', 182, 1, 1, 'Hyperv', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) - VALUES (7, UUID(), 'debian13-x86_64-vmware', 'Debian 13 (64-bit) genericcloud (vSphere)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261026-2643-acs.ova', '{SHA-512}01500faa467c718561624ae697d1866476792c265714d2a742ae0ffba39108c8f245897d3eba6623ef3cecbf410fae490ee47f41b4b1a237eb586f4a79e5c165', 0, 'Debian 13 (64-bit) genericcloud (vSphere)', 'OVA', 184, 1, 1, 'VMware', 1); + VALUES (7, UUID(), 'debian13-x86_64-vmware', 'Debian 13 (64-bit) genericcloud (vSphere)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261026-2643-acs.ova', '{SHA-512}01500faa467c718561624ae697d1866476792c265714d2a742ae0ffba39108c8f245897d3eba6623ef3cecbf410fae490ee47f41b4b1a237eb586f4a79e5c165', 0, 'Debian 13 (64-bit) genericcloud (vSphere)', 'OVA', 184, 1, 1, 'VMware', 1); INSERT INTO `cloud`.`guest_os_category` (id, uuid, name) VALUES (1, UUID(), 'CentOS'); INSERT INTO `cloud`.`guest_os_category` (id, uuid, name) VALUES (2, UUID(), 'Debian'); From 691f6f47ec0cff847d83336d7400cb9eac7d4450 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 9 Nov 2026 12:27:14 +0100 Subject: [PATCH 50/64] build-acs-image.sh: download vhd-util and xe-guest-utilities from download.cloudstack.org Always download the vhd-util of the XenServer VHD together with its libvhd.so.1.0 (https://download.cloudstack.org/tools/vhd-util.x86_64/), and the xe-guest-utilities packages (https://download.cloudstack.org/tools/xe-guest-utilities/), instead of requiring a vhd-util on the host and using the GitHub release. The directory of the downloaded files is first in the PATH and the library path, so the ones of the host are not used. It is removed when the script exits. The early check verifies that the downloaded vhd-util runs, supports convert and can be used with faketime. curl is needed for the patch action and the XenServer VHD, check it first and stop without it. --- scripts/util/build-acs-image.sh | 52 +++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/scripts/util/build-acs-image.sh b/scripts/util/build-acs-image.sh index c44aa7172c18..605fb7a00f92 100755 --- a/scripts/util/build-acs-image.sh +++ b/scripts/util/build-acs-image.sh @@ -46,7 +46,8 @@ # # SHA512SUMS with the checksums of the output files is written to the output directory when all # is done (the entries of other files are kept). The tools needed by the actions and formats are -# checked first, and nothing is installed. +# checked first, and nothing is installed on the host. The vhd-util (with libvhd.so.1.0) of the XenServer VHD and the +# xe-guest-utilities packages are always downloaded from https://download.cloudstack.org/tools/ set -euo pipefail usage() { sed -n '19,46p' "$0"; exit 1; } @@ -59,6 +60,7 @@ UPDATE="" COMPRESS="-c" OS_FAMILY="" ROOT_PASSWORD="password" +TOOLS_URL="https://download.cloudstack.org/tools" while getopts "a:f:o:g:uzd:p:" opt; do case $opt in a) ACTIONS="$OPTARG" ;; @@ -130,7 +132,7 @@ pkg_hint() { elif command -v dnf >/dev/null 2>&1 || command -v yum >/dev/null 2>&1; then [ "$what" = "libguestfs" ] && echo "dnf install guestfs-tools (libguestfs-tools-c on EL8) qemu-img" || echo "dnf install $what" else - echo "install libguestfs tools and qemu-img" + [ "$what" = "libguestfs" ] && echo "install libguestfs tools and qemu-img" || echo "install $what" fi } @@ -141,6 +143,11 @@ check_dependencies() { local missing=() warnings=() local cmd + # curl downloads the xe-guest-utilities packages (patch) and the vhd-util (XenServer VHD), stop here without it + if [ -n "$DO_PATCH" ] || [ -n "$WANT_XEN" ]; then + command -v curl >/dev/null 2>&1 || { echo "ERROR: curl not found, needed to download the tools from $TOOLS_URL ($(pkg_hint curl))" >&2; exit 1; } + fi + for cmd in qemu-img cp mktemp sha512sum; do command -v "$cmd" >/dev/null 2>&1 || missing+=("$cmd not found ($(pkg_hint libguestfs))") done @@ -148,7 +155,6 @@ check_dependencies() { for cmd in virt-customize virt-cat virt-ls virt-inspector; do command -v "$cmd" >/dev/null 2>&1 || missing+=("$cmd not found ($(pkg_hint libguestfs))") done - command -v curl >/dev/null 2>&1 || missing+=("curl not found, needed to download xe-guest-utilities ($(pkg_hint curl))") fi if [ -n "$DO_SHRINK" ]; then command -v virt-sparsify >/dev/null 2>&1 || missing+=("virt-sparsify not found ($(pkg_hint libguestfs))") @@ -180,22 +186,38 @@ check_dependencies() { fi fi - # the XenServer VHD: bzip2, and the 32-bit vhd-util with faketime (as in tools/appliance/build.sh) + # the XenServer VHD: bzip2, and the vhd-util with faketime (as in tools/appliance/build.sh) if [ -n "$WANT_XEN" ]; then command -v bzip2 >/dev/null 2>&1 || missing+=("bzip2 not found, required for the XenServer VHD (install bzip2)") command -v faketime >/dev/null 2>&1 || missing+=("faketime not found, required for the XenServer VHD (install faketime)") - if ! command -v vhd-util >/dev/null 2>&1; then - missing+=("vhd-util not found, required for the XenServer VHD (see the comments in tools/appliance/build.sh, or http://packages.shapeblue.com/systemvmtemplate/vhd-util)") - else - # vhd-util is a 32-bit binary: it needs the i386 libraries, and faketime must be preloadable into it + # vhd-util and its libvhd.so.1.0 are always downloaded from $TOOLS_URL, the directory is first in the PATH + # and the library path so that the ones of the host are not used + local vhd_dir vhd_url="$TOOLS_URL/vhd-util.x86_64" + vhd_dir=$(mktemp -d "$OUTDIR/.vhd-util.XXXXXX" 2>/dev/null || true) + if [ -n "$vhd_dir" ]; then + CLEAN_PATHS+=("$vhd_dir") + if curl -fsSL -o "$vhd_dir/vhd-util" "$vhd_url/vhd-util" && curl -fsSL -o "$vhd_dir/libvhd.so.1.0" "$vhd_url/libvhd.so.1.0" \ + && chmod +x "$vhd_dir/vhd-util"; then + PATH="$vhd_dir:$PATH" + export LD_LIBRARY_PATH="$vhd_dir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" + echo "Downloaded vhd-util and libvhd.so.1.0 from $vhd_url" + fi + fi + [ -n "$vhd_dir" ] && [ -x "$vhd_dir/vhd-util" ] && [ -s "$vhd_dir/libvhd.so.1.0" ] || \ + missing+=("vhd-util and libvhd.so.1.0 could not be downloaded from $vhd_url") + if [ -n "$vhd_dir" ] && [ -x "$vhd_dir/vhd-util" ] && [ -s "$vhd_dir/libvhd.so.1.0" ]; then + # the libraries must be found, faketime must be preloadable into it and it must support convert local vhd_out - vhd_out=$(ldd "$(command -v vhd-util)" 2>&1 || true) + vhd_out=$(ldd "$vhd_dir/vhd-util" 2>&1 || true) if echo "$vhd_out" | grep -qE "not found|not a dynamic|No such file"; then - missing+=("vhd-util cannot be run, missing libraries (32-bit libuuid and libc, and libvhd.so.1.0 in the ldconfig path)") - elif command -v faketime >/dev/null 2>&1; then - vhd_out=$(faketime '2010-01-01' vhd-util 2>&1 || true) - echo "$vhd_out" | grep -q "cannot be preloaded" && \ - missing+=("faketime cannot be used with the 32-bit vhd-util (install the 32-bit faketime library, e.g. faketime:i386)") + missing+=("vhd-util cannot be run, missing libraries: $(echo "$vhd_out" | grep -E 'not found' | awk '{print $1}' | tr '\n' ' ')") + else + vhd_out=$(vhd-util 2>&1 || true) + echo "$vhd_out" | grep -q "convert" || missing+=("the downloaded vhd-util does not support convert") + if command -v faketime >/dev/null 2>&1; then + vhd_out=$(faketime '2010-01-01' vhd-util 2>&1 || true) + echo "$vhd_out" | grep -q "cannot be preloaded" && missing+=("faketime cannot be used with vhd-util") + fi fi fi fi @@ -413,7 +435,7 @@ fi' local pkg for pkg in "${XE_PACKAGES[@]}"; do echo "Downloading $pkg" - curl -fsSL -o "$tmp/$pkg" "https://github.com/xenserver/xe-guest-utilities/releases/download/v10.0.0/$pkg" + curl -fsSL -o "$tmp/$pkg" "$TOOLS_URL/xe-guest-utilities/$pkg" xe_args+=(--upload "$tmp/$pkg:/tmp/xe-pkgs/$pkg") done xe_args+=(--run-command "$XE_INSTALL") From a983a1a6e053f800519e1141a8092f6f440b6c45 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 9 Nov 2026 12:27:21 +0100 Subject: [PATCH 51/64] test_scale_vm: wait for guest tools before scaling Scaling right after VM creation can fail: until the guest tools are up, XenServer does not allow a live vCPU change (VmLacksFeature, errorCode 530). - Add wait_for_xen_pv_tools() for XenServer: wait until XenServer reports PV-drivers-detected for the VM. - Add wait_for_vmware_tools() for VMware: poll the guest until the tools are running, and skip the test if they never come up. - Call the waits after each VM is created, and replace the inline VMware tools checks in every test with the helper, so each test waits and skips the same way. --- test/integration/smoke/test_scale_vm.py | 122 ++++++++++++++---------- 1 file changed, 73 insertions(+), 49 deletions(-) diff --git a/test/integration/smoke/test_scale_vm.py b/test/integration/smoke/test_scale_vm.py index 663a0507b5a3..0d2129a7cd98 100644 --- a/test/integration/smoke/test_scale_vm.py +++ b/test/integration/smoke/test_scale_vm.py @@ -174,6 +174,51 @@ def get_ssh_client(self, ip, username, password, retries=10): def is_host_xcpng8(self, hostname): return type(hostname) == list and len(hostname) > 0 and 'XCP-ng 8' in hostname[0] + def wait_for_xen_pv_tools(self, vm, timeout=60, interval=10): + """XenServer only: wait until the guest PV tools are detected. + XenServer refuses a live vCPU change (VmLacksFeature) until then.""" + if self.hypervisor.lower() != "xenserver": + return + vm_info = VirtualMachine.list(self.apiclient, id=vm.id)[0] + instance_name = vm_info.instancename + host = Host.list( + self.apiclient, + zoneid=self.zone.id, + hostid=vm_info.hostid, + type='Routing' + )[0] + ssh_client = self.get_ssh_client(host.ipaddress, + self.hostConfig["username"], + self.hostConfig["password"]) + deadline = time.time() + timeout + while time.time() < deadline: + out = ssh_client.execute( + "xe vm-list name-label=%s params=PV-drivers-detected --minimal" % instance_name) + if out and out[0].strip().lower() == "true": + self.debug("PV tools detected on %s" % instance_name) + return + time.sleep(interval) + self.fail("PV tools were not detected on %s within %ds" % (instance_name, timeout)) + + def wait_for_vmware_tools(self, vm, timeout=60, interval=10): + """VMware only: wait until the guest VMware tools are running, so the + existing tools check below sees them after a freshly created VM boots.""" + if self.hypervisor.lower() != "vmware": + return True + deadline = time.time() + timeout + while time.time() < deadline: + try: + ssh_client = vm.get_ssh_client() + result = str( + ssh_client.execute("service vmware-tools status || systemctl status open-vm-tools")).lower() + self.debug("and result is: %s" % result) + if "running" in result: + return True + except Exception as e: + self.debug("VMware tools not reachable yet on %s: %s" % (vm.name, e)) + time.sleep(interval) + return False + @attr(hypervisor="xenserver") @attr(tags=["advanced", "basic"], required_hardware="false") def test_01_scale_vm(self): @@ -201,18 +246,13 @@ def test_01_scale_vm(self): mode=self.services["mode"] ) self.cleanup.append(self.virtual_machine) + self.wait_for_xen_pv_tools(self.virtual_machine) - # If hypervisor is Vmware, then check if - # the vmware tools are installed and the process is running - # Vmware tools are necessary for scale VM operation - if self.hypervisor.lower() == "vmware": - sshClient = self.virtual_machine.get_ssh_client() - result = str( - sshClient.execute("service vmware-tools status || systemctl status open-vm-tools")).lower() - self.debug("and result is: %s" % result) - if "running" not in result: - self.skipTest("Skipping scale VM operation because\ - VMware tools are not installed on the VM") + # VMware tools are necessary for scale VM operation: wait for them, + # and skip if they never come up + if not self.wait_for_vmware_tools(self.virtual_machine): + self.skipTest("Skipping scale VM operation because\ + VMware tools are not running on the VM") res = None if self.hypervisor.lower() != 'simulator': hostid = self.virtual_machine.hostid @@ -336,17 +376,11 @@ def test_02_scale_vm_negative_offering_disable_scaling(self): ) self.cleanup.append(self.virtual_machine_with_service_offering_dynamic_scaling_disabled) - # If hypervisor is Vmware, then check if - # the vmware tools are installed and the process is running - # Vmware tools are necessary for scale VM operation - if self.hypervisor.lower() == "vmware": - sshClient = self.virtual_machine_with_service_offering_dynamic_scaling_disabled.get_ssh_client() - result = str( - sshClient.execute("service vmware-tools status || systemctl status open-vm-tools")).lower() - self.debug("and result is: %s" % result) - if "running" not in result: - self.skipTest("Skipping scale VM operation because\ - VMware tools are not installed on the VM") + # VMware tools are necessary for scale VM operation: wait for them, + # and skip if they never come up + if not self.wait_for_vmware_tools(self.virtual_machine_with_service_offering_dynamic_scaling_disabled): + self.skipTest("Skipping scale VM operation because\ + VMware tools are not running on the VM") list_vm_response = VirtualMachine.list( self.apiclient, @@ -445,17 +479,11 @@ def test_03_scale_vm_negative_vm_disable_scaling(self): ) self.cleanup.append(self.virtual_machine_not_dynamically_scalable) - # If hypervisor is Vmware, then check if - # the vmware tools are installed and the process is running - # Vmware tools are necessary for scale VM operation - if self.hypervisor.lower() == "vmware": - sshClient = self.virtual_machine_not_dynamically_scalable.get_ssh_client() - result = str( - sshClient.execute("service vmware-tools status || systemctl status open-vm-tools")).lower() - self.debug("and result is: %s" % result) - if "running" not in result: - self.skipTest("Skipping scale VM operation because\ - VMware tools are not installed on the VM") + # VMware tools are necessary for scale VM operation: wait for them, + # and skip if they never come up + if not self.wait_for_vmware_tools(self.virtual_machine_not_dynamically_scalable): + self.skipTest("Skipping scale VM operation because\ + VMware tools are not running on the VM") list_vm_response = VirtualMachine.list( self.apiclient, @@ -538,15 +566,13 @@ def test_04_scale_vm_with_user_account(self): serviceofferingid=self.small_offering.id, mode=self.services["mode"] ) + self.wait_for_xen_pv_tools(self.virtual_machine_in_user_account) - if self.hypervisor.lower() == "vmware": - sshClient = self.virtual_machine_in_user_account.get_ssh_client() - result = str( - sshClient.execute("service vmware-tools status || systemctl status open-vm-tools")).lower() - self.debug("and result is: %s" % result) - if "running" not in result: - self.skipTest("Skipping scale VM operation because\ - VMware tools are not installed on the VM") + # VMware tools are necessary for scale VM operation: wait for them, + # and skip if they never come up + if not self.wait_for_vmware_tools(self.virtual_machine_in_user_account): + self.skipTest("Skipping scale VM operation because\ + VMware tools are not running on the VM") res = None if self.hypervisor.lower() != 'simulator': list_vm_response = VirtualMachine.list( @@ -687,15 +713,13 @@ def test_05_scale_vm_dont_allow_disk_offering_change(self): serviceofferingid=self.ServiceOffering1WithDiskOffering1.id, mode=self.services["mode"] ) + self.wait_for_xen_pv_tools(self.virtual_machine_test) - if self.hypervisor.lower() == "vmware": - sshClient = self.virtual_machine_test.get_ssh_client() - result = str( - sshClient.execute("service vmware-tools status || systemctl status open-vm-tools")).lower() - self.debug("and result is: %s" % result) - if "running" not in result: - self.skipTest("Skipping scale VM operation because\ - VMware tools are not installed on the VM") + # VMware tools are necessary for scale VM operation: wait for them, + # and skip if they never come up + if not self.wait_for_vmware_tools(self.virtual_machine_test): + self.skipTest("Skipping scale VM operation because\ + VMware tools are not running on the VM") res = None if self.hypervisor.lower() != 'simulator': hostid = self.virtual_machine_test.hostid From cc1b64e84b8672a009409f0eb1da7b419067d578 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 9 Nov 2026 12:28:14 +0100 Subject: [PATCH 52/64] schema: set XenServer dynamic memory details for Debian 12 guest OS Add xenserver.dynamicMin (1 GiB) and xenserver.dynamicMax (1.5 TiB) to the Debian GNU/Linux 12 (64-bit) guest OS. The inserts are guarded by NOT EXISTS so they are safe to run on databases that already have the details. --- .../resources/META-INF/db/schema-42300to2400.sql | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql b/engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql index 27e66514a5a2..93275301137a 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql @@ -247,3 +247,15 @@ INSERT INTO `cloud`.`vm_template_details` (`template_id`, `name`, `value`) SELECT `id`, 'rootDiskController', 'pvscsi' FROM `cloud`.`vm_template` WHERE `id` = 7 AND `unique_name` = 'debian13-x86_64-vmware' AND `type` = 'BUILTIN' AND NOT EXISTS (SELECT 1 FROM `cloud`.`vm_template_details` WHERE `template_id` = 7 AND `name` = 'rootDiskController'); + +-- Debian 12 (64-bit) XenServer dynamic memory defaults: min 1 GiB, max 1.5 TiB +INSERT INTO `cloud`.`guest_os_details` (`guest_os_id`, `name`, `value`, `display`) + SELECT `id`, 'xenserver.dynamicMin', '1073741824', 0 FROM `cloud`.`guest_os` + WHERE `display_name` = 'Debian GNU/Linux 12 (64-bit)' + AND NOT EXISTS (SELECT 1 FROM `cloud`.`guest_os_details` d JOIN `cloud`.`guest_os` g ON d.`guest_os_id` = g.`id` + WHERE g.`display_name` = 'Debian GNU/Linux 12 (64-bit)' AND d.`name` = 'xenserver.dynamicMin'); +INSERT INTO `cloud`.`guest_os_details` (`guest_os_id`, `name`, `value`, `display`) + SELECT `id`, 'xenserver.dynamicMax', '1649267441664', 0 FROM `cloud`.`guest_os` + WHERE `display_name` = 'Debian GNU/Linux 12 (64-bit)' + AND NOT EXISTS (SELECT 1 FROM `cloud`.`guest_os_details` d JOIN `cloud`.`guest_os` g ON d.`guest_os_id` = g.`id` + WHERE g.`display_name` = 'Debian GNU/Linux 12 (64-bit)' AND d.`name` = 'xenserver.dynamicMax'); From 50f51a4d14a09de374d4e92cbd3e8cf88f8051d9 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 9 Nov 2026 12:28:24 +0100 Subject: [PATCH 53/64] test_scale_vm: remove is_host_xcpng8 The XCP-ng 8 check only selected a CPU-only scale. Remove it and its five uses, so every hypervisor takes the default offering path. --- test/integration/smoke/test_scale_vm.py | 37 ++----------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/test/integration/smoke/test_scale_vm.py b/test/integration/smoke/test_scale_vm.py index 0d2129a7cd98..742a08db7a41 100644 --- a/test/integration/smoke/test_scale_vm.py +++ b/test/integration/smoke/test_scale_vm.py @@ -171,9 +171,6 @@ def get_ssh_client(self, ip, username, password, retries=10): return ssh_client - def is_host_xcpng8(self, hostname): - return type(hostname) == list and len(hostname) > 0 and 'XCP-ng 8' in hostname[0] - def wait_for_xen_pv_tools(self, vm, timeout=60, interval=10): """XenServer only: wait until the guest PV tools are detected. XenServer refuses a live vCPU change (VmLacksFeature) until then.""" @@ -278,18 +275,7 @@ def test_01_scale_vm(self): self.apiclient, isdynamicallyscalable='true') - if self.is_host_xcpng8(res): - self.debug("Only scaling for CPU for XCP-ng 8") - offering_data = self.services["service_offerings"]["big"] - offering_data["cpunumber"] = 2 - offering_data["memory"] = self.virtual_machine.memory - self.bigger_offering = ServiceOffering.create( - self.apiclient, - offering_data - ) - self.cleanup.append(self.bigger_offering) - else: - self.bigger_offering = self.big_offering + self.bigger_offering = self.big_offering self.debug("Scaling VM-ID: %s to service offering: %s and state %s" % ( self.virtual_machine.id, @@ -602,18 +588,7 @@ def test_04_scale_vm_with_user_account(self): self.userapiclient, isdynamicallyscalable='true') - if self.is_host_xcpng8(res): - self.debug("Only scaling for CPU for XCP-ng 8") - offering_data = self.services["service_offerings"]["big"] - offering_data["cpunumber"] = 2 - offering_data["memory"] = self.virtual_machine_in_user_account.memory - self.bigger_offering = ServiceOffering.create( - self.apiclient, - offering_data - ) - self.cleanup.append(self.bigger_offering) - else: - self.bigger_offering = self.big_offering + self.bigger_offering = self.big_offering self.debug("Scaling VM-ID: %s to service offering: %s and state %s" % ( self.virtual_machine_in_user_account.id, @@ -760,10 +735,6 @@ def test_05_scale_vm_dont_allow_disk_offering_change(self): 'memory': 1024, 'diskofferingid': self.disk_offering2.id } - if self.is_host_xcpng8(res): - self.debug("Only scaling for CPU for XCP-ng 8") - offering_data["memory"] = self.virtual_machine_test.memory - self.ServiceOffering2WithDiskOffering2 = ServiceOffering.create( self.apiclient, offering_data, @@ -850,10 +821,6 @@ def test_05_scale_vm_dont_allow_disk_offering_change(self): 'memory': 1024, 'diskofferingid': self.disk_offering3.id } - if self.is_host_xcpng8(res): - self.debug("Only scaling for CPU for XCP-ng 8") - offering_data["memory"] = vm_response.memory - self.ServiceOffering3WithDiskOffering3 = ServiceOffering.create( self.apiclient, offering_data, From bd8cd9b1f4cee1d8379ab6b6cc33135656bf7980 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Sat, 7 Nov 2026 10:35:01 +0100 Subject: [PATCH 54/64] test_scale_vm: wait for guest tools before scaling Scaling right after VM creation can fail: until the guest tools are up, XenServer does not allow a live vCPU change (VmLacksFeature, errorCode 530). - Add wait_for_xen_pv_tools() for XenServer: wait until XenServer reports PV-drivers-detected for the VM. - Add wait_for_vmware_tools() for VMware: poll the guest until the tools are running, and skip the test if they never come up. - Call the waits after each VM is created, and replace the inline VMware tools checks in every test with the helper, so each test waits and skips the same way. --- test/integration/smoke/test_scale_vm.py | 45 +++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/integration/smoke/test_scale_vm.py b/test/integration/smoke/test_scale_vm.py index 742a08db7a41..c497d33998a6 100644 --- a/test/integration/smoke/test_scale_vm.py +++ b/test/integration/smoke/test_scale_vm.py @@ -216,6 +216,51 @@ def wait_for_vmware_tools(self, vm, timeout=60, interval=10): time.sleep(interval) return False + def wait_for_xen_pv_tools(self, vm, timeout=60, interval=10): + """XenServer only: wait until the guest PV tools are detected. + XenServer refuses a live vCPU change (VmLacksFeature) until then.""" + if self.hypervisor.lower() != "xenserver": + return + vm_info = VirtualMachine.list(self.apiclient, id=vm.id)[0] + instance_name = vm_info.instancename + host = Host.list( + self.apiclient, + zoneid=self.zone.id, + hostid=vm_info.hostid, + type='Routing' + )[0] + ssh_client = self.get_ssh_client(host.ipaddress, + self.hostConfig["username"], + self.hostConfig["password"]) + deadline = time.time() + timeout + while time.time() < deadline: + out = ssh_client.execute( + "xe vm-list name-label=%s params=PV-drivers-detected --minimal" % instance_name) + if out and out[0].strip().lower() == "true": + self.debug("PV tools detected on %s" % instance_name) + return + time.sleep(interval) + self.fail("PV tools were not detected on %s within %ds" % (instance_name, timeout)) + + def wait_for_vmware_tools(self, vm, timeout=60, interval=10): + """VMware only: wait until the guest VMware tools are running, so the + existing tools check below sees them after a freshly created VM boots.""" + if self.hypervisor.lower() != "vmware": + return True + deadline = time.time() + timeout + while time.time() < deadline: + try: + ssh_client = vm.get_ssh_client() + result = str( + ssh_client.execute("service vmware-tools status || systemctl status open-vm-tools")).lower() + self.debug("and result is: %s" % result) + if "running" in result: + return True + except Exception as e: + self.debug("VMware tools not reachable yet on %s: %s" % (vm.name, e)) + time.sleep(interval) + return False + @attr(hypervisor="xenserver") @attr(tags=["advanced", "basic"], required_hardware="false") def test_01_scale_vm(self): From c950e384ac395b29be012517a169d84ba6dd815b Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Tue, 27 Oct 2026 14:49:45 +0100 Subject: [PATCH 55/64] test_hostha_kvm: reset the host abruptly to make the recovery tests less timing-sensitive resetHost() ran a graceful reboot right after the agent was killed. On hosts where libvirt-guests waits for running guests to shut down (up to 300 seconds), sshd is already stopped during that wait, so the later startAgent over ssh fails and the host ends up fenced instead of recovered. Reset the host immediately with sysrq instead, which is closer to the crash the tests simulate. The reset runs detached so that the ssh command returns before the host goes down, as an abrupt reset leaves the connection half-open. --- test/integration/smoke/test_hostha_kvm.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/integration/smoke/test_hostha_kvm.py b/test/integration/smoke/test_hostha_kvm.py index c4a804584a2c..b9964834a6c8 100644 --- a/test/integration/smoke/test_hostha_kvm.py +++ b/test/integration/smoke/test_hostha_kvm.py @@ -176,9 +176,15 @@ def disableAgent(self): ("systemctl disable cloudstack-agent || chkconfig cloudstack-agent off") def resetHost(self): + # Simulate a crash: reset immediately instead of a graceful "reboot", + # which can block on libvirt-guests waiting for running guests to shut down + # (up to 5 minutes on some distros) while sshd is already stopped. + # The reset runs detached so that the ssh command returns before the host + # goes down, as an abrupt reset leaves the ssh connection half-open. SshClient(self.host.ipaddress, port=22, user=self.hostConfig["username"], passwd=self.hostConfig["password"]).execute \ - ("reboot") + ("nohup sh -c 'sleep 2; echo 1 > /proc/sys/kernel/sysrq; echo b > /proc/sysrq-trigger' " + "/dev/null 2>&1 &") def enableAgent(self): SshClient(self.host.ipaddress, port=22, user=self.hostConfig["username"], passwd=self.hostConfig["password"]).execute\ From 4e2b565678b04b8cb866abfb58c60d25c4d6d306 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 9 Nov 2026 12:38:25 +0100 Subject: [PATCH 56/64] test_scale_vm: list the host by id Host.list has no hostid parameter, use id to get the host of the VM. --- test/integration/smoke/test_scale_vm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/smoke/test_scale_vm.py b/test/integration/smoke/test_scale_vm.py index c497d33998a6..5c862d7757ac 100644 --- a/test/integration/smoke/test_scale_vm.py +++ b/test/integration/smoke/test_scale_vm.py @@ -181,7 +181,7 @@ def wait_for_xen_pv_tools(self, vm, timeout=60, interval=10): host = Host.list( self.apiclient, zoneid=self.zone.id, - hostid=vm_info.hostid, + id=vm_info.hostid, type='Routing' )[0] ssh_client = self.get_ssh_client(host.ipaddress, From dc3949ce8199cba650e61c6e0740d1a617cb1edd Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 9 Nov 2026 13:17:29 +0100 Subject: [PATCH 57/64] marvin: do not add the default userdata if the built-in template has a linked userdata The VMs use the userdata linked to the template, the default userdata is only passed when there is none. --- tools/marvin/marvin/lib/base.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py index 6a068322dece..4a781c836004 100755 --- a/tools/marvin/marvin/lib/base.py +++ b/tools/marvin/marvin/lib/base.py @@ -369,7 +369,8 @@ def login(cls, apiclient, username, password, domain=None, domainid=None): return apiclient.login(cmd) -# cloud-init userdata to allow ssh login with password (root/password) on the built-in templates +# cloud-init userdata to allow ssh login with password (root/password) on the built-in templates, +# it is passed to the VMs only if no userdata is linked to the template BUILTIN_TEMPLATE_USERDATA = """#cloud-config ssh_pwauth: true disable_root: false @@ -564,7 +565,8 @@ def program_ssh_access( @classmethod def needs_default_userdata(cls, apiclient, templateid): - """Check if the template is a built-in template of a hypervisor, other than the simulator""" + """Check if the template is a built-in template of a hypervisor, other than the simulator, + without a userdata linked to it""" cmd = listTemplates.listTemplatesCmd() cmd.id = templateid cmd.templatefilter = "executable" @@ -575,6 +577,9 @@ def needs_default_userdata(cls, apiclient, templateid): return False if not templates or templates[0].templatetype != "BUILTIN": return False + # the VMs use the userdata linked to the template + if getattr(templates[0], "userdataid", None): + return False # there is no guest to apply the userdata on the simulator return str(getattr(templates[0], "hypervisor", "")).lower() != "simulator" From 73acd9723d4dc7853fbffe278d4e9f403c931c95 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 9 Nov 2026 18:52:48 +0100 Subject: [PATCH 58/64] marvin: wait for the PV tools and the VMware tools with helpers in utils XenServer refuses to attach a volume or to change the vCPUs of a running VM until the PV drivers of the guest are detected, which takes about 45 seconds after the boot. test_attach_multiple_volumes attached the volumes right after deploying the VM and failed. Add wait_for_xen_pv_tools (host of the VM, xe PV-drivers-detected) and wait_for_vmware_tools (VMware tools running in the guest) to marvin.lib.utils, use them in test_scale_vm instead of its own copies, and wait for the PV tools in the setUpClass of test_attach_multiple_volumes on XenServer. --- .../smoke/test_attach_multiple_volumes.py | 8 +++- test/integration/smoke/test_scale_vm.py | 44 ++++-------------- tools/marvin/marvin/lib/utils.py | 46 +++++++++++++++++++ 3 files changed, 61 insertions(+), 37 deletions(-) diff --git a/test/integration/smoke/test_attach_multiple_volumes.py b/test/integration/smoke/test_attach_multiple_volumes.py index 89bf780140f0..d34463412176 100644 --- a/test/integration/smoke/test_attach_multiple_volumes.py +++ b/test/integration/smoke/test_attach_multiple_volumes.py @@ -18,7 +18,7 @@ #Import Local Modules from marvin.cloudstackAPI import * from marvin.cloudstackTestCase import cloudstackTestCase -from marvin.lib.utils import (validateList) +from marvin.lib.utils import (validateList, wait_for_xen_pv_tools) from marvin.lib.base import (ServiceOffering, VirtualMachine, Host, @@ -150,6 +150,12 @@ def setUpClass(cls): ) cls._cleanup.append(cls.volume6) + if cls.hypervisor.lower() == "xenserver": + # XenServer refuses to attach a volume until the PV tools of the guest are detected + host_config = cls.config.__dict__["zones"][0].__dict__["pods"][0].__dict__["clusters"][0].__dict__["hosts"][ + 0].__dict__ + wait_for_xen_pv_tools(cls.apiclient, cls.virtual_machine, host_config["username"], host_config["password"]) + @classmethod def tearDownClass(cls): super(TestMultipleVolumeAttach, cls).tearDownClass() diff --git a/test/integration/smoke/test_scale_vm.py b/test/integration/smoke/test_scale_vm.py index 5c862d7757ac..d5d89b4b542e 100644 --- a/test/integration/smoke/test_scale_vm.py +++ b/test/integration/smoke/test_scale_vm.py @@ -20,7 +20,7 @@ from marvin.codes import FAILED from marvin.cloudstackTestCase import cloudstackTestCase from marvin.cloudstackAPI import scaleVirtualMachine -from marvin.lib.utils import cleanup_resources +from marvin.lib.utils import cleanup_resources, wait_for_xen_pv_tools, wait_for_vmware_tools from marvin.lib.base import (Account, Host, VirtualMachine, @@ -171,50 +171,22 @@ def get_ssh_client(self, ip, username, password, retries=10): return ssh_client - def wait_for_xen_pv_tools(self, vm, timeout=60, interval=10): + def wait_for_xen_pv_tools(self, vm): """XenServer only: wait until the guest PV tools are detected. XenServer refuses a live vCPU change (VmLacksFeature) until then.""" if self.hypervisor.lower() != "xenserver": return - vm_info = VirtualMachine.list(self.apiclient, id=vm.id)[0] - instance_name = vm_info.instancename - host = Host.list( - self.apiclient, - zoneid=self.zone.id, - id=vm_info.hostid, - type='Routing' - )[0] - ssh_client = self.get_ssh_client(host.ipaddress, - self.hostConfig["username"], - self.hostConfig["password"]) - deadline = time.time() + timeout - while time.time() < deadline: - out = ssh_client.execute( - "xe vm-list name-label=%s params=PV-drivers-detected --minimal" % instance_name) - if out and out[0].strip().lower() == "true": - self.debug("PV tools detected on %s" % instance_name) - return - time.sleep(interval) - self.fail("PV tools were not detected on %s within %ds" % (instance_name, timeout)) + try: + wait_for_xen_pv_tools(self.apiclient, vm, self.hostConfig["username"], self.hostConfig["password"]) + except Exception as e: + self.fail(str(e)) - def wait_for_vmware_tools(self, vm, timeout=60, interval=10): + def wait_for_vmware_tools(self, vm): """VMware only: wait until the guest VMware tools are running, so the existing tools check below sees them after a freshly created VM boots.""" if self.hypervisor.lower() != "vmware": return True - deadline = time.time() + timeout - while time.time() < deadline: - try: - ssh_client = vm.get_ssh_client() - result = str( - ssh_client.execute("service vmware-tools status || systemctl status open-vm-tools")).lower() - self.debug("and result is: %s" % result) - if "running" in result: - return True - except Exception as e: - self.debug("VMware tools not reachable yet on %s: %s" % (vm.name, e)) - time.sleep(interval) - return False + return wait_for_vmware_tools(vm) def wait_for_xen_pv_tools(self, vm, timeout=60, interval=10): """XenServer only: wait until the guest PV tools are detected. diff --git a/tools/marvin/marvin/lib/utils.py b/tools/marvin/marvin/lib/utils.py index c822a587dfc1..09e8b3761339 100644 --- a/tools/marvin/marvin/lib/utils.py +++ b/tools/marvin/marvin/lib/utils.py @@ -614,3 +614,49 @@ def wait_until(retry_interval=2, no_of_times=2, callback=None, *callback_args): break return wait_result, return_val + + +def wait_for_xen_pv_tools(apiclient, vm, username, password, timeout=120, interval=10): + """XenServer only: wait until the guest PV tools of the VM are detected. + XenServer refuses to attach a volume or to change the vCPUs of a running VM (VmLacksFeature) + until then, it takes about 45 seconds after the boot. + + @param apiclient: API client + @param vm: VirtualMachine object of marvin.lib.base (with hostid and instancename) + @param username, password: credentials to log in to the XenServer host of the VM + @raise Exception: if the PV tools were not detected within timeout seconds + """ + cmd = listHosts.listHostsCmd() + cmd.id = vm.hostid + cmd.type = "Routing" + host = apiclient.listHosts(cmd)[0] + ssh_client = SshClient(host.ipaddress, 22, username, password, 10) + deadline = time.time() + timeout + while time.time() < deadline: + out = ssh_client.execute( + "xe vm-list name-label=%s params=PV-drivers-detected --minimal" % vm.instancename) + if out and out[0].strip().lower() == "true": + return + time.sleep(interval) + raise Exception("PV tools were not detected on %s within %ds" % (vm.instancename, timeout)) + + +def wait_for_vmware_tools(vm, timeout=60, interval=10): + """VMware only: wait until the guest VMware tools (vmware-tools or open-vm-tools) of the VM are running, + it takes some time after the boot. + + @param vm: VirtualMachine object of marvin.lib.base (it must be reachable with get_ssh_client) + @return: True if the tools are running, False if not within timeout seconds + """ + deadline = time.time() + timeout + while time.time() < deadline: + try: + ssh_client = vm.get_ssh_client() + result = str( + ssh_client.execute("service vmware-tools status || systemctl status open-vm-tools")).lower() + if "running" in result: + return True + except Exception as e: + logging.debug("VMware tools not reachable yet on %s: %s", getattr(vm, "name", vm), e) + time.sleep(interval) + return False From ae9e5b375cac8e7ec4ed5749d46a83576adc468b Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 9 Nov 2026 21:56:17 +0100 Subject: [PATCH 59/64] test_host_control_state: poll for the host control state after the agent is started The KVM agent needs about 12-15 seconds to reconnect and the host to be Up, so the fixed sleep of 10 seconds made test_uservm_host_control_state fail with 'Offline' != 'Enabled'. Poll for up to 30 seconds instead. --- test/integration/smoke/test_host_control_state.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/integration/smoke/test_host_control_state.py b/test/integration/smoke/test_host_control_state.py index 7edb39322660..a5cc9883f782 100644 --- a/test/integration/smoke/test_host_control_state.py +++ b/test/integration/smoke/test_host_control_state.py @@ -145,6 +145,15 @@ def verify_uservm_host_control_state(self, vm_id, state): state, msg="host control state should be %s, but it is %s" % (state, vm.hostcontrolstate)) + def wait_for_uservm_host_control_state(self, vm_id, state, timeout=30, interval=2): + """ The agent needs about 15 seconds to reconnect, poll instead of sleeping a fixed time """ + def check_state(): + vm = VirtualMachine.list(self.apiclient, id=vm_id)[0] + return vm.hostcontrolstate == state, vm.hostcontrolstate + + done, _ = wait_until(interval, timeout // interval, check_state) + self.verify_uservm_host_control_state(vm_id, state) + def verify_ssvm_host_control_state(self, vm_id, state): list_ssvm_response = list_ssvms( self.apiclient, @@ -193,8 +202,7 @@ def test_uservm_host_control_state(self): self.verify_uservm_host_control_state(self.vm.id, "Offline") self.start_agent(host_ipaddress) - time.sleep(10) # wait for the host to be Up - self.verify_uservm_host_control_state(self.vm.id, "Enabled") + self.wait_for_uservm_host_control_state(self.vm.id, "Enabled") # wait for the host to be Up else: self.enable_host(host_id) From 231f77d664523ffda0745d526528fee429ded37e Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Wed, 11 Nov 2026 10:06:45 +0100 Subject: [PATCH 60/64] marvin: wait_for_xen_pv_tools looks up the host and instance name when the VM object lacks them --- tools/marvin/marvin/lib/utils.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tools/marvin/marvin/lib/utils.py b/tools/marvin/marvin/lib/utils.py index 09e8b3761339..e8a4376cd81e 100644 --- a/tools/marvin/marvin/lib/utils.py +++ b/tools/marvin/marvin/lib/utils.py @@ -29,7 +29,7 @@ import socket import urllib.parse import datetime -from marvin.cloudstackAPI import cloudstackAPIClient, listHosts, listRouters +from marvin.cloudstackAPI import cloudstackAPIClient, listHosts, listRouters, listVirtualMachines from platform import system from marvin.cloudstackException import GetDetailExceptionInfo from marvin.sshClient import SshClient @@ -622,23 +622,33 @@ def wait_for_xen_pv_tools(apiclient, vm, username, password, timeout=120, interv until then, it takes about 45 seconds after the boot. @param apiclient: API client - @param vm: VirtualMachine object of marvin.lib.base (with hostid and instancename) + @param vm: VirtualMachine object of marvin.lib.base (hostid and instancename are looked up if missing) @param username, password: credentials to log in to the XenServer host of the VM @raise Exception: if the PV tools were not detected within timeout seconds """ + hostid = getattr(vm, "hostid", None) + instancename = getattr(vm, "instancename", None) + if not hostid or not instancename: + # the object returned by VirtualMachine.create does not always have them (e.g. VMs of a user account) + vm_cmd = listVirtualMachines.listVirtualMachinesCmd() + vm_cmd.id = vm.id + vm_cmd.listall = True + vm_info = apiclient.listVirtualMachines(vm_cmd)[0] + hostid = vm_info.hostid + instancename = vm_info.instancename cmd = listHosts.listHostsCmd() - cmd.id = vm.hostid + cmd.id = hostid cmd.type = "Routing" host = apiclient.listHosts(cmd)[0] ssh_client = SshClient(host.ipaddress, 22, username, password, 10) deadline = time.time() + timeout while time.time() < deadline: out = ssh_client.execute( - "xe vm-list name-label=%s params=PV-drivers-detected --minimal" % vm.instancename) + "xe vm-list name-label=%s params=PV-drivers-detected --minimal" % instancename) if out and out[0].strip().lower() == "true": return time.sleep(interval) - raise Exception("PV tools were not detected on %s within %ds" % (vm.instancename, timeout)) + raise Exception("PV tools were not detected on %s within %ds" % (instancename, timeout)) def wait_for_vmware_tools(vm, timeout=60, interval=10): From c897222813a3e3bfc66c6ae40b489ede340e8aa2 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 12 Nov 2026 08:35:38 +0100 Subject: [PATCH 61/64] tests: use the built-in Debian 13 template (user debian) in the cloud-init tests TestSharedNetworkWithConfigDrive, test_ssl_offloading and test_network_extension_namespace registered an Ubuntu 22.04 cloud image. Use the built-in template, which is a Debian 13 cloud image with cloud-init, and ssh as the debian user instead of ubuntu. --- test/integration/smoke/test_network.py | 16 +++---- .../smoke/test_network_extension_namespace.py | 47 +++++-------------- test/integration/smoke/test_ssl_offloading.py | 16 +++---- 3 files changed, 24 insertions(+), 55 deletions(-) diff --git a/test/integration/smoke/test_network.py b/test/integration/smoke/test_network.py index a47a5c37e776..1040c1ad1399 100644 --- a/test/integration/smoke/test_network.py +++ b/test/integration/smoke/test_network.py @@ -39,7 +39,6 @@ LoadBalancerRule, Router, NIC, - Template, Cluster, SSHKeyPair) from marvin.lib.common import (get_domain, @@ -47,6 +46,7 @@ get_zone, get_suitable_test_template, get_test_template, + get_template, list_hosts, list_publicIP, list_nat_rules, @@ -2135,18 +2135,14 @@ def setUpClass(cls): cls._cleanup = [] - template = Template.register( - cls.apiclient, - cls.services["test_templates_cloud_init"][cls.hv.lower()], - zoneid=cls.zone.id, - hypervisor=cls.hv, - ) - template.download(cls.apiclient) - cls._cleanup.append(template) + # the built-in template is a Debian 13 cloud image with cloud-init, the default user is debian + template = get_template(cls.apiclient, cls.zone.id, hypervisor=cls.hv) + if template == FAILED: + assert False, "get_template() failed to return the built-in template" cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = template.id - cls.services["virtual_machine"]["username"] = "ubuntu" + cls.services["virtual_machine"]["username"] = "debian" # Create Network Offering cls.services["shared_network_offering_configdrive"]["specifyVlan"] = "True" cls.services["shared_network_offering_configdrive"]["specifyIpRanges"] = "True" diff --git a/test/integration/smoke/test_network_extension_namespace.py b/test/integration/smoke/test_network_extension_namespace.py index f2484d73d8c1..624e5166ac35 100644 --- a/test/integration/smoke/test_network_extension_namespace.py +++ b/test/integration/smoke/test_network_extension_namespace.py @@ -71,7 +71,6 @@ ServiceOffering, SSHKeyPair, StaticNATRule, - Template, VirtualMachine, VPC, VpcOffering) @@ -511,34 +510,12 @@ def setUpClass(cls): cls.logger.info("KVM hosts from config: %s", [h['ip'] for h in cls.kvm_host_configs if h.get('ip')]) - # ---- Cloud-init template (Ubuntu 22.04) ---- + # ---- Cloud-init template (built-in Debian 13) ---- # Used for hardware tests that verify actual SSH connectivity. - # Falls back to the default test template when the cloud-init entry - # is absent from the services config (e.g. on simulator). - try: - tpl_data = (cls.services - .get("test_templates_cloud_init", {}) - .get(cls.hv.lower())) - if tpl_data: - cls.logger.info("Registering cloud-init template for %s", cls.hv) - tpl = Template.register( - cls.apiclient, - tpl_data, - zoneid=cls.zone.id, - hypervisor=cls.hv, - ) - tpl.download(cls.apiclient) - cls._cleanup.append(tpl) - cls.template = tpl - cls.logger.info("Cloud-init template registered: %s", tpl.id) - else: - cls.logger.info("No cloud-init template for %s; using default", - cls.hv) - cls.template = get_template(cls.apiclient, cls.zone.id, cls.hv) - except Exception as e: - cls.logger.warning("Cloud-init template registration failed: %s; " - "falling back to default", e) - cls.template = get_template(cls.apiclient, cls.zone.id, cls.hv) + # The built-in template is a Debian 13 cloud image with cloud-init, + # the default user is ``debian``. + cls.template = get_template(cls.apiclient, cls.zone.id, hypervisor=cls.hv) + cls.logger.info("Using the built-in template: %s", cls.template) # ---- Download wrapper scripts from GitHub ---- try: @@ -737,8 +714,8 @@ def _safe_teardown(self): def _verify_vm_ssh_access(self, ip, port=22, timeout=30, retries=10): """Return True if SSH to *ip*:*port* succeeds using the active keypair. - The VM is expected to run Ubuntu 22.04 (cloud-init) with username - ``ubuntu``. Returns False if no keypair is available or if the + The VM is expected to run the built-in Debian 13 template (cloud-init) + with username ``debian``. Returns False if no keypair is available or if the connection fails. """ key_file = self._ssh_private_key_file @@ -750,7 +727,7 @@ def _verify_vm_ssh_access(self, ip, port=22, timeout=30, retries=10): return False try: ssh = SshClient( - ip, int(port), "ubuntu", None, + ip, int(port), "debian", None, keyPairFiles=key_file, timeout=timeout, retries=retries, @@ -1057,7 +1034,7 @@ def _create_account_network_vm(self, nw_offering, name_suffix="", """Create an account, an isolated network, and deploy a cloud-init VM. The VM is deployed with an account-scoped SSH keypair so that SSH - access can be tested directly. Username is ``ubuntu``. + access can be tested directly. Username is ``debian``. Returns ``(account, network, vm)``. """ @@ -1309,8 +1286,8 @@ def test_04_dhcp_dns_userdata(self): def test_05_isolated_network_full_lifecycle(self): """Full isolated-network lifecycle with SSH connectivity verification. - Uses a single cloud-init VM (Ubuntu 22.04, SSH keypair, username - ``ubuntu``) throughout. + Uses a single cloud-init VM (built-in Debian 13, SSH keypair, username + ``debian``) throughout. Sub-tests in order ------------------ @@ -2178,7 +2155,7 @@ def test_07_vpc_network_acl(self): # This tests that the ACL egress rules work and inter-tier routing is OK try: ssh_vm2 = SshClient( - tier2_public_ip, 22, "ubuntu", None, + tier2_public_ip, 22, "debian", None, keyPairFiles=self._ssh_private_key_file, timeout=30, retries=10 ) diff --git a/test/integration/smoke/test_ssl_offloading.py b/test/integration/smoke/test_ssl_offloading.py index 5f0ea9adc546..557038a2f285 100644 --- a/test/integration/smoke/test_ssl_offloading.py +++ b/test/integration/smoke/test_ssl_offloading.py @@ -22,7 +22,6 @@ Project, UserData, SslCertificate, - Template, NetworkOffering, ServiceOffering, VirtualMachine, @@ -31,7 +30,7 @@ VpcOffering, PublicIPAddress, LoadBalancerRule) -from marvin.lib.common import (get_domain, get_zone, get_test_template) +from marvin.lib.common import (get_domain, get_zone, get_template, get_test_template) from nose.plugins.attrib import attr import os @@ -212,17 +211,14 @@ def setUpClass(cls): cls.zone.id, cls.hypervisor) else: - cls.template = Template.register( + # the built-in template is a Debian 13 cloud image with cloud-init + cls.template = get_template( cls.apiclient, - cls.services["test_templates_cloud_init"][cls.hypervisor.lower()], - zoneid=cls.zone.id, - hypervisor=cls.hypervisor, - ) - cls.template.download(cls.apiclient) - cls._cleanup.append(cls.template) + cls.zone.id, + hypervisor=cls.hypervisor) if cls.template == FAILED: - assert False, "get_test_template() failed to return template" + assert False, "failed to get the template" # Create service offering cls.service_offering = ServiceOffering.create( From 1b958582a50408a907b0d3e0a6f2d55744d8c647 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 12 Nov 2026 08:41:35 +0100 Subject: [PATCH 62/64] marvin: get_free_vlan skips the networks and IP ranges which are not on a numeric VLAN A network with another broadcast URI (e.g. cs-net-207) made int() fail. --- tools/marvin/marvin/lib/common.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/marvin/marvin/lib/common.py b/tools/marvin/marvin/lib/common.py index 26a4b6af7902..0ee7a1a9a341 100644 --- a/tools/marvin/marvin/lib/common.py +++ b/tools/marvin/marvin/lib/common.py @@ -1158,13 +1158,15 @@ def get_free_vlan(apiclient, zoneid): usedVlanIds = [] if isinstance(networks, list) and len(networks) > 0: + # skip the networks which are not on a numeric VLAN, e.g. untagged ones or ones with + # another broadcast URI like cs-net-207 usedVlanIds = [int(nw.broadcasturi.split("//")[-1]) - for nw in networks if (nw.broadcasturi and nw.broadcasturi.lower() != "vlan://untagged")] + for nw in networks if (nw.broadcasturi and nw.broadcasturi.split("//")[-1].isdigit())] ipranges = list_vlan_ipranges(apiclient, zoneid=zoneid) if isinstance(ipranges, list) and len(ipranges) > 0: usedVlanIds += [int(iprange.vlan.split("/")[-1]) - for iprange in ipranges if (iprange.vlan and iprange.vlan.split("/")[-1].lower() != "untagged")] + for iprange in ipranges if (iprange.vlan and iprange.vlan.split("/")[-1].isdigit())] if not hasattr(physical_network, "vlan"): while True: From 0185d1bb5e087c5258bdc5eac09973e31bb01991 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 12 Nov 2026 20:44:35 +0100 Subject: [PATCH 63/64] test_network_extension_namespace: fail setup clearly when the built-in template is not found --- test/integration/smoke/test_network_extension_namespace.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/integration/smoke/test_network_extension_namespace.py b/test/integration/smoke/test_network_extension_namespace.py index 624e5166ac35..c21e5d67dd72 100644 --- a/test/integration/smoke/test_network_extension_namespace.py +++ b/test/integration/smoke/test_network_extension_namespace.py @@ -42,6 +42,7 @@ import urllib.parse from marvin.cloudstackTestCase import cloudstackTestCase +from marvin.codes import FAILED from marvin.cloudstackAPI import (listPhysicalNetworks, listTrafficTypes, listManagementServers, @@ -515,6 +516,8 @@ def setUpClass(cls): # The built-in template is a Debian 13 cloud image with cloud-init, # the default user is ``debian``. cls.template = get_template(cls.apiclient, cls.zone.id, hypervisor=cls.hv) + if cls.template == FAILED: + assert False, "failed to get the built-in template" cls.logger.info("Using the built-in template: %s", cls.template) # ---- Download wrapper scripts from GitHub ---- From d38a3894022cf49f7ffcce52f71376601b0b56c4 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Wed, 25 Nov 2026 11:16:34 +0100 Subject: [PATCH 64/64] tests: check for FAILED after every get_test_template() call --- test/integration/smoke/test_hostha_kvm.py | 3 +++ test/integration/smoke/test_network.py | 8 ++++++++ test/integration/smoke/test_restore_vm.py | 3 +++ test/integration/smoke/test_routers_network_ops.py | 2 ++ 4 files changed, 16 insertions(+) diff --git a/test/integration/smoke/test_hostha_kvm.py b/test/integration/smoke/test_hostha_kvm.py index b9964834a6c8..1981519cd27d 100644 --- a/test/integration/smoke/test_hostha_kvm.py +++ b/test/integration/smoke/test_hostha_kvm.py @@ -18,6 +18,7 @@ import marvin from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * +from marvin.codes import FAILED from marvin.lib.utils import * from marvin.lib.base import * from marvin.lib.common import * @@ -85,6 +86,8 @@ def setUp(self): self.zone.id, self.hypervisor ) + if self.template == FAILED: + self.fail("get_test_template() failed to return template") self.configureAndDisableHostHa() self.cleanup = [self.service_offering] diff --git a/test/integration/smoke/test_network.py b/test/integration/smoke/test_network.py index 1040c1ad1399..cb59bcf52db1 100644 --- a/test/integration/smoke/test_network.py +++ b/test/integration/smoke/test_network.py @@ -803,6 +803,8 @@ def setUp(self): self.zone.id, self.hypervisor ) + if template == FAILED: + self.fail("get_test_template() failed to return template") self.services["virtual_machine"]["zoneid"] = self.zone.id # Create an account, network, VM, Port forwarding rule, LB rules @@ -1006,6 +1008,8 @@ def setUp(self): self.zone.id, self.hypervisor ) + if template == FAILED: + self.fail("get_test_template() failed to return template") self.services["virtual_machine"]["zoneid"] = self.zone.id # Create an account, network, VM and IP addresses @@ -1419,6 +1423,8 @@ def setUpClass(cls): cls.zone.id, cls.hypervisor ) + if cls.template == FAILED: + assert False, "get_test_template() failed to return template" cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["tiny"] @@ -1668,6 +1674,8 @@ def setUpClass(cls): cls.zone.id, cls.hypervisor ) + if cls.template == FAILED: + assert False, "get_test_template() failed to return template" cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["tiny"] diff --git a/test/integration/smoke/test_restore_vm.py b/test/integration/smoke/test_restore_vm.py index a97395d7b55a..5ad9aefa2029 100644 --- a/test/integration/smoke/test_restore_vm.py +++ b/test/integration/smoke/test_restore_vm.py @@ -21,6 +21,7 @@ # Import Local Modules from marvin.cloudstackTestCase import cloudstackTestCase +from marvin.codes import FAILED from marvin.lib.base import (VirtualMachine, Volume, DiskOffering, ServiceOffering, Template) from marvin.lib.common import (get_zone, get_domain, get_test_template, list_storage_pools) from nose.plugins.attrib import attr @@ -53,6 +54,8 @@ def setUpClass(cls): # the first template is the shared public test template, the restore needs another one template_t1 = get_test_template(cls.apiclient, cls.zone.id, cls.hypervisor) + if template_t1 == FAILED: + assert False, "get_test_template() failed to return template" cls.template_t1 = Template.list(cls.apiclient, templatefilter='all', id=template_t1.id)[0] template_t2 = Template.register(cls.apiclient, cls.services["test_templates"][ diff --git a/test/integration/smoke/test_routers_network_ops.py b/test/integration/smoke/test_routers_network_ops.py index 83fc9edf1d01..3bb4cc03a1b4 100644 --- a/test/integration/smoke/test_routers_network_ops.py +++ b/test/integration/smoke/test_routers_network_ops.py @@ -662,6 +662,8 @@ def setUpClass(cls): cls.zone.id, cls.hypervisor ) + if cls.template == FAILED: + assert False, "get_test_template() failed to return template" cls.services["virtual_machine"]["zoneid"] = cls.zone.id # Create an account, network, VM and IP addresses