fester/backend/policy/rules.py

48 lines
818 B
Python

class Rule:
def apply(self, action, target, node):
return 0
# -----------------------------
# EXAMPLES
# -----------------------------
class AvoidHotNodes(Rule):
def apply(self, action, target, node):
if node.get("temp", 0) > 80:
return -100
return 0
class PreferLXCForARM(Rule):
def apply(self, action, target, node):
if target.arch == "arm64" and target.runtime == "lxc":
return 20
return 0
class AvoidVMForSmallBuilds(Rule):
def apply(self, action, target, node):
if target.runtime == "libvirt" and action.get("size") == "small":
return -50
return 0
class SpreadLoad(Rule):
def apply(self, action, target, node):
load = node.get("cpu_load", 50)
return -(load // 2)