zones: Machine.IsGateway()

Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
2023-08-23 20:04:47 +00:00
parent 15f28fa7c8
commit 7258b4a20e
2 changed files with 13 additions and 1 deletions
+1 -1
View File
@@ -88,7 +88,7 @@ func getRingZeroGatewayID(z *Zone) int {
firstNodeID = nodeID
}
if _, found := p.getRingInfo(0); found {
if p.IsGateway() {
gatewayID = nodeID
}
+12
View File
@@ -58,6 +58,18 @@ func (m *Machine) FullName() string {
return m.Name
}
// IsGateway tells if the Machine is a ring0 gateway
func (m *Machine) IsGateway() bool {
m.mu.Lock()
defer m.mu.Unlock()
if ri, found := m.getRingInfo(0); found {
return ri.Enabled
}
return false
}
func (m *Machine) getPeerByName(name string) (*Machine, bool) {
return m.zone.zones.GetMachineByName(name)
}