def compute_affinity(bench=[]):
    affinity = {}
    global hosts

    def acceptable_host(host_list, host):
        if (len(host_list) == 0):
            return True
        if host_list in host:
            return True
        return False

    for host in hosts.keys():
        hw = hosts[host].hw
        system_id = HL.get_value(hw, "system", "product", "serial")

        if len(bench) > 0:
            if acceptable_host(bench['affinity-hosts'], system_id) is False:
                continue

        if system_id not in affinity.keys():
            affinity[system_id] = [host]
        else:
            # If the system is already known, it means that several
            # virtual machines are sharing the same Hypervisor
            affinity[system_id].append(host)

    return affinity
dataset/ETHPy150Open redhat-cip/edeploy/src/health-server.py/compute_affinity/swapped operands of `in`