Cells: Add filtering and weight support

This adds filtering and weighing support to the cells scheduler.

Adds the following config options to the 'cells' group:

scheduler_filter_classes -- list of filter classes
scheduler_weight_classes -- list of weight classes

Adds a couple of weighing modules as defaults (which removes the random
cell selection):

ram_by_instance_type: Select cells with the most capacity for the
instance type being requested.
weight_offset: Allows modifying the DB to weight a particular cell
(useful for disabling a cell)

Adds a filter class (TargetCellFilter) that allows specifying a scheduler
hint to direct a build to a particular cell if you're an admin.

DocImpact

Implements blueprint cells-filter-scheduler

Change-Id: I027c5734e3d6134127fcd4dd28b8ff39047416dc
This commit is contained in:
Chris Behrens
2012-11-15 18:08:07 +00:00
parent 719ec4725e
commit 7a5ed3e767
13 changed files with 848 additions and 33 deletions

View File

@@ -54,8 +54,14 @@ class BaseFilterHandler(loadables.BaseLoader):
list_objs = list(objs)
LOG.debug("Starting with %d host(s)", len(list_objs))
for filter_cls in filter_classes:
list_objs = list(filter_cls().filter_all(list_objs,
filter_properties))
LOG.debug("Filter %s returned %d host(s)",
filter_cls.__name__, len(list_objs))
cls_name = filter_cls.__name__
objs = filter_cls().filter_all(list_objs,
filter_properties)
if objs is None:
LOG.debug("Filter %(cls_name)s says to stop filtering",
{'cls_name': cls_name})
return
list_objs = list(objs)
LOG.debug("Filter %(cls_name)s returned %(obj_len)d host(s)",
{'cls_name': cls_name, 'obj_len': len(list_objs)})
return list_objs