def numa_fit_instance_to_host(host_topology, instance_topology, limits=None, pci_requests=None, pci_stats=None):
 if (not (host_topology and instance_topology)):
  LOG.debug('Require both a host and instance NUMA topology to fit instance on host.')
  return
 elif (len(host_topology) < len(instance_topology)):
  LOG.debug('There are not enough NUMA nodes on the system to schedule the instance correctly. Required: %(required)s, actual: %(actual)s', {'required': len(instance_topology), 'actual': len(host_topology)})
  return
 for host_cell_perm in itertools.permutations(host_topology.cells, len(instance_topology)):
  cells = []
  for (host_cell, instance_cell) in zip(host_cell_perm, instance_topology.cells):
   try:
    got_cell = _numa_fit_instance_cell(host_cell, instance_cell, limits)
   except exception.MemoryPageSizeNotSupported:
    break
   if (got_cell is None):
    break
   cells.append(got_cell)
  if (len(cells) != len(host_cell_perm)):
   continue
  if ((not pci_requests) or ((pci_stats is not None) and pci_stats.support_requests(pci_requests, cells))):
   return objects.InstanceNUMATopology(cells=cells)

def numa_fit_instance_to_host ( host_topology , instance_topology , limits = None , pci_requests = None , pci_stats = None ) : if ( not ( host_topology and instance_topology ) ) : LOG . debug ( 'Require both a host and instance NUMA topology to fit instance on host.' ) return elif ( len ( host_topology ) < len ( instance_topology ) ) : LOG . debug ( 'There are not enough NUMA nodes on the system to schedule the instance correctly. Required: %(required)s, actual: %(actual)s' , { 'required' : len ( instance_topology ) , 'actual' : len ( host_topology ) } ) return for host_cell_perm in itertools . permutations ( host_topology . cells , len ( instance_topology ) ) : cells = [ ] for ( host_cell , instance_cell ) in zip ( host_cell_perm , instance_topology . cells ) : try : got_cell = _numa_fit_instance_cell ( host_cell , instance_cell , limits ) except exception . MemoryPageSizeNotSupported : break if ( got_cell is None ) : break cells . append ( got_cell ) if ( len ( cells ) != len ( host_cell_perm ) ) : continue if ( ( not pci_requests ) or ( ( pci_stats is not None ) and pci_stats . support_requests ( pci_requests , cells ) ) ) : return objects . InstanceNUMATopology ( cells = cells )
fit the instance topology onto the host topology .