本文整理汇总了Python中bkr.server.model.System.scheduler_ordering方法的典型用法代码示例。如果您正苦于以下问题:Python System.scheduler_ordering方法的具体用法?Python System.scheduler_ordering怎么用?Python System.scheduler_ordering使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bkr.server.model.System
的用法示例。
在下文中一共展示了System.scheduler_ordering方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: queue_processed_recipeset
# 需要导入模块: from bkr.server.model import System [as 别名]
# 或者: from bkr.server.model.System import scheduler_ordering [as 别名]
#.........这里部分代码省略.........
if not enough_systems:
log.debug("recipe: %s labController:%s entering not enough systems logic" %
(recipe.id, l_controller))
# Eliminate bad choices.
for recipe in recipeset.machine_recipes_orderby(l_controller)[:]:
for tmprecipe in recipeset.machine_recipes:
systemsa = set(recipe.dyn_systems.filter(
System.lab_controller==l_controller
).all())
systemsb = set(tmprecipe.dyn_systems.filter(
System.lab_controller==l_controller
).all())
if systemsa.difference(systemsb):
for rem_system in systemsa.intersection(systemsb):
if rem_system in recipe.systems:
log.debug("recipe: %s labController:%s Removing system %s" % (recipe.id, l_controller, rem_system))
recipe.systems.remove(rem_system)
for recipe in recipeset.machine_recipes:
count = 0
systems = recipe.dyn_systems.filter(
System.lab_controller==l_controller
).all()
for tmprecipe in recipeset.machine_recipes:
tmpsystems = tmprecipe.dyn_systems.filter(
System.lab_controller==l_controller
).all()
if recipe != tmprecipe and \
systems == tmpsystems:
count += 1
if len(systems) <= count:
# Remove all systems from this lc on this rs.
log.debug("recipe: %s labController:%s %s <= %s Removing lab" % (recipe.id, l_controller, len(systems), count))
bad_l_controllers = bad_l_controllers.union([l_controller])
# Remove systems that are on bad lab controllers
# This means one of the recipes can be fullfilled on a lab controller
# but not the rest of the recipes in the recipeSet.
# This could very well remove ALL systems from all recipes in this
# recipeSet. If that happens then the recipeSet cannot be scheduled
# and will be aborted by the abort process.
for recipe in recipeset.machine_recipes:
for l_controller in bad_l_controllers:
systems = (recipe.dyn_systems.filter(
System.lab_controller==l_controller
).all()
)
log.debug("recipe: %s labController: %s Removing lab" % (recipe.id, l_controller))
for system in systems:
if system in recipe.systems:
log.debug("recipe: %s labController: %s Removing system %s" % (recipe.id, l_controller, system))
recipe.systems.remove(system)
# Make the removal of systems visible to subsequent queries which use .dyn_systems
session.flush()
# Are we left with any recipes having no candidate systems?
dead_recipes = [recipe for recipe in recipeset.machine_recipes if not recipe.systems]
if dead_recipes:
# Set status to Aborted
log.debug('Not enough systems logic for %s left %s with no candidate systems',
recipeset.t_id, ', '.join(recipe.t_id for recipe in dead_recipes))
log.info('%s moved from Processed to Aborted' % recipeset.t_id)
recipeset.abort(u'Recipe ID %s does not match any systems'
% ', '.join(str(recipe.id) for recipe in dead_recipes))
return
# Can we schedule any recipes immediately?
for recipe in recipeset.machine_recipes:
systems = recipe.matching_systems()
if not systems: # may be None if we know there are no possible LCs
continue
system_count = systems.count()
if not system_count:
continue
# Order systems by owner, then Group, finally shared for everyone.
# FIXME Make this configurable, so that a user can specify their scheduling
# Implemented order, still need to do pool
# preference from the job.
# <recipe>
# <autopick order='sequence|random'>
# <pool>owner</pool>
# <pool>groups</pool>
# <pool>public</pool>
# </autopick>
# </recipe>
if True: #FIXME if pools are defined add them here in the order requested.
systems = System.scheduler_ordering(recipeset.job.owner, query=systems)
if recipe.autopick_random:
system = systems[random.randrange(0, system_count)]
else:
system = systems.first()
schedule_recipe_on_system(recipe, system)
for recipe in recipeset.machine_recipes:
if recipe.status == TaskStatus.processed:
# Leave it Queued until a system becomes free
log.info("recipe: %s moved from Processed to Queued" % recipe.id)
recipe.queue()
for guestrecipe in recipe.guests:
guestrecipe.queue()