Manage a pool of nodes for a distributed test infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fake-image-create 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #!/bin/bash
  2. outfile=
  3. outtypes=("qcow2")
  4. all_args=$*
  5. logfile=
  6. checksum=
  7. no_tmpfs=
  8. qemu_img_options=
  9. x=
  10. TEMP=$(getopt -o xo:t: --long qemu-img-options:,no-tmpfs,checksum,logfile: -- "$@")
  11. if [ $? -ne 0 ]; then
  12. echo "Invalid option"
  13. exit 1
  14. fi
  15. eval set -- "$TEMP"
  16. while true ; do
  17. case "$1" in
  18. --checksum)
  19. checksum=1; shift 1;;
  20. --no-tmpfs)
  21. no_tmpfs=1; shift 1;;
  22. --qemu-img-options)
  23. qemu_img_options=$2; shift 2;;
  24. --logfile)
  25. logfile=$2; shift 2;;
  26. -o) outfile=$2; shift 2;;
  27. -t) IFS="," read -a outtypes <<< "$2"; shift 2;;
  28. -x) x=1; shift;;
  29. --) shift ; break ;;
  30. *) echo "Unknown option : $1"; exit 1;;
  31. esac
  32. done
  33. # If --logfile was given, direct stdout to it, as well
  34. if [ ! -z "$logfile" ]; then
  35. exec > >(tee -a ${logfile})
  36. fi
  37. echo "*** fake-image-create: start"
  38. echo "arguments:"
  39. echo "----"
  40. echo "$all_args"
  41. echo "----"
  42. if [[ "${SHOULD_FAIL}" == 'true' ]]; then
  43. echo "Should fail is set, exiting with status 127"
  44. exit 127
  45. fi
  46. if [[ "${DIB_RELEASE}" != "21" ]]; then
  47. echo "DIB_RELEASE not set correctly"
  48. exit 1
  49. fi
  50. # test passing of real-life env-vars
  51. if [[ "${TMPDIR}" != "/opt/dib_tmp" ]]; then
  52. echo "TMPDIR not set"
  53. exit 1
  54. fi
  55. if [[ "${DIB_IMAGE_CACHE}" != "/opt/dib_cache" ]]; then
  56. echo "DIB_IMAGE_CACHE not set"
  57. exit 1
  58. fi
  59. if [[ "${DIB_CLOUD_IMAGES}" != "http://download.fedoraproject.org/pub/fedora/linux/releases/test/21-Beta/Cloud/Images/x86_64/" ]]; then
  60. echo "DIB_CLOUD_IMAGES not set"
  61. exit 1
  62. fi
  63. if [[ "${BASE_IMAGE_FILE}" != "Fedora-Cloud-Base-20141029-21_Beta.x86_64.qcow2" ]]; then
  64. echo "BASE_IMAGE_FILE not set"
  65. exit 1
  66. fi
  67. if [ ! -z "$logfile" ]; then
  68. echo " -> logfile: $logfile"
  69. fi
  70. if [ ! -z "$checksum" ]; then
  71. echo " -> set --checksum"
  72. fi
  73. if [ ! -z "$no_tmpfs" ]; then
  74. echo " -> set --no-tmpfs"
  75. fi
  76. if [ ! -z "$qemu_img_options" ]; then
  77. echo " -> qemu-img-options: $qemu_img_options"
  78. fi
  79. if [ ! -z "$x" ]; then
  80. echo " -> debugging enabled"
  81. fi
  82. if [ -z "$outfile" ]; then
  83. echo "No output file specified."
  84. exit 1
  85. else
  86. for outtype in ${outtypes[@]} ; do
  87. echo "fake-data" > $outfile.$outtype
  88. echo "10da41d43d4bd6d67db763616c18b72f" > $outfile.$outtype.md5
  89. echo "0033e9d444953d11689b5fa6a6dba32bf901582f62b0825bc35f593190b1f7dc" > $outfile.$outtype.sha256
  90. done
  91. fi
  92. # Emulate manifest creation
  93. mkdir $outfile.d
  94. echo "*** fake-image-create: done"