Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- export OCCIAPI=https://nova3.ui.savba.sk:8787/occi1.1
- 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
- ##Centos7
- [ $OS == "centos7" ] && export OST=os_tpl#2509f4de-cd7f-422d-a12d-0355e1bfc68a
- ##Ubuntu 16
- [ $OS == "ubuntu" ] && export OST=os_tpl#72cf3fbe-cb6f-4238-9f0e-f651c80224fc
- ##flavor
- #gpu2cpu12:
- export RES=resource_tpl#e0b2b0a7-d2ee-4f0e-9b79-ea4f6435a532
- #gpu1cpu6:
- #export RES=resource_tpl#f0cd78ab-10a0-4350-a6cb-5f3fdd6e6294
- 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"
- echo sleeping 10...
- sleep 10
- VMID=$(occi --endpoint $OCCIAPI --auth x509 --voms --action list --resource compute)
- echo sleeping 20
- sleep 20
- occi --endpoint $OCCIAPI --auth x509 --voms --action link --resource $VMID -j /occi1.1/network/PUBLIC
- 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 ../tmpfedcloud $OS@${NET[1]}
- ;;
- ssh)
- OS=$2
- [ -z "$2" ] && echo "Usage : $0 ssh centos7/ubuntu" && exit
- 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 ../tmpfedcloud $OS@${NET[1]}
- ;;
- *)
- echo this option does not exist!
- echo "Usage : $0 create|del|list|ssh centos7/ubuntu|flavors|images"
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement