def name_to_ip(name, data=None):
  """Do a DNS lookup using the Compute API.

  Args:
    name: instance name
    data: the result from calling getinstance, if the caller already has it.

  Returns:
    An IP address, unless some error is raised.
  """
  if name in ip_cache:
    return ip_cache[name]
  else:
    if data is None:
      try:
        data = api.get_instance(name)
      except __HOLE__:
        # This instance does not exist
        return None
    ip = data.networkInterfaces[0].accessConfigs[0].natIP
    ip_cache[name] = ip
    return ip
dataset/ETHPy150Open GoogleCloudPlatform/compute-hadoop-java-python/util.py/name_to_ip