The 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 = None
minval = None
weigh_objects(weighed_obj_list, weight_properties)

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()

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: cinder.scheduler.base_handler.BaseHandler

get_weighed_objects(weigher_classes, obj_list, weighing_properties)

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

object_class

alias of WeighedObject

class WeighedObject(obj, weight)

Bases: object

Object with weight information.

normalize(weight_list, minval=None, maxval=None)

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.