'Explodes a service based on a lis of hosts.
:param hosts:   The hosts container
:param s:       The base service to explode
:param hnames:  The host_name list to exlode sevice on'

def explode_services_from_hosts(self, hosts, s, hnames):

    duplicate_for_hosts = []
    not_hosts = []
    for hname in hnames:
        hname = hname.strip()
        if hname.startswith('!'):
            not_hosts.append(hname[1:])
        else:
            duplicate_for_hosts.append(hname)
    duplicate_for_hosts = list(set(duplicate_for_hosts))
    for hname in not_hosts:
        try:
            duplicate_for_hosts.remove(hname)
        except IndexError:
            pass
    for hname in duplicate_for_hosts:
        h = hosts.find_by_name(hname)
        if (h is None):
            err = ('Error:    The    hostname    %s    is    unknown    for    the    service    %s!' % (hname, s.get_name()))
            s.configuration_errors.append(err)
            continue
        if h.is_excluded_for(s):
            continue
        new_s = s.copy()
        new_s.host_name = hname
        self.add_item(new_s)
