Advertisement
marcoverl

IISAS-create-VM.sh

Jul 14th, 2016
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. #!/bin/sh
  2. export OCCIAPI=https://nova3.ui.savba.sk:8787/occi1.1
  3. case "$1" in
  4. del)
  5. VMID=$(occi --endpoint $OCCIAPI --auth x509 --voms --action list --resource compute)
  6. occi --endpoint $OCCIAPI --auth x509 --voms --action delete --resource $VMID
  7. echo VM $VMID has been destroyed
  8. ;;
  9. list)
  10. occi --endpoint $OCCIAPI --auth x509 --voms --action list --resource compute
  11. ;;
  12. images)
  13. occi --endpoint $OCCIAPI --auth x509 --voms --action describe --resource os_tpl
  14. ;;
  15. flavors)
  16. occi --endpoint $OCCIAPI --auth x509 --voms --action describe --resource resource_tpl
  17. ;;
  18. create)
  19. OS=$2
  20. [ -z "$2" ] && echo "Usage : $0 create centos7/ubuntu" && exit
  21. ##Centos7
  22. [ $OS == "centos7" ] && export OST=os_tpl#2509f4de-cd7f-422d-a12d-0355e1bfc68a
  23. ##Ubuntu 16
  24. [ $OS == "ubuntu" ] && export OST=os_tpl#72cf3fbe-cb6f-4238-9f0e-f651c80224fc
  25. ##flavor
  26. #gpu2cpu12:
  27. export RES=resource_tpl#e0b2b0a7-d2ee-4f0e-9b79-ea4f6435a532
  28. #gpu1cpu6:
  29. #export RES=resource_tpl#f0cd78ab-10a0-4350-a6cb-5f3fdd6e6294
  30. occi --endpoint $OCCIAPI --auth x509 --voms --action create -r compute -M $OST -M $RES --context user_data="file://$PWD/ansible_user_data_$OS" --attribute occi.core.title="GPU-VM"
  31. echo sleeping 10...
  32. sleep 10
  33. VMID=$(occi --endpoint $OCCIAPI --auth x509 --voms --action list --resource compute)
  34. echo sleeping 20
  35. sleep 20
  36. occi --endpoint $OCCIAPI --auth x509 --voms --action link --resource $VMID -j /occi1.1/network/PUBLIC
  37. NET=($(occi --endpoint $OCCIAPI --auth x509 --voms --action describe --resource compute | grep occi.networkinterface.address | awk '{print $3}'))
  38. echo connect via:
  39. echo ssh \$SSH_OPT -i ../tmpfedcloud $OS@${NET[1]}
  40. ;;
  41. ssh)
  42. OS=$2
  43. [ -z "$2" ] && echo "Usage : $0 ssh centos7/ubuntu" && exit
  44. NET=($(occi --endpoint $OCCIAPI --auth x509 --voms --action describe --resource compute | grep occi.networkinterface.address | awk '{print $3}'))
  45. echo connect via:
  46. echo ssh \$SSH_OPT -i ../tmpfedcloud $OS@${NET[1]}
  47. ;;
  48. *)
  49. echo this option does not exist!
  50. echo "Usage : $0 create|del|list|ssh centos7/ubuntu|flavors|images"
  51. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement