def _numa_get_pagesize_constraints(flavor, image_meta):
 def check_and_return_pages_size(request):
  if (request == 'any'):
   return MEMPAGES_ANY
  elif (request == 'large'):
   return MEMPAGES_LARGE
  elif (request == 'small'):
   return MEMPAGES_SMALL
  else:
   try:
    request = int(request)
   except ValueError:
    try:
     request = (strutils.string_to_bytes(request, return_int=True) / units.Ki)
    except ValueError:
     request = 0
  if (request <= 0):
   raise exception.MemoryPageSizeInvalid(pagesize=request)
  return request
 (flavor_request, image_request) = _get_flavor_image_meta('mem_page_size', flavor, image_meta)
 if ((not flavor_request) and image_request):
  raise exception.MemoryPageSizeForbidden(pagesize=image_request, against='<empty>')
 if (not flavor_request):
  return None
 pagesize = check_and_return_pages_size(flavor_request)
 if (image_request and (pagesize in (MEMPAGES_ANY, MEMPAGES_LARGE))):
  return check_and_return_pages_size(image_request)
 elif image_request:
  raise exception.MemoryPageSizeForbidden(pagesize=image_request, against=flavor_request)
 return pagesize

def _numa_get_pagesize_constraints ( flavor , image_meta ) : def check_and_return_pages_size ( request ) : if ( request == 'any' ) : return MEMPAGES_ANY elif ( request == 'large' ) : return MEMPAGES_LARGE elif ( request == 'small' ) : return MEMPAGES_SMALL else : try : request = int ( request ) except ValueError : try : request = ( strutils . string_to_bytes ( request , return_int = True ) / units . Ki ) except ValueError : request = 0 if ( request <= 0 ) : raise exception . MemoryPageSizeInvalid ( pagesize = request ) return request ( flavor_request , image_request ) = _get_flavor_image_meta ( 'mem_page_size' , flavor , image_meta ) if ( ( not flavor_request ) and image_request ) : raise exception . MemoryPageSizeForbidden ( pagesize = image_request , against = '<empty>' ) if ( not flavor_request ) : return None pagesize = check_and_return_pages_size ( flavor_request ) if ( image_request and ( pagesize in ( MEMPAGES_ANY , MEMPAGES_LARGE ) ) ) : return check_and_return_pages_size ( image_request ) elif image_request : raise exception . MemoryPageSizeForbidden ( pagesize = image_request , against = flavor_request ) return pagesize
return the requested memory page size .