"git@developer.sourcefind.cn:OpenDAS/dgl.git" did not exist on "c5e8481cf303f0bb9f7002d98896ee2a50fe6db5"
Unverified Commit 6efee45c authored by zenlytix's avatar zenlytix Committed by GitHub
Browse files

Option to keep VM without incuring charges with shutdown command (#106)

* Update scripts to handle cases where you have other VMs in your sub

* Support subs with other VMs and fix for PDSH permission error

* Minor fix to support subs with other VMs

* Added shutdown with or without delete VM option

In Azure deallocate is like machine shutdown (and prevents billing). You can restart deallocated VM. To fully drop the VM delete is used. This command with "-d" option will fully delete the VM. Without any argument it justs deallocates / shutd down the VM.
parent cd0d6f3c
...@@ -6,6 +6,17 @@ if [ ! -f ${azure_config} ]; then ...@@ -6,6 +6,17 @@ if [ ! -f ${azure_config} ]; then
exit 1 exit 1
fi fi
delete=0
while getopts 'd' flag; do
case "${flag}" in
d) delete=1 ;;
*)
echo "Unexpected option ${flag}"
exit 1
;;
esac
done
num_vms=`cat ${azure_config} | jq .num_vms` num_vms=`cat ${azure_config} | jq .num_vms`
if [ $num_vms == "null" ]; then echo 'missing num_vms in config'; exit 1; fi if [ $num_vms == "null" ]; then echo 'missing num_vms in config'; exit 1; fi
location=`cat ${azure_config} | jq .location | sed 's/"//g'` location=`cat ${azure_config} | jq .location | sed 's/"//g'`
...@@ -16,8 +27,11 @@ resource_group=deepspeed_rg_$location ...@@ -16,8 +27,11 @@ resource_group=deepspeed_rg_$location
for i in `seq 0 $(( num_vms - 1))`; do for i in `seq 0 $(( num_vms - 1))`; do
vm_name=${base_vm_name}_$i vm_name=${base_vm_name}_$i
if [ $delete == 0 ]; then
echo "deallocating $vm_name" echo "deallocating $vm_name"
az vm deallocate --resource-group $resource_group --name $vm_name az vm deallocate --resource-group $resource_group --name $vm_name --no-wait
else
echo "deleting $vm_name" echo "deleting $vm_name"
az vm delete -y --resource-group $resource_group --name $vm_name az vm delete -y --resource-group $resource_group --name $vm_name --no-wait
fi
done done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment