code: def wait_for_ssh(ip):
    
    for _ in range(12):
      with safe_socket() as s:
        try:
          s.connect((ip, 22))
          return True
        except socket.timeout:
          pass
      time.sleep(10)
    return False
docs: Wait for SSH to be available at given IP address.