12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. . $(ffoom path)
  3. ffoo import pretty
  4. ffoo import recon
  5. FFOO_VERBOSE=${FFOO_VERBOSE:-true}
  6. usage() {
  7. usage_is "[--dry-run] [-c|--connection] domain [snapshot]"
  8. }
  9. DRY_RUN=false
  10. connection="qemu:///system"
  11. while true; do
  12. case $1 in
  13. -c|--connection)
  14. connection=$2
  15. shift 2
  16. ;;
  17. --dry-run)
  18. DRY_RUN=true
  19. shift 1
  20. ;;
  21. "")
  22. usage
  23. ;;
  24. --)
  25. shift 1
  26. break
  27. ;;
  28. *)
  29. break
  30. ;;
  31. esac
  32. done
  33. domain="$1"
  34. snapshot="$2"
  35. test -z "$snapshot" && {
  36. think "looking for $domain in revert.conf"
  37. snapshot=$(saturnin conf -1 -p revert.to.snapshot.$domain)
  38. }
  39. test -z "$snapshot" && {
  40. think "looking for default snapshot name in revert.conf"
  41. snapshot=$(saturnin conf -1 -p revert.to.snapshot._default_)
  42. }
  43. test -z "$snapshot" && {
  44. die "could not determine snapshot for $domain"
  45. }
  46. think "reverting $domain to $snapshot"
  47. debug "virsh -c "$connection" snapshot-revert $domain $snapshot"
  48. $DRY_RUN || virsh -c "$connection" snapshot-revert $domain $snapshot
  49. think "starting $domain"
  50. debug "virsh -c "$connection" start $domain"
  51. $DRY_RUN || virsh -c "$connection" start $domain