def _numa_cell_supports_pagesize_request(host_cell, inst_cell):
 avail_pagesize = [page.size_kb for page in host_cell.mempages]
 avail_pagesize.sort(reverse=True)
 def verify_pagesizes(host_cell, inst_cell, avail_pagesize):
  inst_cell_mem = (inst_cell.memory * units.Ki)
  for pagesize in avail_pagesize:
   if host_cell.can_fit_hugepages(pagesize, inst_cell_mem):
    return pagesize
 if (inst_cell.pagesize == MEMPAGES_SMALL):
  return verify_pagesizes(host_cell, inst_cell, avail_pagesize[(-1):])
 elif (inst_cell.pagesize == MEMPAGES_LARGE):
  return verify_pagesizes(host_cell, inst_cell, avail_pagesize[:(-1)])
 elif (inst_cell.pagesize == MEMPAGES_ANY):
  return verify_pagesizes(host_cell, inst_cell, avail_pagesize)
 else:
  return verify_pagesizes(host_cell, inst_cell, [inst_cell.pagesize])

def _numa_cell_supports_pagesize_request ( host_cell , inst_cell ) : avail_pagesize = [ page . size_kb for page in host_cell . mempages ] avail_pagesize . sort ( reverse = True ) def verify_pagesizes ( host_cell , inst_cell , avail_pagesize ) : inst_cell_mem = ( inst_cell . memory * units . Ki ) for pagesize in avail_pagesize : if host_cell . can_fit_hugepages ( pagesize , inst_cell_mem ) : return pagesize if ( inst_cell . pagesize == MEMPAGES_SMALL ) : return verify_pagesizes ( host_cell , inst_cell , avail_pagesize [ ( - 1 ) : ] ) elif ( inst_cell . pagesize == MEMPAGES_LARGE ) : return verify_pagesizes ( host_cell , inst_cell , avail_pagesize [ : ( - 1 ) ] ) elif ( inst_cell . pagesize == MEMPAGES_ANY ) : return verify_pagesizes ( host_cell , inst_cell , avail_pagesize ) else : return verify_pagesizes ( host_cell , inst_cell , [ inst_cell . pagesize ] )
determine whether the cell can accept the request .