Compare commits

..

5 Commits

Author SHA1 Message Date
amery 7dc3b36777 zones: set Machine.CephMonitor if its referenced as monitor on ceph.conf
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-04 22:01:13 +00:00
amery 9e8a19d00d ceph: zones.Zones.WriteCephConfig() and ceph.Config.WriteTo() [WIP]
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-04 20:33:01 +00:00
amery 1037ed4bae build-sys: use local asciigoat.org/ini
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-04 20:31:59 +00:00
amery 3014212bc9 Merge branch 'pr-amery-ceph' into next-amery
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-04 20:31:16 +00:00
amery f1a0b1d644 vscode: add special words to the dictionary
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-04 20:30:25 +00:00
3 changed files with 0 additions and 100 deletions
-45
View File
@@ -2,7 +2,6 @@ package zones
import (
"bytes"
"sort"
"git.jpi.io/amery/jpictl/pkg/ceph"
)
@@ -29,47 +28,3 @@ func (m *Zones) WriteCephConfig(cfg *ceph.Config) error {
_, err = cfg.WriteTo(f)
return err
}
// GetCephMonitors returns the set of Ceph monitors on
// the zone
func (z *Zone) GetCephMonitors() Machines {
var mons Machines
var first, second *Machine
z.ForEachMachine(func(p *Machine) bool {
switch {
case p.CephMonitor:
// it is a monitor
mons = append(mons, p)
case len(mons) > 0:
// zone has a monitor
case first == nil && !p.IsGateway():
// first option for monitor
first = p
case second == nil:
// second option for monitor
second = p
}
return false
})
switch {
case len(mons) > 0:
// ready
case first != nil:
// make first option our monitor
first.CephMonitor = true
mons = append(mons, first)
case second != nil:
// make second option our monitor
second.CephMonitor = true
mons = append(mons, second)
default:
// zone without machines??
panic("unreachable")
}
sort.Sort(mons)
return mons
}
-5
View File
@@ -167,10 +167,5 @@ func (m *Zones) scanCephMonitors(_ *ScanOptions) error {
return core.Wrap(err, "ceph")
}
// make sure every zone has one
m.ForEachZone(func(z *Zone) bool {
_ = z.GetCephMonitors()
return false
})
return nil
}
-50
View File
@@ -59,15 +59,6 @@ func (m *Env) writeEnvZone(w io.Writer, z *Zone) {
// ZONE{zoneID}_GW
gateways, _ := z.GatewayIDs()
m.writeEnvVarInts(w, gateways, "ZONE%v_%s", zoneID, "GW")
// Ceph
monitors := z.GetCephMonitors()
// MON{zoneID}_NAME
m.writeEnvVar(w, genEnvZoneCephMonNames(monitors), "MON%v_%s", zoneID, "NAME")
// MON{zoneID}_IP
m.writeEnvVar(w, genEnvZoneCephMonIPs(monitors), "MON%v_%s", zoneID, "IP")
// MON{zoneID}_ID
m.writeEnvVar(w, genEnvZoneCephMonIDs(monitors), "MON%v_%s", zoneID, "ID")
}
func (m *Env) writeEnvVarInts(w io.Writer, value []int, name string, args ...any) {
@@ -120,44 +111,3 @@ func genEnvZoneNodes(z *Zone) string {
}
return ""
}
func genEnvZoneCephMonNames(m Machines) string {
var buf strings.Builder
m.ForEachMachine(func(p *Machine) bool {
if buf.Len() > 0 {
_, _ = buf.WriteRune(' ')
}
_, _ = buf.WriteString(p.Name)
return false
})
return buf.String()
}
func genEnvZoneCephMonIPs(m Machines) string {
var buf strings.Builder
m.ForEachMachine(func(p *Machine) bool {
addr, _ := RingOneAddress(p.Zone(), p.ID)
if buf.Len() > 0 {
_, _ = buf.WriteRune(' ')
}
_, _ = buf.WriteString(addr.String())
return false
})
return buf.String()
}
func genEnvZoneCephMonIDs(m Machines) string {
var buf strings.Builder
m.ForEachMachine(func(p *Machine) bool {
if buf.Len() > 0 {
_, _ = buf.WriteRune(' ')
}
_, _ = fmt.Fprintf(&buf, "%v", p.ID)
return false
})
return buf.String()
}