|
|
|
@ -66,6 +66,26 @@ func (m Machines) Swap(i, j int) {
|
|
|
|
|
m[i], m[j] = m[j], m[i] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// FilterMachines produces a subset of the machines offered by the given
|
|
|
|
|
// iterator fulfilling a condition
|
|
|
|
|
func FilterMachines(m MachineIterator, cond func(*Machine) bool) (Machines, int) { |
|
|
|
|
var out []*Machine |
|
|
|
|
|
|
|
|
|
if cond == nil { |
|
|
|
|
// unconditional
|
|
|
|
|
cond = func(*Machine) bool { return true } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
m.ForEachMachine(func(p *Machine) bool { |
|
|
|
|
if cond(p) { |
|
|
|
|
out = append(out, p) |
|
|
|
|
} |
|
|
|
|
return false |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
return out, len(out) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Zone represents one zone in a cluster
|
|
|
|
|
type Zone struct { |
|
|
|
|
zones *Zones |
|
|
|
|