#NEWLINE# def get_constraint_matrix( self , hosts , filter_properties ) : #NEWLINE# #INDENT# num_hosts = len ( hosts ) #NEWLINE# num_instances = filter_properties . get ( 'num_instances' ) #NEWLINE# constraint_matrix = [ [ True for j in xrange ( num_instances ) ] for i in xrange ( num_hosts ) ] #NEWLINE# pci_requests = filter_properties . get ( 'pci_requests' ) #NEWLINE# if ( not pci_requests ) : #NEWLINE# #INDENT# LOG . warn ( _LW ( 'PciPassthroughConstraint check is skipped because requested instance PCI requests is unavailable.' ) ) #NEWLINE# return constraint_matrix #NEWLINE# #UNINDENT# for i in xrange ( num_hosts ) : #NEWLINE# #INDENT# host_pci_stats = copy . deepcopy ( hosts [ i ] . pci_stats ) #NEWLINE# acceptable_num_instances = self . _get_acceptable_pci_requests_times ( num_instances , hosts , host_pci_stats ) #NEWLINE# if ( acceptable_num_instances < num_instances ) : #NEWLINE# #INDENT# inacceptable_num = ( num_instances - acceptable_num_instances ) #NEWLINE# constraint_matrix [ i ] = ( [ True for j in xrange ( acceptable_num_instances ) ] + [ False for j in xrange ( inacceptable_num ) ] ) #NEWLINE# #UNINDENT# LOG . debug ( '%(host)s can accept %(num)s requested instances according to PciPassthroughConstraint.' , { #NEWLINE# #INDENT# 'host' : hosts [ i ] , #NEWLINE# 'num' : acceptable_num_instances , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# return constraint_matrix