cinder.scheduler.base_weight module

Pluggable Weighing support

class BaseWeigher

Bases: object

Base class for pluggable weighers.

The attributes maxval and minval can be specified to set up the maximum and minimum values for the weighed objects. These values will then be taken into account in the normalization step, instead of taking the values from the calculated weights.

maxval: float | None = None
minval: float | None = None
weigh_objects(weighed_obj_list: list[WeighedObject], weight_properties: dict) list[float]

Weigh multiple objects.

Override in a subclass if you need access to all objects in order to calculate weights. Do not modify the weight of an object here, just return a list of weights.

weight_multiplier() float

How weighted this weigher should be.

Override this method in a subclass, so that the returned value is read from a configuration option to permit operators specify a multiplier for the weigher.

class BaseWeightHandler(modifier_class_type, modifier_namespace)

Bases: BaseHandler

get_weighed_objects(weigher_classes: list, obj_list: list[WeighedObject], weighing_properties: dict) list[WeighedObject]

Return a sorted (descending), normalized list of WeighedObjects.


alias of WeighedObject

class WeighedObject(obj, weight: float)

Bases: object

Object with weight information.

normalize(weight_list: list[float], minval: float | None = None, maxval: float | None = None) Iterable[float]

Normalize the values in a list between 0 and 1.0.

The normalization is made regarding the lower and upper values present in weight_list. If the minval and/or maxval parameters are set, these values will be used instead of the minimum and maximum from the list.

If all the values are equal, they are normalized to 0.