def get_status(name):
  """Get the status of an instance.

  Args:
    name: Instance name

  Returns:
    A tuple (state, extra_info). extra_info is a string only used when the
    instance is broken somehow. This won't ever report HADOOP_READY; that's
    known when we start a Hadoop daemon ourselves.
  """
  # Do getinstance first. Trying to poke the agent on a STAGING box just times
  # out, so such stages are never observed otherwise
  try:
    data = api.get_instance(name)
    if data.status == 'RUNNING':
      # Now try talking to their agent
      address = name_to_ip(name, data=data) if cfg.ip_via_api else name
      response = talk_to_agent(address, '/status')
      if response is not None:
        state = response.get('state', '')
        if state == 'READY':
          return (InstanceState.SNITCH_READY, None)
        elif state != 'STARTING':
          msg = 'snitch reported {0}'.format(response['state'])
          logging.warn('%s: %s', name, msg)
          return (InstanceState.BROKEN, msg)
      return (InstanceState.RUNNING, None)
    elif data.status == 'PROVISIONING':
      return (InstanceState.PROVISIONING, None)
    elif data.status == 'STAGING':
      return (InstanceState.STAGING, None)
    else:
      msg = 'instance is {0}'.format(data.status)
      logging.warn('%s: %s', name, data.status)
      return (InstanceState.BROKEN, msg)
  except __HOLE__:
    return (InstanceState.NON_EXISTENT, None)


# Communication
dataset/ETHPy150Open GoogleCloudPlatform/compute-hadoop-java-python/util.py/get_status