def block_until_ssh_open(ipstring, wait_time=10, timeout=120):
 reached = False
 t_elapsed = 0
 while ((not reached) and (t_elapsed < timeout)):
  try:
   sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
   sock.connect((ipstring, 22))
   reached = True
  except socket.error as err:
   time.sleep(wait_time)
   t_elapsed += wait_time
 sock.close()

def block_until_ssh_open ( ipstring , wait_time = 10 , timeout = 120 ) : reached = False t_elapsed = 0 while ( ( not reached ) and ( t_elapsed < timeout ) ) : try : sock = socket . socket ( socket . AF_INET , socket . SOCK_STREAM ) sock . connect ( ( ipstring , 22 ) ) reached = True except socket . error as err : time . sleep ( wait_time ) t_elapsed += wait_time sock . close ( )
blocks until server at ipstring has an open port 22 .