code: def explode_host_groups_into_hosts(self, item, hosts, hostgroups):
          
          hnames_list = []
          # Gets item's hostgroup_name
          hgnames = getattr(item, "hostgroup_name", '') or ''
  
          # Defines if hostgroup is a complex expression
          # Expands hostgroups
          if is_complex_expr(hgnames):
              hnames_list.extend(self.evaluate_hostgroup_expression(
                  item.hostgroup_name, hosts, hostgroups))
          elif hgnames:
              try:
                  hnames_list.extend(
                      self.get_hosts_from_hostgroups(hgnames, hostgroups))
              except ValueError as err:  # pragma: no cover, simple protection
                  item.add_error(str(err))
  
          # Expands host names
          hname = getattr(item, "host_name", '')
          hnames_list.extend([n.strip() for n in hname.split(',') if n.strip()])
          hnames = set()
  
          for host in hnames_list:
              # If the host start with a !, it's to be removed from
              # the hostgroup get list
              if host.startswith('!'):
                  hst_to_remove = host[1:].strip()
                  try:
                      hnames.remove(hst_to_remove)
                  except KeyError:
                      pass
              elif host == '*':
                  hnames.update([host.host_name for host
                                 in hosts.items.values() if getattr(host, 'host_name', '')])
              # Else it's a host to add, but maybe it's ALL
              else:
                  hnames.add(host)
  
          item.host_name = ','.join(hnames)
docs: Get all hosts of hostgroups and add all in host_name container
  
          :param item: the item object
          :type item: alignak.objects.item.Item
          :param hosts: hosts object
          :type hosts: alignak.objects.host.Hosts
          :param hostgroups: hostgroups object
          :type hostgroups: alignak.objects.hostgroup.Hostgroups
          :return: None