|
|
|
@ -9,6 +9,7 @@ var (
|
|
|
|
|
_ MachineIterator = (*Region)(nil) |
|
|
|
|
_ ZoneIterator = (*Region)(nil) |
|
|
|
|
|
|
|
|
|
_ RegionIterator = (*Zone)(nil) |
|
|
|
|
_ RegionIterator = (*Cluster)(nil) |
|
|
|
|
) |
|
|
|
|
|
|
|
|
@ -152,6 +153,28 @@ func (m *Cluster) appendRegionRegions(name string, subs ...string) {
|
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// ForEachRegion calls a function on all regions this zone belongs to.
|
|
|
|
|
func (z *Zone) ForEachRegion(fn func(*Region) bool) { |
|
|
|
|
if fn == nil { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
z.zones.ForEachRegion(func(r *Region) bool { |
|
|
|
|
var match bool |
|
|
|
|
|
|
|
|
|
r.ForEachZone(func(z2 *Zone) bool { |
|
|
|
|
match = (z == z2) |
|
|
|
|
return match |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
if match && fn(r) { |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (z *Zone) appendRegions(regions ...string) error { |
|
|
|
|
for _, s := range regions { |
|
|
|
|
// TODO: validate
|
|
|
|
|