This Page

Psst... hey. You're reading the latest content, but it might be out of sync with code. You can read Nova 2011.2 docs or all OpenStack docs too.

The nova.scheduler.least_cost Module

Least Cost Scheduler is a mechanism for choosing which host machines to provision a set of resources to. The input of the least-cost-scheduler is a set of objective-functions, called the ‘cost-functions’, a weight for each cost-function, and a list of candidate hosts (gathered via FilterHosts).

The cost-function and weights are tabulated, and the host with the least cost is then selected for provisioning.

class nova.scheduler.least_cost.LeastCostScheduler(*args, **kwargs)

Bases: nova.scheduler.base_scheduler.BaseScheduler

get_cost_fns(topic)

Returns a list of tuples containing weights and cost functions to use for weighing hosts

weigh_hosts(topic, request_spec, hosts)

Returns a list of dictionaries of form: [ {weight: weight, hostname: hostname, capabilities: capabs} ]

nova.scheduler.least_cost.compute_fill_first_cost_fn(host)

Prefer hosts that have less ram available, filter_hosts will exclude hosts that don’t have enough ram.

nova.scheduler.least_cost.noop_cost_fn(host)

Return a pre-weight cost of 1 for each host

nova.scheduler.least_cost.normalize_list(L)

Normalize an array of numbers such that each element satisfies: 0 <= e <= 1

nova.scheduler.least_cost.weighted_sum(domain, weighted_fns, normalize=True)

Use the weighted-sum method to compute a score for an array of objects. Normalize the results of the objective-functions so that the weights are meaningful regardless of objective-function’s range.

domain - input to be scored weighted_fns - list of weights and functions like:

[(weight, objective-functions)]
Returns an unsorted list of scores. To pair with hosts do:
zip(scores, hosts)