From f63ce6c4e78254b3f9c4d12ed9e497c6cdcf9c02 Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Sun, 27 Aug 2023 17:09:15 +0000 Subject: [PATCH] zones: introduce Zone.GatewayIDs() Signed-off-by: Alejandro Mery --- pkg/zones/zones.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/zones/zones.go b/pkg/zones/zones.go index a8fb2ea..ae9eb33 100644 --- a/pkg/zones/zones.go +++ b/pkg/zones/zones.go @@ -125,6 +125,19 @@ func (z *Zone) SetGateway(gatewayID int, enabled bool) error { } } +// GatewayIDs returns the list of IDs of machines that act as ring0 gateways +func (z *Zone) GatewayIDs() ([]int, int) { + var out []int + z.ForEachMachine(func(p *Machine) bool { + if p.IsGateway() { + out = append(out, p.ID) + } + return false + }) + + return out, len(out) +} + // Zones represents all zones in a cluster type Zones struct { dir fs.FS