Last active
October 1, 2016 16:57
-
-
Save kvaps/41354aafdf008393f6cae2ddf06852d4 to your computer and use it in GitHub Desktop.
OpenNebula time restore hook, it tryes to restore time after vm back from SUSPEND state during 1 minute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# VM_HOOK = [ | |
# name = "time_restore", | |
# on = "RUNNING", | |
# state = "ACTIVE", | |
# lcm_state = "BOOT_SUSPENDED", | |
# command = "time_restore.sh", | |
# arguments = "$ID $TEMPLATE" ] | |
VM=one-$1 | |
ATTEMPT=12 | |
TIMEOUT=5 | |
TEMPLATE=$2 | |
HOSTNAME=($(echo $TEMPLATE | base64 -d | grep -oP '(?<=<HOSTNAME>).*(?=</HOSTNAME>)' | tail -n1)) | |
until [[ $ATTEMPT == 0 ]]; do | |
virsh --connect=qemu+ssh://$HOSTNAME/system domtime $VM --now && exit | |
sleep $TIMEOUT | |
ATTEMPT=$((ATTEMPT-1)) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment