|
|
|
@ -32,11 +32,14 @@ func (m *Zones) writeEnvZone(w io.Writer, z *Zone) {
|
|
|
|
|
|
|
|
|
|
// ZONE{zoneID}_GW
|
|
|
|
|
gatewayID := getRingZeroGatewayID(z) |
|
|
|
|
m.writeEnvVar(w, fmt.Sprintf("%v", gatewayID), "ZONE%v_%s", zoneID, "GW") |
|
|
|
|
if gatewayID > 0 { |
|
|
|
|
m.writeEnvVar(w, fmt.Sprintf("%v", gatewayID), "ZONE%v_%s", zoneID, "GW") |
|
|
|
|
|
|
|
|
|
// ZONE{zoneID}_IP
|
|
|
|
|
ip, _ := RingZeroAddress(zoneID, gatewayID) |
|
|
|
|
m.writeEnvVar(w, ip.String(), "ZONE%v_%s", zoneID, "IP") |
|
|
|
|
// ZONE{zoneID}_IP
|
|
|
|
|
if ip, ok := RingZeroAddress(zoneID, gatewayID); ok { |
|
|
|
|
m.writeEnvVar(w, ip.String(), "ZONE%v_%s", zoneID, "IP") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (m *Zones) writeEnvVarFn(w io.Writer, fn func(*Zones) string, name string, args ...any) { |
|
|
|
@ -79,13 +82,9 @@ func genEnvZoneNodes(z *Zone) string {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func getRingZeroGatewayID(z *Zone) int { |
|
|
|
|
var firstNodeID, gatewayID int |
|
|
|
|
var gatewayID int |
|
|
|
|
|
|
|
|
|
z.ForEachMachine(func(p *Machine) bool { |
|
|
|
|
if firstNodeID == 0 { |
|
|
|
|
firstNodeID = p.ID |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if p.IsGateway() { |
|
|
|
|
gatewayID = p.ID |
|
|
|
|
} |
|
|
|
@ -93,10 +92,5 @@ func getRingZeroGatewayID(z *Zone) int {
|
|
|
|
|
return gatewayID != 0 |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
switch { |
|
|
|
|
case gatewayID == 0: |
|
|
|
|
return firstNodeID |
|
|
|
|
default: |
|
|
|
|
return gatewayID |
|
|
|
|
} |
|
|
|
|
return gatewayID |
|
|
|
|
} |
|
|
|
|