kayrus / deploy-vm

Libvirt wrapper to spawn VMs using cloud images
GNU General Public License v2.0
59 stars 19 forks source link

Add wait time for the cluster up and ready #6

Closed kayrus closed 7 years ago

kayrus commented 8 years ago

while true ping, etc.

kayrus commented 8 years ago

while true; do ping -n -c1 coreos1 && break; done

kayrus commented 8 years ago
TRY=0
while true; do
  TRY=$((TRY+1))
  if [ $TRY -gt $MAX_SSH_TRIES ]; then
    echo "Can not connect to ssh, exiting..."
    exit 1
  fi
  echo "Trying to connect to VM, #${TRY} of #${MAX_SSH_TRIES}..."
  set +e
  RES=$(ssh -l core -o ConnectTimeout=1 -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p $SSH_PORT -i ~/.ssh/id_rsa 127.0.0.1 "true" 2>&1)
  RES_CODE=$?
  set -e
  if [ $RES_CODE -eq 0 ]; then
    break
  else
    echo "$RES" | grep -q "Connection refused" && sleep 1 || true
  fi
done