f-82: e2e: image des VM de test choisie par VM_IMAGE #82
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
2e7a6568ae
commit
0be5983b86
4 changed files with 67 additions and 3 deletions
|
|
@ -1,8 +1,22 @@
|
|||
set -u
|
||||
API=http://127.0.0.1:8080
|
||||
IMAGE_URL=https://cloud.debian.org/images/cloud/bookworm/latest
|
||||
IMAGE_FILE=debian-12-genericcloud-amd64.qcow2
|
||||
TWO_IMAGE=/var/tmp/deb-two.qcow2
|
||||
VM_IMAGE="${VM_IMAGE:-debian12}"
|
||||
case "${VM_IMAGE}" in
|
||||
debian12)
|
||||
IMAGE_URL=https://cloud.debian.org/images/cloud/bookworm/latest
|
||||
IMAGE_FILE=debian-12-genericcloud-amd64.qcow2
|
||||
TWO_IMAGE=/var/tmp/deb-two.qcow2
|
||||
;;
|
||||
rocky10)
|
||||
IMAGE_DIR=/var/tmp/two-images
|
||||
IMAGE_FILE=rocky10.qcow2
|
||||
TWO_IMAGE=/var/tmp/rocky10-two.qcow2
|
||||
;;
|
||||
*)
|
||||
echo "VM_IMAGE inconnue : ${VM_IMAGE} (debian12, rocky10)" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
VM_KEY=/root/.ssh/lab-vm
|
||||
VOLUMES=/var/lib/two/volumes
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,22 @@
|
|||
two_image () {
|
||||
[ -f "${TWO_IMAGE}" ] && return 0
|
||||
case "${VM_IMAGE}" in
|
||||
rocky10) two_image_built ;;
|
||||
*) two_image_debian ;;
|
||||
esac
|
||||
}
|
||||
|
||||
two_image_built () {
|
||||
local want got
|
||||
[ -f "${IMAGE_DIR}/${IMAGE_FILE}" ] || { echo "image: ${IMAGE_DIR}/${IMAGE_FILE} absente, à déposer depuis two-images" >&2; return 1; }
|
||||
want=$(awk -v f="${IMAGE_FILE}" '$2 == f {print $1}' "${IMAGE_DIR}/SHA512SUMS")
|
||||
[ -n "${want}" ] || { echo "image: ${IMAGE_FILE} absente de ${IMAGE_DIR}/SHA512SUMS" >&2; return 1; }
|
||||
got=$(sha512sum < "${IMAGE_DIR}/${IMAGE_FILE}" | cut -d' ' -f1) || return 1
|
||||
[ "${got}" = "${want}" ] || { echo "image: somme SHA-512 incorrecte" >&2; return 1; }
|
||||
cp "${IMAGE_DIR}/${IMAGE_FILE}" "${TWO_IMAGE}.part" && mv "${TWO_IMAGE}.part" "${TWO_IMAGE}"
|
||||
}
|
||||
|
||||
two_image_debian () {
|
||||
local work
|
||||
work=$(mktemp -d)
|
||||
curl -fsSL -o "${work}/${IMAGE_FILE}" "${IMAGE_URL}/${IMAGE_FILE}" || return 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue