def numa_get_constraints(flavor, image_meta):

    nodes = flavor.get('extra_specs', {}).get("hw:numa_nodes")
    props = image_meta.properties
    if nodes is not None:
        if props.obj_attr_is_set("hw_numa_nodes"):
            raise exception.ImageNUMATopologyForbidden(
                name='hw_numa_nodes')
        nodes = int(nodes)
    else:
        nodes = props.get("hw_numa_nodes")

    pagesize = _numa_get_pagesize_constraints(
        flavor, image_meta)

    numa_topology = None
    if nodes or pagesize:
        nodes = nodes or 1

        cpu_list = _numa_get_cpu_map_list(flavor, image_meta)
        mem_list = _numa_get_mem_map_list(flavor, image_meta)

        # If one property list is specified both must be
        if ((cpu_list is None and mem_list is not None) or
            (cpu_list is not None and mem_list is None)):
            raise exception.ImageNUMATopologyIncomplete()

        # If any node has data set, all nodes must have data set
        if ((cpu_list is not None and len(cpu_list) != nodes) or
            (mem_list is not None and len(mem_list) != nodes)):
            raise exception.ImageNUMATopologyIncomplete()

        if cpu_list is None:
            numa_topology = _numa_get_constraints_auto(
                nodes, flavor)
        else:
            numa_topology = _numa_get_constraints_manual(
                nodes, flavor, cpu_list, mem_list)

        # We currently support same pagesize for all cells.
        [setattr(c, 'pagesize', pagesize) for c in numa_topology.cells]

    return _add_cpu_pinning_constraint(flavor, image_meta, numa_topology)
Return topology related to input request
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/virt/hardware.py/numa_get_constraints