#!/bin/sh set -e # Temporary directory for tests to use. AYA_TMPDIR="$(pwd)/.tmp" # Directory for VM images AYA_IMGDIR=${AYA_TMPDIR} # Test Architecture if [ -z "${AYA_TEST_ARCH}" ]; then AYA_TEST_ARCH="$(uname -m)" fi # Test Image if [ -z "${AYA_TEST_IMAGE}" ]; then AYA_TEST_IMAGE="fedora37" fi case "${AYA_TEST_IMAGE}" in fedora*) AYA_SSH_USER="fedora";; centos*) AYA_SSH_USER="centos";; esac download_images() { mkdir -p "${AYA_IMGDIR}" case $1 in fedora37) if [ ! -f "${AYA_IMGDIR}/fedora37.${AYA_TEST_ARCH}.qcow2" ]; then IMAGE="Fedora-Cloud-Base-37-1.7.${AYA_TEST_ARCH}.qcow2" IMAGE_URL="https://download.fedoraproject.org/pub/fedora/linux/releases/37/Cloud/${AYA_TEST_ARCH}/images" echo "Downloading: ${IMAGE}, this may take a while..." curl -o "${AYA_IMGDIR}/fedora37.${AYA_TEST_ARCH}.qcow2" -sSL "${IMAGE_URL}/${IMAGE}" fi ;; centos8) if [ ! -f "${AYA_IMGDIR}/centos8.${AYA_TEST_ARCH}.qcow2" ]; then IMAGE="CentOS-8-GenericCloud-8.4.2105-20210603.0.${AYA_TEST_ARCH}.qcow2" IMAGE_URL="https://cloud.centos.org/centos/8/${AYA_TEST_ARCH}/images" echo "Downloading: ${IMAGE}, this may take a while..." curl -o "${AYA_IMGDIR}/centos8.${AYA_TEST_ARCH}.qcow2" -sSL "${IMAGE_URL}/${IMAGE}" fi ;; *) echo "$1 is not a recognized image name" return 1 ;; esac } start_vm() { download_images "${AYA_TEST_IMAGE}" # prepare config cat > "${AYA_TMPDIR}/metadata.yaml" < "${AYA_TMPDIR}/user-data.yaml" < "${AYA_TMPDIR}/ssh_config" <