Add examples with kubevirt
* Add helpers to install kubevirt and its dependencies
* Add examples how to use kubevirt
Related-Prod: PRODX-3456
Change-Id: I3ade65df5f8ddff39f35605104851833d74690a1
diff --git a/kubevirt/examples/lib.sh b/kubevirt/examples/lib.sh
new file mode 100644
index 0000000..0a72d48
--- /dev/null
+++ b/kubevirt/examples/lib.sh
@@ -0,0 +1,31 @@
+function wait_vm_state {
+ local vm_name=$1
+ local state=$2
+ i=1
+ while [[ $(kubectl get vm ${vm_name} -o jsonpath="{.status.printableStatus}") != ${state} ]]; do
+ echo "Waiting VM ${vm_name} status ${state}. Attempt ${i}"
+ i=$(( i + 1 ))
+ sleep 5
+ done
+}
+
+function wait_vmsnapshot_state {
+ local snapshot_name=$1
+ local state=$2
+ i=1
+ while [[ $(kubectl get vmsnapshot ${snapshot_name} -o jsonpath="{.status.phase}") != ${state} ]]; do
+ echo "Waiting vmsnapshot ${snapshot_name} phase is ${state}. Attempt ${i}"
+ i=$(( i + 1 ))
+ sleep 5
+ done
+}
+
+function wait_vmrestore_completed {
+ local restore_name=$1
+ i=1
+ while [[ $(kubectl get vmrestore ${restore_name} -o jsonpath="{.status.complete}") != "true" ]]; do
+ echo "Waiting vmrestore ${restore_name} is completed. Attempt ${i}"
+ i=$(( i + 1 ))
+ sleep 5
+ done
+}