def get_status(name):
  # 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 ValueError:
    return (InstanceState.NON_EXISTENT, None)


# Communication
Returns a view function decorator that checks to see if the domain
dataset/ETHPy150Open GoogleCloudPlatform/compute-hadoop-java-python/util.py/get_status--crossover with--dataset/ETHPy150Open dimagi/commcare-hq/corehq/toggles.py/StaticToggle.required_decorator