Vasyl Saienko | 775c1da | 2023-07-13 11:34:25 +0000 | [diff] [blame] | 1 | function wait_vm_state { |
| 2 | local vm_name=$1 |
| 3 | local state=$2 |
| 4 | i=1 |
| 5 | while [[ $(kubectl get vm ${vm_name} -o jsonpath="{.status.printableStatus}") != ${state} ]]; do |
| 6 | echo "Waiting VM ${vm_name} status ${state}. Attempt ${i}" |
| 7 | i=$(( i + 1 )) |
| 8 | sleep 5 |
| 9 | done |
| 10 | } |
| 11 | |
| 12 | function wait_vmsnapshot_state { |
| 13 | local snapshot_name=$1 |
| 14 | local state=$2 |
| 15 | i=1 |
| 16 | while [[ $(kubectl get vmsnapshot ${snapshot_name} -o jsonpath="{.status.phase}") != ${state} ]]; do |
| 17 | echo "Waiting vmsnapshot ${snapshot_name} phase is ${state}. Attempt ${i}" |
| 18 | i=$(( i + 1 )) |
| 19 | sleep 5 |
| 20 | done |
| 21 | } |
| 22 | |
| 23 | function wait_vmrestore_completed { |
| 24 | local restore_name=$1 |
| 25 | i=1 |
| 26 | while [[ $(kubectl get vmrestore ${restore_name} -o jsonpath="{.status.complete}") != "true" ]]; do |
| 27 | echo "Waiting vmrestore ${restore_name} is completed. Attempt ${i}" |
| 28 | i=$(( i + 1 )) |
| 29 | sleep 5 |
| 30 | done |
| 31 | } |