Skip to content

Commit

Permalink
Remove duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
enolfc committed Oct 7, 2024
1 parent 21ab1b5 commit 871b3c6
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions builder/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 871b3c6

Please sign in to comment.