Last active
September 26, 2019 12:27
-
-
Save ticapix/fbf696491484f9a267a78f498c3c3854 to your computer and use it in GitHub Desktop.
start / stop / getip from a VM on OVH Public Cloud. (default vm flavor is t1-45)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
. ./openrc.sh # download this config file from the api or the manager | |
for var in OS_AUTH_URL OS_IDENTITY_API_VERSION OS_TENANT_ID OS_USERNAME OS_PASSWORD OS_REGION_NAME; do | |
[ -z $( eval "echo \$$var" ) ] && (echo "Variable $var is undefined."; exit 1) | |
done | |
which openstack > /dev/null || (echo "Missing openstack. Install python-openstackclient"; exit 1) | |
action=$1 | |
vm=${2:-mygpuvm} | |
FLAVOR="t1-45" | |
echo "Action: $action $vm" | |
case $action in | |
"start") | |
openstack keypair show $vm > /dev/null || openstack keypair create $vm > $vm.pem | |
openstack server show $vm > /dev/null || openstack server create --key-name $vm --image 'NVIDIA GPU Cloud (NGC)' --flavor $FLAVOR --network Ext-Net $vm | |
;; | |
"stop") | |
openstack server show $vm > /dev/null && openstack server delete $vm | |
;; | |
"getip") | |
openstack server show $vm -f shell | grep "^addresses=" | |
;; | |
*) | |
echo "$0 [start|stop|getip] (<vmname>)" | |
exit 1 | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment