code: def collect_hosts(api, wanted_hostnames):
    
    all_hosts = api.get_all_hosts(view='full')
    all_hostnames = set([ h.hostname for h in all_hosts])
    wanted_hostnames = set(wanted_hostnames)
  
    unknown_hosts = wanted_hostnames.difference(all_hostnames)
    if len(unknown_hosts) != 0:
      msg = "The following hosts are not found in Cloudera Manager. "\
            "Please check for typos:\n%s" % ('\n'.join(unknown_hosts))
      LOG.error(msg)
      raise RuntimeError(msg)
  
    return [ h for h in all_hosts if h.hostname in wanted_hostnames ]
docs: Return a list of ApiHost objects for the set of hosts that
    we want to change config for.