def _get_cost_functions():
 cost_fns_conf = CONF.least_cost_functions
 if (cost_fns_conf is None):
  fn_str = 'nova.scheduler.least_cost.compute_fill_first_cost_fn'
  cost_fns_conf = [fn_str]
 cost_fns = []
 for cost_fn_str in cost_fns_conf:
  short_name = cost_fn_str.split('.')[(-1)]
  if (not (short_name.startswith('compute_') or short_name.startswith('noop'))):
   continue
  if cost_fn_str.startswith('nova.scheduler.least_cost.'):
   cost_fn_str = ('nova.scheduler.weights.least_cost' + cost_fn_str[25:])
  try:
   cost_fn = importutils.import_class(cost_fn_str)
  except ImportError:
   raise exception.SchedulerCostFunctionNotFound(cost_fn_str=cost_fn_str)
  try:
   flag_name = ('%s_weight' % cost_fn.__name__)
   weight = getattr(CONF, flag_name)
  except AttributeError:
   raise exception.SchedulerWeightFlagNotFound(flag_name=flag_name)
  if ((flag_name == 'compute_fill_first_cost_fn_weight') and (weight is None)):
   weight = (-1.0)
  cost_fns.append((weight, cost_fn))
 return cost_fns

def _get_cost_functions ( ) : cost_fns_conf = CONF . least_cost_functions if ( cost_fns_conf is None ) : fn_str = 'nova.scheduler.least_cost.compute_fill_first_cost_fn' cost_fns_conf = [ fn_str ] cost_fns = [ ] for cost_fn_str in cost_fns_conf : short_name = cost_fn_str . split ( '.' ) [ ( - 1 ) ] if ( not ( short_name . startswith ( 'compute_' ) or short_name . startswith ( 'noop' ) ) ) : continue if cost_fn_str . startswith ( 'nova.scheduler.least_cost.' ) : cost_fn_str = ( 'nova.scheduler.weights.least_cost' + cost_fn_str [ 25 : ] ) try : cost_fn = importutils . import_class ( cost_fn_str ) except ImportError : raise exception . SchedulerCostFunctionNotFound ( cost_fn_str = cost_fn_str ) try : flag_name = ( '%s_weight' % cost_fn . __name__ ) weight = getattr ( CONF , flag_name ) except AttributeError : raise exception . SchedulerWeightFlagNotFound ( flag_name = flag_name ) if ( ( flag_name == 'compute_fill_first_cost_fn_weight' ) and ( weight is None ) ) : weight = ( - 1.0 ) cost_fns . append ( ( weight , cost_fn ) ) return cost_fns
returns a list of tuples containing weights and cost functions to use for weighing hosts .