

def get_extended_cost_matrix(self, hosts, filter_properties):
    num_hosts = len(hosts)
    num_instances = filter_properties.get('num_instances')
    extended_cost_matrix = [[0 for j in xrange((num_instances + 1))] for i in xrange(num_hosts)]
    project_id = filter_properties['project_id']
    host_racks_map = solver_utils.get_host_racks_map(hosts)
    affinity_racks = set([])
    affinity_hosts = set([])
    for i in xrange(num_hosts):
        host_name = hosts[i].host
        host_racks = host_racks_map.get(host_name, set([]))
        if (project_id in hosts[i].projects):
            affinity_hosts.add(host_name)
            affinity_racks = affinity_racks.union(host_racks)
    for i in xrange(num_hosts):
        host_name = hosts[i].host
        host_racks = host_racks_map.get(host_name, set([]))
        if ((not any([(rack in affinity_racks) for rack in host_racks])) and (host_name not in affinity_hosts)):
            extended_cost_matrix[i] = [1 for j in xrange((num_instances + 1))]
        else:
            LOG.debug(_('%(host)s is in tenant affinity rack.'), {
                'host': host_name,
            })
    return extended_cost_matrix

dataset/ETHPy150Open openstack/nova-solver-scheduler/nova_solverscheduler/scheduler/solvers/costs/tenant_rack_affinity_cost.py TenantRackAffinityCost.get_extended_cost_matrix/original