Skip to content

Commit

Permalink
Let's upload this
Browse files Browse the repository at this point in the history
  • Loading branch information
enolfc committed Aug 1, 2024
1 parent 2fb971b commit 6ae587e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ jobs:
sed -i -e "s/deploy_secret/$DEPLOY_OS_TOKEN/" clouds.yaml
# Another one for images
IMAGES_SITE="$(yq -r .clouds.deploy.site clouds.yaml)"
IMAGES_VO="$(yq -r .clouds.deploy.vo clouds.yaml)"
IMAGES_SITE="$(yq -r .clouds.images.site clouds.yaml)"
IMAGES_VO="$(yq -r .clouds.images.vo clouds.yaml)"
echo "IMAGES_SITE=$IMAGES_SITE" >> "$GITHUB_ENV"
IMAGES_OS_TOKEN="$(fedcloud openstack token issue --oidc-access-token "$ACCESS_OIDC_TOKEN" \
--site "$IMAGES_SITE" --vo "$IMAGES_VO" -j | jq -r '.[0].Result.id')"
Expand Down
14 changes: 11 additions & 3 deletions builder/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ FEDCLOUD_SECRET_LOCKER="$2"

# create a virtual env for fedcloudclient
python3 -m venv "$PWD/.venv"
PATH="$PWD/.venv/bin/pip:$PATH"
"$PWD/.venv/bin/pip" install fedcloudclient

mkdir -p /etc/openstack/
TMP_SECRETS="$(mktemp)"
"$PWD/.venv/bin/fedcloud" secret get --locker-token "$FEDCLOUD_SECRET_LOCKER" \
fedcloud secret get --locker-token "$FEDCLOUD_SECRET_LOCKER" \
deploy data >"$TMP_SECRETS" && mv "$TMP_SECRETS" /etc/openstack/clouds.yaml

systemctl start notify
Expand All @@ -26,6 +27,13 @@ packer plugins install github.com/hashicorp/qemu
packer plugins install github.com/hashicorp/ansible

if tools/build.sh "$IMAGE" >/var/log/image-build.log 2>&1; then
# upload the image is missing
echo "UPLOAD"
VM_NAME="$(jq -r ".builders[].vm_name" < "$IMAGE").ova"
pushd $(dirname "$IMAGE/output-qemu")
openstack --os-cloud images \
object create egi_endorsed_vas \
"$VM_NAME" >>/var/log/image-build.log
popd
echo "SUCCESSFUL BUILD - uploaded $VM_NAME" >>/var/log/image-build.log
fi

echo "BUILD ENDED" >>/var/log/image-build.log
14 changes: 5 additions & 9 deletions tools/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
# e.g. build.sh centos-7.json
set -e

template_dir="$(dirname "$1")"
pushd "$template_dir"
TEMPLATE_DIR="$(dirname "$1")"
pushd "$TEMPLATE_DIR"

TEMPLATE="$(basename "$1")"

# Create a temp ssh key that will be used to login to the VMs
SSH_KEY_DIR=$(mktemp -d)
Expand All @@ -19,12 +21,6 @@ done
# build with this key
packer build -var "SSH_PRIVATE_KEY_FILE=$SSH_KEY_DIR/key" \
-var "SSH_PUB_KEY=$(cat "$SSH_KEY_DIR/key.pub")" \
"$(basename "$1")"
"$TEMPLATE"

rm -rf "$SSH_KEY_DIR"

# convert to OVA
VM_NAME=$(jq -r ".builders[].vm_name" < "$1")

# Assume we are in the right location for the scripts to work
../tools/qcow2-to-ova.sh "$VM_NAME"

0 comments on commit 6ae587e

Please sign in to comment.