code: def is_crm_leader(resource, retry=False):
      
      if resource == DC_RESOURCE_NAME:
          return is_crm_dc()
      cmd = ['crm', 'resource', 'show', resource]
      try:
          status = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
          if not isinstance(status, six.text_type):
              status = six.text_type(status, "utf-8")
      except subprocess.CalledProcessError:
          status = None
  
      if status and get_unit_hostname() in status:
          return True
  
      if status and "resource %s is NOT running" % (resource) in status:
          raise CRMResourceNotFound("CRM resource %s not found" % (resource))
  
      return False
docs: Returns True if the charm calling this is the elected corosync leader,
      as returned by calling the external "crm" command.
  
      We allow this operation to be retried to avoid the possibility of getting a
      false negative. See LP #1396246 for more info.