A host selection policy module looks like this:
from haizea.core.scheduler.policy import HostSelectionPolicy class NoPolicy(HostSelectionPolicy): def __init__(self, slottable): HostSelectionPolicy.__init__(self, slottable) def get_host_score(self, node, time, lease): # Your code goes here
The get_host_score method receives a physical host (the integer node identifier used in the slot table, which all policy modules have access to), a time, and a Lease object we would like to schedule at that time. This method returns a score indicating how desirable that host is for that lease at that time. The score can be between 0.0 and 1.0, and the higher the score, the "more desirable" the physical host is. Like the lease preemptability score, this is a relative measure; the score will be used to determine which of several physical hosts is more desirable for this lease.
The host selection policy to use is specified using the policy-host-selection option of the [scheduling] section in the configuration file. So, assuming you save your module as policies.py, you would specify the following in the configuration file:
[scheduling] ... policy-host-selection: policies.MyPolicy ...
Borja Sotomayor 2009-12-17