Blocks until instance is in desired_state.

def __WaitForInstance(instance, desired_state):
  """ Blocks until instance is in desired_state. """
  print 'Waiting for instance %s to change to %s' % (instance.id, desired_state)
  while True:
      try:
          instance.update()
          state = instance.state
          sys.stdout.write('.')
          sys.stdout.flush()
          if state == desired_state:
              break
      except boto_exception.EC2ResponseError as e:
          logging.info(e)
      #except boto_exception.ResponseError as e:  # This is an alias
      #    logging.info(e)
      time.sleep(5)  
  return