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 ram
        instance_type = filter_properties.get('instance_type') or {}
        requested_ram = instance_type.get('memory_mb', 0)
        if 'memory_mb' not in instance_type:
            LOG.warn(_LW("No information about requested instances\' RAM size "
                    "was found, default value (0) is used."))
        if requested_ram <= 0:
            LOG.warn(_LW("ExactRamConstraint is skipped because requested "
                        "instance RAM size is 0 or invalid."))
            return constraint_matrix

        for i in xrange(num_hosts):
            if requested_ram == hosts[i].free_ram_mb:
                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_ram)s MB"
                          "RAM, it has %(usable_ram)s MB RAM.",
                          {'host': hosts[i],
                           'requested_ram': requested_ram,
                           'usable_ram': hosts[i].free_ram_mb})

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