code: def get_hosts_from_hostgroups(hgname, hostgroups):
          
          if not isinstance(hgname, list):
              hgname = [e.strip() for e in hgname.split(',') if e.strip()]
  
          host_names = []
  
          for name in hgname:
              hostgroup = hostgroups.find_by_name(name)
              if hostgroup is None:
                  raise ValueError("the hostgroup '%s' is unknown" % hgname)
              mbrs = [h.strip() for h in hostgroup.get_hosts() if h.strip()]
              host_names.extend(mbrs)
          return host_names
docs: Get hosts of hostgroups
  
          :param hgname: hostgroup name
          :type hgname: str
          :param hostgroups: hostgroups object (all hostgroups)
          :type hostgroups: alignak.objects.hostgroup.Hostgroups
          :return: list of hosts
          :rtype: list