'Explodes services holding a `duplicate_foreach` clause.
:param hosts:   The hosts container
:param s:       The service to explode
:type s:        Service'

def explode_services_duplicates(self, hosts, s):

    hname = getattr(s, 'host_name', None)
    if (hname is None):
        return
    h = hosts.find_by_name(hname.strip())
    if (h is None):
        err = ('Error:    The    hostname    %s    is    unknown    for    the    service    %s!' % (hname, s.get_name()))
        s.configuration_errors.append(err)
        return
    for new_s in s.duplicate(h):
        if h.is_excluded_for(new_s):
            continue
        self.add_item(new_s)
