版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处!
文件 nova/scheduler/filter_scheduler.py
class FilterScheduler(driver.Scheduler)
->def schedule_run_instance
->self._schedule
->_schedule
->least_cost.weighted_sum
文件nova/schedul/least_cost.py
def weighted_sum
.........................
for host_state in host_states:
score = sum(weight * fn(host_state, weighing_properties)
for weight, fn in weighted_fns)
if min_score is None or score < min_score:
min_score, best_host = score, host_state
return WeightedHost(min_score, host_state=best_host)
每种调度策略给不同的权重,使用不同的调度策略根据物理主机的状态计算一个得分,得分与权重做乘运算,然后所有调度策略得分相加,计算出一个物理主机的和值,根据此值进行虚拟机实例的创建调度。