diff --git a/test/vm-cluster/.gitignore b/test/vm-cluster/.gitignore index 31bb52e5..596199cf 100644 --- a/test/vm-cluster/.gitignore +++ b/test/vm-cluster/.gitignore @@ -1 +1,3 @@ -cfg \ No newline at end of file +cfg +vmpass.txt +iplist.txt \ No newline at end of file diff --git a/test/vm-cluster/cluster.sh b/test/vm-cluster/cluster.sh index 80c1367f..4ddbbdb7 100755 --- a/test/vm-cluster/cluster.sh +++ b/test/vm-cluster/cluster.sh @@ -1,6 +1,6 @@ #!/bin/bash -vmpass="" -vmips=(ip list) +vmpass=$(cat vmpass.txt) +readarray -t vmips < iplist.txt vmcount=${#vmips[@]} mode=$1 @@ -11,7 +11,7 @@ if [ "$mode" = "new" ] || [ "$mode" = "run" ] || [ "$mode" = "update" ]; then echo "" else echo "Invalid command. new | run | update expected." - exit + exit 1 fi if [ $mode = "run" ]; then @@ -27,7 +27,19 @@ for (( i=0; i<$vmcount; i++ )) do vmip=${vmips[i]} let n=$i+1 - /bin/bash ./setup-vm.sh $mode $n $vmpass $vmip $hpcore + /bin/bash ./setup-vm.sh $mode $n $vmpass $vmip $hpcore & +done + +wait + +if [ $mode = "update" ]; then + exit 0 +fi + +for (( i=0; i<$vmcount; i++ )) +do + vmip=${vmips[i]} + let n=$i+1 # Collect each node's pub key and peer address. pubkeys[i]=$(node -p "require('./cfg/node$n.json').pubkeyhex") diff --git a/test/vm-cluster/vm-clustercreate.sh b/test/vm-cluster/vm-clustercreate.sh new file mode 100755 index 00000000..5ce8e222 --- /dev/null +++ b/test/vm-cluster/vm-clustercreate.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +name=temp +locs=(ukwest eastus) +loccount=${#locs[@]} + +for (( i=0; i<$loccount; i++ )) +do + loc=${locs[i]} + let n=$i+1 + /bin/bash ./vmcreate.sh $name$n $loc +done \ No newline at end of file diff --git a/test/vm-cluster/vmcreate.sh b/test/vm-cluster/vmcreate.sh index b530b289..6cfd3b6f 100755 --- a/test/vm-cluster/vmcreate.sh +++ b/test/vm-cluster/vmcreate.sh @@ -7,7 +7,14 @@ name=$1 loc=$2 -vmpass="" -az vm create --name $name --resource-group HotPocket-ResGroup --size Standard_B1s --admin-username geveo --admin-password $vmpass --image UbuntuLTS --location $loc --generate-ssh-keys -az vm open-port --resource-group HotPocket-ResGroup --name $name --port 22860 --priority 900 && \ -az vm open-port --resource-group HotPocket-ResGroup --name $name --port 8080 --priority 901 +vmsize=Standard_B1ls +vmpass=$(cat vmpass.txt) +resgroup=HotPocket-ResGroup + +az vm create --name $name --resource-group $resgroup --size $vmsize --admin-username geveo --admin-password $vmpass --image UbuntuLTS --location $loc --generate-ssh-keys +az vm open-port --resource-group $resgroup --name $name --port 22860 --priority 900 && \ +az vm open-port --resource-group $resgroup --name $name --port 8080 --priority 901 + +vmip=$(az vm show -d -g $resgroup -n $name --query publicIps -o tsv) +echo $vmip >> iplist.txt +echo $vmip "created and added to iplist.txt" \ No newline at end of file