#!/bin/bash
echo $0 started at $(date)

. ./common-vars $@

for PARTICIPANT in `seq ${START} ${MAX}` ; do
  . ./openstack_credentials.rc PARTICIPANT
  VM_NAME=`expr charmedosm-${PARTICIPANT}`
  IP=`expr openstack server list --name $VM_NAME --column Networks -f yaml | head -3 | tail -1 | grep -o '[0-9]\+[.][0-9]\+[.][0-9]\+[.][0-9]\+'`
  scp -o StrictHostKeyChecking=no -i hackfest_rsa ./hackfest_rsa ./hackfest_rsa.pub ubuntu@${IP}:.ssh/ &
  scp -o StrictHostKeyChecking=no -i hackfest_rsa vm-microk8s-setup.sh ubuntu@${IP}: &
  ssh -o StrictHostKeyChecking=no -i hackfest_rsa ubuntu@${IP} "scp -o StrictHostKeyChecking=no -i .ssh/hackfest_rsa vm-microk8s-setup.sh 10.0.0.11:; ssh -o StrictHostKeyChecking=no -i .ssh/hackfest_rsa 10.0.0.11 ./vm-microk8s-setup.sh"  2>&1 | tee -a logs/vm-microk8s-setup-${PARTICIPANT}.log&
done
wait

echo $0 $@ complete at $(date)