Skip to content

Commit 405cdf4

Browse files
committed
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.
1 parent cad9138 commit 405cdf4

3 files changed

Lines changed: 37 additions & 10 deletions

File tree

‎engine/schema/templateConfig.sh‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ function getTemplateVersion() {
2828
subversion2="$(cut -d'.' -f2 <<<"$version")"
2929
minorversion="$(cut -d'.' -f3 <<<"$version")"
3030
fourthversion="$(cut -d'.' -f4 <<<"$version")"
31-
export CS_VERSION="${subversion1}"."${subversion2}"
3231
export CS_MINOR_VERSION="${minorversion}"
33-
export VERSION="${CS_VERSION}.${CS_MINOR_VERSION}"
3432
if [[ "$subversion1" -ge "$NEW_VERSIONING_CUTOVER_MAJOR_VERSION" ]]; then
3533
# New versioning (major.minor.security): the third component is the
3634
# security release itself, there is no separate patch component. A
@@ -40,11 +38,17 @@ function getTemplateVersion() {
4038
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
4139
exit 1
4240
fi
43-
export FULL_VERSION="${VERSION}"
41+
# The templates are in the directory named after the major version (24),
42+
# and the file names contain major.minor (24.0), like 4.22 and 4.22.0 before
43+
export CS_VERSION="${subversion1}"
44+
export VERSION="${subversion1}.${subversion2}"
45+
export FULL_VERSION="${subversion1}.${subversion2}.${minorversion}"
4446
else
4547
# Legacy versioning: major.minor.patch, or major.minor.patch.security when a 4th
4648
# component is present. Without a 4th component, VERSION is already correct as-is;
4749
# appending an empty security component would leave a dangling trailing dot.
50+
export CS_VERSION="${subversion1}"."${subversion2}"
51+
export VERSION="${CS_VERSION}.${CS_MINOR_VERSION}"
4852
if [[ -n "$fourthversion" ]]; then
4953
export FULL_VERSION="${VERSION}.${fourthversion}"
5054
else

‎engine/schema/test_templateConfig.sh‎

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ assert_eq "legacy: VERSION" "4.22.0" "$VERSION"
5151
assert_eq "legacy: FULL_VERSION keeps the 4th (security) component" "4.22.0.0" "$FULL_VERSION"
5252

5353
getTemplateVersion "4.23.0.1-SNAPSHOT"
54+
assert_eq "legacy with -SNAPSHOT suffix: CS_VERSION" "4.23" "$CS_VERSION"
5455
assert_eq "legacy with -SNAPSHOT suffix: VERSION" "4.23.0" "$VERSION"
5556
assert_eq "legacy with -SNAPSHOT suffix: FULL_VERSION" "4.23.0.1" "$FULL_VERSION"
5657

@@ -62,16 +63,18 @@ assert_eq "legacy 3-component (no security): FULL_VERSION has no trailing dot" "
6263
# --- getTemplateVersion: new versioning (major >= 24, post-cutover) ---
6364

6465
getTemplateVersion "24.0.0"
65-
assert_eq "cutover: CS_VERSION" "24.0" "$CS_VERSION"
66-
assert_eq "cutover: VERSION" "24.0.0" "$VERSION"
66+
assert_eq "cutover: CS_VERSION (directory) is the major version" "24" "$CS_VERSION"
67+
assert_eq "cutover: VERSION (file names) is major.minor" "24.0" "$VERSION"
6768
assert_eq "cutover: FULL_VERSION has no trailing dot (patch dropped)" "24.0.0" "$FULL_VERSION"
6869

6970
getTemplateVersion "24.1.2-SNAPSHOT"
70-
assert_eq "cutover with -SNAPSHOT suffix: VERSION" "24.1.2" "$VERSION"
71+
assert_eq "cutover with -SNAPSHOT suffix: CS_VERSION" "24" "$CS_VERSION"
72+
assert_eq "cutover with -SNAPSHOT suffix: VERSION" "24.1" "$VERSION"
7173
assert_eq "cutover with -SNAPSHOT suffix: FULL_VERSION" "24.1.2" "$FULL_VERSION"
7274

7375
getTemplateVersion "99.9.9"
74-
assert_eq "future major: VERSION" "99.9.9" "$VERSION"
76+
assert_eq "future major: CS_VERSION" "99" "$CS_VERSION"
77+
assert_eq "future major: VERSION" "99.9" "$VERSION"
7578
assert_eq "future major: FULL_VERSION" "99.9.9" "$FULL_VERSION"
7679

7780
# A 4-component major.minor.patch.security value is invalid at/after the cutover (matches
@@ -96,7 +99,7 @@ run_create_metadata_file() {
9699
: > "$METADATAFILE"
97100

98101
createMetadataFile
99-
grep '^version = ' "$METADATAFILE" | head -1 | cut -d' ' -f3
102+
grep "^${2:-version} = " "$METADATAFILE" | head -1 | cut -d' ' -f3
100103

101104
rm -rf "$workdir"
102105
}
@@ -107,6 +110,26 @@ assert_eq "metadata.ini legacy 'version' line" "4.22.0.0" "$actual"
107110
actual="$(run_create_metadata_file "24.0.0")"
108111
assert_eq "metadata.ini cutover 'version' line has no trailing dot" "24.0.0" "$actual"
109112

113+
# --- createMetadataFile: file names, directory, template name and checksum ---
114+
115+
actual="$(run_create_metadata_file "4.22.0.0" downloadurl)"
116+
assert_eq "metadata.ini legacy downloadurl" "https://download.cloudstack.org/systemvm//4.22/systemvmtemplate-4.22.0-x86_64-kvm.qcow2.bz2" "$actual"
117+
actual="$(run_create_metadata_file "4.22.0.0" templatename)"
118+
assert_eq "metadata.ini legacy templatename" "systemvm-kvm-4.22.0-x86_64" "$actual"
119+
actual="$(run_create_metadata_file "4.22.0.0" checksum)"
120+
assert_eq "metadata.ini legacy checksum is found" "abc123" "$actual"
121+
122+
actual="$(run_create_metadata_file "24.0.0" downloadurl)"
123+
assert_eq "metadata.ini cutover downloadurl" "https://download.cloudstack.org/systemvm//24/systemvmtemplate-24.0-x86_64-kvm.qcow2.bz2" "$actual"
124+
actual="$(run_create_metadata_file "24.0.0" filename)"
125+
assert_eq "metadata.ini cutover filename" "systemvmtemplate-24.0-x86_64-kvm.qcow2.bz2" "$actual"
126+
actual="$(run_create_metadata_file "24.0.0" templatename)"
127+
assert_eq "metadata.ini cutover templatename" "systemvm-kvm-24.0-x86_64" "$actual"
128+
actual="$(run_create_metadata_file "24.0.0" checksum)"
129+
assert_eq "metadata.ini cutover checksum is found" "abc123" "$actual"
130+
actual="$(run_create_metadata_file "24.0.1" downloadurl)"
131+
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"
132+
110133
echo ""
111134
echo "${pass} passed, ${fail} failed"
112135
[[ $fail -eq 0 ]]

‎scripts/installer/export-templates.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ TEMPLATE_VERSION=$(awk -F "=" '/version/ {print $2}' ${IMAGE_PATH}${METADATA_FIL
2626
TEMPLATE_PATH="/usr/share/cloudstack-management/templates/systemvm/"
2727
TEMPLATE_MAJOR_VERSION="$(cut -d'.' -f1 <<<"$TEMPLATE_VERSION")"
2828
if [[ "$TEMPLATE_MAJOR_VERSION" -ge "$NEW_VERSIONING_CUTOVER_MAJOR_VERSION" ]]; then
29-
# New versioning (major.minor.security): the generated template files use the full version as-is.
30-
VERSION="${TEMPLATE_VERSION}"
29+
# New versioning (major.minor.security): the template files contain major.minor, without the security component.
30+
VERSION="$(cut -d'.' -f1,2 <<<"$TEMPLATE_VERSION")"
3131
else
3232
# Legacy versioning drops the trailing security component only for four-component metadata;
3333
# a valid three-component major.minor.patch value is already the filename version.

0 commit comments

Comments
 (0)