def get_constraint_matrix(self, hosts, filter_properties):
        num_hosts = len(hosts)
        num_instances = filter_properties.get('num_instances')

        constraint_matrix = [[True for j in xrange(num_instances)]
                            for i in xrange(num_hosts)]

        # get requested vcpus
        instance_type = filter_properties.get('instance_type') or {}
        if not instance_type:
            return constraint_matrix
        else:
            instance_vcpus = instance_type['vcpus']
        if instance_vcpus <= 0:
            LOG.warn(_LW("ExactVcpuConstraint is skipped because requested "
                         "instance vCPU number is 0 or invalid."))
            return constraint_matrix

        for i in xrange(num_hosts):
            # get available vcpus
            if not hosts[i].vcpus_total:
                LOG.warn(_LW("vCPUs of %(host)s not set; assuming CPU "
                             "collection broken."), {'host': hosts[i]})
                constraint_matrix[i] = [False for j in xrange(num_instances)]
                continue
            else:
                usable_vcpus = hosts[i].vcpus_total - hosts[i].vcpus_used

            if instance_vcpus == usable_vcpus:
                constraint_matrix[i] = (
                        [True] + [False for j in xrange(num_instances - 1)])
            else:
                constraint_matrix[i] = [False for j in xrange(num_instances)]
                LOG.debug("%(host)s does not have exactly %(requested_num)s "
                          "vcpus, it has %(usable_num)s vcpus.",
                          {'host': hosts[i],
                           'requested_num': instance_vcpus,
                           'usable_num': usable_vcpus})

        return constraint_matrix
dataset/ETHPy150Open openstack/nova-solver-scheduler/nova_solverscheduler/scheduler/solvers/constraints/exact_vcpu_constraint.py/ExactVcpuConstraint.get_constraint_matrix/original