From 871b3c6b7876db67f8a1019d4d557a9997289820 Mon Sep 17 00:00:00 2001 From: Enol Fernandez Date: Mon, 7 Oct 2024 11:34:12 +0100 Subject: [PATCH] Remove duplicated code --- builder/build-image.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/builder/build-image.sh b/builder/build-image.sh index 2582747..1796db2 100755 --- a/builder/build-image.sh +++ b/builder/build-image.sh @@ -53,14 +53,12 @@ if openstack --os-cloud images --os-token "$OS_TOKEN" \ else if tools/build.sh "$IMAGE" >/var/log/image-build.log 2>&1; then # compress the resulting image - QEMU_SOURCE_ID=$(hcl2tojson "$IMAGE" | jq -r '.source[0].qemu | keys[]') - VM_NAME=$(hcl2tojson "$IMAGE" | jq -r '.source[0].qemu.'"$QEMU_SOURCE_ID"'.vm_name') - QCOW_FILE="$VM_NAME.qcow2" - builder/refresh.sh vo.access.egi.eu "$(cat /var/tmp/egi/.refresh_token)" images - OS_TOKEN="$(yq -r '.clouds.images.auth.token' /etc/openstack/clouds.yaml)" OUTPUT_DIR="$(dirname "$IMAGE")/output-$QEMU_SOURCE_ID" cd "$OUTPUT_DIR" qemu-img convert -O qcow2 -c "$VM_NAME" "$QCOW_FILE" + # upload the image + builder/refresh.sh vo.access.egi.eu "$(cat /var/tmp/egi/.refresh_token)" images + OS_TOKEN="$(yq -r '.clouds.images.auth.token' /etc/openstack/clouds.yaml)" openstack --os-cloud images --os-token "$OS_TOKEN" \ object create egi_endorsed_vas "$QCOW_FILE" ls -lh "$QCOW_FILE"