You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
1.4 KiB

package cluster
// SyncAll updates all config files
func (m *Cluster) SyncAll() error {
for _, fn := range []func() error{
m.SyncMkdirAll,
m.SyncAllWireguard,
m.SyncAllCeph,
m.SyncAllRegions,
m.WriteHosts,
} {
if err := fn(); err != nil {
return err
}
}
return nil
}
// SyncMkdirAll creates the directories needed to store files
// required to represent the cluster.
func (m *Cluster) SyncMkdirAll() error {
err := m.MkdirAll(".")
if err == nil {
m.ForEachMachine(func(p *Machine) bool {
err = p.MkdirAll(".")
return err != nil
})
}
return err
}
// SyncAllWireguard updates all wireguard config files
func (m *Cluster) SyncAllWireguard() error {
var err error
for _, ring := range Rings {
err = m.WriteWireguardKeys(ring.ID)
if err != nil {
return err
}
err = m.SyncWireguardConfig(ring.ID)
if err != nil {
return err
}
}
return nil
}
// SyncAllCeph updates the ceph.conf file
func (m *Cluster) SyncAllCeph() error {
cfg, err := m.GenCephConfig()
if err != nil {
return err
}
return m.WriteCephConfig(cfg)
}
// SyncAllRegions rewrites all region data
func (m *Cluster) SyncAllRegions() error {
var err error
m.ForEachZone(func(z *Zone) bool {
err := z.SyncRegions()
return err != nil
})
if err != nil {
return err
}
m.ForEachRegion(func(r *Region) bool {
err = r.SyncRegions()
return err != nil
})
return err
}