Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- export OCCIAPI=https://carach5.ics.muni.cz:11443/
- case "$1" in
- del)
- VMID=$(occi --endpoint $OCCIAPI --auth x509 --voms --action list --resource compute)
- occi --endpoint $OCCIAPI --auth x509 --voms --action delete --resource $VMID
- echo VM $VMID has been destroyed
- ;;
- list)
- occi --endpoint $OCCIAPI --auth x509 --voms --action list --resource compute
- ;;
- images)
- occi --endpoint $OCCIAPI --auth x509 --voms --action describe --resource os_tpl
- ;;
- flavors)
- occi --endpoint $OCCIAPI --auth x509 --voms --action describe --resource resource_tpl
- ;;
- create)
- OS=$2
- [ -z "$2" ] && echo "Usage : $0 create centos7/ubuntu" && exit
- [ $OS == "centos7" ] && export OST=os_tpl#uuid_enmr_gpgpu_centos_7_cerit_sc_185
- [ $OS == "ubuntu" ] && export OST=os_tpl#uuid_enmr_gpgpu_egi_ubuntu_server_14_04_lts_cerit_sc_168
- occi --endpoint $OCCIAPI --auth x509 --voms --action create -r compute -M $OST --context user_data="file://$PWD/ansible_user_data_$OS" --attribute occi.core.title="GPU-VM"
- echo sleeping 10...
- sleep 10
- VMID=$(occi --endpoint $OCCIAPI --auth x509 --voms --action list --resource compute)
- NET=($(occi --endpoint $OCCIAPI --auth x509 --voms --action describe --resource compute | grep occi.networkinterface.address | awk '{print $3}'))
- echo connect via:
- echo ssh \$SSH_OPT -i yoursshkey $OS@${NET[@]}
- ;;
- ssh)
- NET=($(occi --endpoint $OCCIAPI --auth x509 --voms --action describe --resource compute | grep occi.networkinterface.address | awk '{print $3}'))
- echo connect via:
- echo ssh \$SSH_OPT -i yoursshkey $2@${NET[@]}
- ;;
- *)
- echo this option does not exist!
- echo "Usage : $0 create|del|list|ssh|flavors|images"
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement