'Filter hosts with access to at least one segment.
:returns: a subset of candidate_hosts.
This method returns all hosts from candidate_hosts with access to a
segment according to at least one driver.'

def filter_hosts_with_segment_access(self, context, segments, candidate_hosts, agent_getter):

    candidate_hosts = set(candidate_hosts)
    if (not self.host_filtering_supported):
        return candidate_hosts
    hosts_with_access = set()
    for driver in self.ordered_mech_drivers:
        hosts = driver.obj.filter_hosts_with_segment_access(context, segments, candidate_hosts, agent_getter)
        hosts_with_access |= hosts
        candidate_hosts -= hosts
        if (not candidate_hosts):
            break
    return hosts_with_access
