|
|
|
@ -31,25 +31,7 @@ func (m *Zones) writeEnvZone(w io.Writer, z *Zone) {
|
|
|
|
|
m.writeEnvVar(w, z.Name, "ZONE%v_%s", zoneID, "NAME") |
|
|
|
|
|
|
|
|
|
// ZONE{zoneID}_GW
|
|
|
|
|
firstNodeID := 0 |
|
|
|
|
gatewayID := 0 |
|
|
|
|
z.ForEachMachine(func(p *Machine) bool { |
|
|
|
|
nodeID := p.ID() |
|
|
|
|
|
|
|
|
|
if firstNodeID == 0 { |
|
|
|
|
firstNodeID = nodeID |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if _, found := p.getRingInfo(0); found { |
|
|
|
|
gatewayID = nodeID |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return gatewayID != 0 |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
if gatewayID == 0 { |
|
|
|
|
gatewayID = firstNodeID |
|
|
|
|
} |
|
|
|
|
gatewayID := getRingZeroGatewayID(z) |
|
|
|
|
m.writeEnvVar(w, fmt.Sprintf("%v", gatewayID), "ZONE%v_%s", zoneID, "GW") |
|
|
|
|
|
|
|
|
|
// ZONE{zoneID}_IP
|
|
|
|
@ -95,3 +77,28 @@ func genEnvZoneNodes(z *Zone) string {
|
|
|
|
|
} |
|
|
|
|
return strings.Join(s, " ") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func getRingZeroGatewayID(z *Zone) int { |
|
|
|
|
var firstNodeID, gatewayID int |
|
|
|
|
|
|
|
|
|
z.ForEachMachine(func(p *Machine) bool { |
|
|
|
|
nodeID := p.ID() |
|
|
|
|
|
|
|
|
|
if firstNodeID == 0 { |
|
|
|
|
firstNodeID = nodeID |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if _, found := p.getRingInfo(0); found { |
|
|
|
|
gatewayID = nodeID |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return gatewayID != 0 |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
switch { |
|
|
|
|
case gatewayID == 0: |
|
|
|
|
return firstNodeID |
|
|
|
|
default: |
|
|
|
|
return gatewayID |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|