blob: 6078a57f63711afeff3a35d04cb432fbc58ee86e [file] [log] [blame]
Vasyl Saienko775c1da2023-07-13 11:34:25 +00001EXAMPLES_DIR=$(cd $(dirname "$0")/.. && pwd)
2WORKDIR=$(cd $(dirname "$0") && pwd)
3
4TMP_DIR=$(cd $(dirname "$0")/../../.workdir/ && pwd)
5source ${EXAMPLES_DIR}/lib.sh
6
7command=$1
8
9function run {
10 echo "Downloading cirros"
11 if [[ ! -f ${TMP_DIR}/cirros-0.6.2-x86_64-disk.img ]]; then
12 wget https://download.cirros-cloud.net/0.6.2/cirros-0.6.2-x86_64-disk.img -O ${TMP_DIR}/cirros-0.6.2-x86_64-disk.img
13 fi
14
15 echo "Uploading cirros to PVC."
16 UPLOADPROXY_URL=https://$(kubectl get nodes -o wide| tail -1 | awk '{print $6}'):31119
17 virtctl image-upload pvc cirros-cdi-pvc --size 5G --image-path=${TMP_DIR}/cirros-0.6.2-x86_64-disk.img --insecure --uploadproxy-url ${UPLOADPROXY_URL}
18
19 kubectl get pvc
20 kubectl get pods
21
22 echo "Creating VM"
23 kubectl apply -f cirros.yaml
24
25 echo "Starting VM"
26 virtctl start cirros-cdi-pvc
27
28 echo "Waiting VM is Running."
29 wait_vm_state cirros-cdi-pvc Running
30}
31
32function cleanup {
33 kubectl delete -f cirros.yaml
34 kubectl delete datavolume cirros-cdi-pvc
35 kubectl delete pvc cirros-cdi-pvc
36}
37
38pushd $WORKDIR
39$command
40popd