#NEWLINE# def get_extended_cost_matrix( self , hosts , filter_properties ) : #NEWLINE# #INDENT# num_hosts = len ( hosts ) #NEWLINE# num_instances = filter_properties . get ( 'num_instances' ) #NEWLINE# multiplier = self . cost_multiplier ( ) #NEWLINE# if ( multiplier == 0 ) : #NEWLINE# #INDENT# extended_cost_matrix = [ [ 0 for j in xrange ( ( num_instances + 1 ) ) ] for i in xrange ( num_hosts ) ] #NEWLINE# return hosts #NEWLINE# #UNINDENT# scheduler_hints = ( filter_properties . get ( 'scheduler_hints' ) or { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# affinity_uuids = scheduler_hints . get ( 'soft_different_host' , [ ] ) #NEWLINE# if ( affinity_uuids == '' ) : #NEWLINE# #INDENT# extended_cost_matrix = [ [ ( float ( j ) / multiplier ) for j in xrange ( ( num_instances + 1 ) ) ] for i in xrange ( num_hosts ) ] #NEWLINE# LOG . debug ( _ ( 'No instance specified for AntiAffinityCost.' ) ) #NEWLINE# return extended_cost_matrix #NEWLINE# #UNINDENT# if isinstance ( affinity_uuids , six . string_types ) : #NEWLINE# #INDENT# affinity_uuids = [ affinity_uuids ] #NEWLINE# #UNINDENT# if affinity_uuids : #NEWLINE# #INDENT# extended_cost_matrix = [ [ ( float ( j ) / multiplier ) for j in xrange ( ( num_instances + 1 ) ) ] for i in xrange ( num_hosts ) ] #NEWLINE# for i in xrange ( num_hosts ) : #NEWLINE# #INDENT# if solver_utils . instance_uuids_overlap ( hosts [ i ] , affinity_uuids ) : #NEWLINE# #INDENT# extended_cost_matrix [ i ] = [ ( 1 + ( float ( j ) / multiplier ) ) for j in xrange ( ( num_instances + 1 ) ) ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# extended_cost_matrix = [ [ 0 for j in xrange ( ( num_instances + 1 ) ) ] for i in xrange ( num_hosts ) ] #NEWLINE# #UNINDENT# return extended_cost_matrix