def _WaitForExternalIp(self, instance_name):
    """Waits for the instance to get external IP and returns it.

    Args:
      instance_name: Name of the Compute Engine instance.
    Returns:
      External IP address in string.
    Raises:
      ClusterSetUpError: External IP assignment times out.
    """
    for _ in xrange(self.INSTANCE_IP_ADDRESS_MAX_CHECK_TIMES):
      instance = self._GetApi().GetInstance(instance_name)
      if instance:
        try:
          return instance['networkInterfaces'][0]['accessConfigs'][0]['natIP']
        except (__HOLE__, IndexError):
          pass
      time.sleep(self.INSTANCE_IP_ADDRESS_CHECK_INTERVAL)

    raise ClusterSetUpError('External IP address time out for %s' %
                            instance_name)
dataset/ETHPy150Open GoogleCloudPlatform/Data-Pipeline/app/src/hadoop/hadoop_cluster.py/HadoopCluster._WaitForExternalIp