Compare commits
19 Commits
f1c40aa03c
..
v0.5.2
| Author | SHA1 | Date | |
|---|---|---|---|
| 8c32b88e24 | |||
| 1bca1f7da1 | |||
| 5e5958d22e | |||
| 45447275a7 | |||
| e03e5e0d05 | |||
| a655603343 | |||
| c291b218a4 | |||
| 3911a51ccf | |||
| 1fe1cf940d | |||
| f10ea1dc22 | |||
| ac87757b06 | |||
| fe081a4297 | |||
| cea8362fe6 | |||
| b772ec0a3d | |||
| 77ad016e99 | |||
| bf4bfeb3fc | |||
| e3ab931eb1 | |||
| 05e04c758b | |||
| 94011a3a03 |
Vendored
+1
@@ -2,6 +2,7 @@
|
|||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
"ceph",
|
"ceph",
|
||||||
"darvaza",
|
"darvaza",
|
||||||
|
"gofrs",
|
||||||
"jpictl",
|
"jpictl",
|
||||||
"zerolog"
|
"zerolog"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -17,5 +17,6 @@ var cfg = &Config{
|
|||||||
func (cfg *Config) LoadZones(resolve bool) (*zones.Zones, error) {
|
func (cfg *Config) LoadZones(resolve bool) (*zones.Zones, error) {
|
||||||
return zones.New(cfg.Base, cfg.Domain,
|
return zones.New(cfg.Base, cfg.Domain,
|
||||||
zones.ResolvePublicAddresses(resolve),
|
zones.ResolvePublicAddresses(resolve),
|
||||||
|
zones.WithLogger(log),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -16,7 +16,11 @@ var envCmd = &cobra.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = m.Env(*envExport).WriteTo(os.Stdout)
|
env, err := m.Env(*envExport)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = env.WriteTo(os.Stdout)
|
||||||
return err
|
return err
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"darvaza.org/slog"
|
"darvaza.org/slog"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TODO: make log level configurable via flags
|
||||||
var (
|
var (
|
||||||
log = zerolog.New(nil, slog.Debug)
|
log = zerolog.New(nil, slog.Debug)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ require (
|
|||||||
darvaza.org/resolver v0.5.4
|
darvaza.org/resolver v0.5.4
|
||||||
darvaza.org/sidecar v0.0.2
|
darvaza.org/sidecar v0.0.2
|
||||||
darvaza.org/slog v0.5.3
|
darvaza.org/slog v0.5.3
|
||||||
|
darvaza.org/slog/handlers/discard v0.4.5
|
||||||
github.com/burntSushi/toml v0.3.1
|
github.com/burntSushi/toml v0.3.1
|
||||||
github.com/gofrs/uuid/v5 v5.0.0
|
github.com/gofrs/uuid/v5 v5.0.0
|
||||||
github.com/hack-pad/hackpadfs v0.2.1
|
github.com/hack-pad/hackpadfs v0.2.1
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ darvaza.org/sidecar v0.0.2 h1:4H8FUxc43kkLjxdShN1CoxLTcoHQsZjDVwm7kt6eIK0=
|
|||||||
darvaza.org/sidecar v0.0.2/go.mod h1:yFC3Qt3j+uS7n9CMpLxwrA68z+FNJhENoenBc9zBJJo=
|
darvaza.org/sidecar v0.0.2/go.mod h1:yFC3Qt3j+uS7n9CMpLxwrA68z+FNJhENoenBc9zBJJo=
|
||||||
darvaza.org/slog v0.5.3 h1:sQzmZXgqRh9oFMKBwEYrEpucLvKJVZxaxa2bHIA6GJ0=
|
darvaza.org/slog v0.5.3 h1:sQzmZXgqRh9oFMKBwEYrEpucLvKJVZxaxa2bHIA6GJ0=
|
||||||
darvaza.org/slog v0.5.3/go.mod h1:59d+yi+C7gn4pDDuwbbOKawERpdXthFFk1Yc+Sv6XB0=
|
darvaza.org/slog v0.5.3/go.mod h1:59d+yi+C7gn4pDDuwbbOKawERpdXthFFk1Yc+Sv6XB0=
|
||||||
|
darvaza.org/slog/handlers/discard v0.4.5 h1:RRykOItNolHyiUav57lG/GFBL33rcljoa0nWTpY+T0g=
|
||||||
|
darvaza.org/slog/handlers/discard v0.4.5/go.mod h1:HYHfISQjMqcPbPoPZ92ib/u7s9JcXvF6OaygpPFwdF8=
|
||||||
darvaza.org/slog/handlers/filter v0.4.5 h1:CX1bMzldd67e3y3s3Sh4jK8Lyo0WMvTGBB2lD315jhc=
|
darvaza.org/slog/handlers/filter v0.4.5 h1:CX1bMzldd67e3y3s3Sh4jK8Lyo0WMvTGBB2lD315jhc=
|
||||||
darvaza.org/slog/handlers/filter v0.4.5/go.mod h1:OuH9rHYg9CIErTJCZliMnFexBfP/HJ9PZ1V1VwSCZ1g=
|
darvaza.org/slog/handlers/filter v0.4.5/go.mod h1:OuH9rHYg9CIErTJCZliMnFexBfP/HJ9PZ1V1VwSCZ1g=
|
||||||
darvaza.org/slog/handlers/zerolog v0.4.5 h1:W4cgGORx4wImr+RL96CWSQGTdkZzKX6YHXPSYJvdoB4=
|
darvaza.org/slog/handlers/zerolog v0.4.5 h1:W4cgGORx4wImr+RL96CWSQGTdkZzKX6YHXPSYJvdoB4=
|
||||||
|
|||||||
+31
-2
@@ -1,8 +1,11 @@
|
|||||||
package ceph
|
package ceph
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gofrs/uuid/v5"
|
"github.com/gofrs/uuid/v5"
|
||||||
|
|
||||||
@@ -17,11 +20,37 @@ type Config struct {
|
|||||||
// GlobalConfig represents the [global] section of a ceph.conf file
|
// GlobalConfig represents the [global] section of a ceph.conf file
|
||||||
type GlobalConfig struct {
|
type GlobalConfig struct {
|
||||||
FSID uuid.UUID `ini:"fsid"`
|
FSID uuid.UUID `ini:"fsid"`
|
||||||
Monitors []string `ini:"mon_host,comma"`
|
Monitors []string `ini:"mon_initial_members,comma"`
|
||||||
MonitorsAddr []netip.Addr `ini:"mon_initial_members,comma"`
|
MonitorsAddr []netip.Addr `ini:"mon_host,comma"`
|
||||||
ClusterNetwork netip.Prefix `ini:"cluster_network"`
|
ClusterNetwork netip.Prefix `ini:"cluster_network"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WriteTo writes a Wireguard [Config] onto the provided [io.Writer]
|
||||||
|
func (cfg *Config) WriteTo(w io.Writer) (int64, error) {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
|
||||||
|
writeGlobalToBuffer(&buf, &cfg.Global)
|
||||||
|
return buf.WriteTo(w)
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeGlobalToBuffer(w *bytes.Buffer, c *GlobalConfig) {
|
||||||
|
_, _ = w.WriteString("[global]\n")
|
||||||
|
_, _ = fmt.Fprintf(w, "%s = %s\n", "fsid", c.FSID.String())
|
||||||
|
_, _ = fmt.Fprintf(w, "%s = %s\n", "mon_initial_members", strings.Join(c.Monitors, ", "))
|
||||||
|
_, _ = fmt.Fprintf(w, "%s = %s\n", "mon_host", joinAddrs(c.MonitorsAddr, ", "))
|
||||||
|
_, _ = fmt.Fprintf(w, "%s = %s\n", "cluster_network", c.ClusterNetwork.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
func joinAddrs(addrs []netip.Addr, sep string) string {
|
||||||
|
s := make([]string, len(addrs))
|
||||||
|
|
||||||
|
for i, addr := range addrs {
|
||||||
|
s[i] = addr.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.Join(s, sep)
|
||||||
|
}
|
||||||
|
|
||||||
// NewConfigFromReader parses the ceph.conf file
|
// NewConfigFromReader parses the ceph.conf file
|
||||||
func NewConfigFromReader(r io.Reader) (*Config, error) {
|
func NewConfigFromReader(r io.Reader) (*Config, error) {
|
||||||
doc, err := basic.Decode(r)
|
doc, err := basic.Decode(r)
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ func loadGlobalConfField(cfg *GlobalConfig, field basic.Field) error {
|
|||||||
// revive:enable:cyclomatic
|
// revive:enable:cyclomatic
|
||||||
// revive:enable:cognitive-complexity
|
// revive:enable:cognitive-complexity
|
||||||
|
|
||||||
|
// TODO: refactor when asciigoat's ini parser learns to do reflection
|
||||||
|
|
||||||
switch field.Key {
|
switch field.Key {
|
||||||
case "fsid":
|
case "fsid":
|
||||||
if !core.IsZero(cfg.FSID) {
|
if !core.IsZero(cfg.FSID) {
|
||||||
|
|||||||
+18
-2
@@ -14,8 +14,12 @@ import (
|
|||||||
// GetCephFSID returns our Ceph's FSID
|
// GetCephFSID returns our Ceph's FSID
|
||||||
func (m *Zones) GetCephFSID() (uuid.UUID, error) {
|
func (m *Zones) GetCephFSID() (uuid.UUID, error) {
|
||||||
if core.IsZero(m.CephFSID) {
|
if core.IsZero(m.CephFSID) {
|
||||||
// TODO: generate one
|
// generate one
|
||||||
return uuid.Nil, nil
|
v, err := uuid.NewV4()
|
||||||
|
if err != nil {
|
||||||
|
return uuid.Nil, err
|
||||||
|
}
|
||||||
|
m.CephFSID = v
|
||||||
}
|
}
|
||||||
return m.CephFSID, nil
|
return m.CephFSID, nil
|
||||||
}
|
}
|
||||||
@@ -31,6 +35,18 @@ func (m *Zones) GetCephConfig() (*ceph.Config, error) {
|
|||||||
return ceph.NewConfigFromReader(r)
|
return ceph.NewConfigFromReader(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WriteCephConfig writes the ceph.conf file
|
||||||
|
func (m *Zones) WriteCephConfig(cfg *ceph.Config) error {
|
||||||
|
f, err := m.CreateTruncFile("ceph.conf")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
_, err = cfg.WriteTo(f)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// GenCephConfig prepares a ceph.Config using the cluster information
|
// GenCephConfig prepares a ceph.Config using the cluster information
|
||||||
func (m *Zones) GenCephConfig() (*ceph.Config, error) {
|
func (m *Zones) GenCephConfig() (*ceph.Config, error) {
|
||||||
fsid, err := m.GetCephFSID()
|
fsid, err := m.GetCephFSID()
|
||||||
|
|||||||
+21
-14
@@ -53,7 +53,7 @@ func (err CephMissingMonitorError) Error() string {
|
|||||||
|
|
||||||
func (err *CephMissingMonitorError) writeNames(w *strings.Builder) {
|
func (err *CephMissingMonitorError) writeNames(w *strings.Builder) {
|
||||||
if len(err.Names) > 0 {
|
if len(err.Names) > 0 {
|
||||||
_, _ = w.WriteString(" mon_host:")
|
_, _ = w.WriteString(" mon_initial_members:")
|
||||||
for i, name := range err.Names {
|
for i, name := range err.Names {
|
||||||
if i != 0 {
|
if i != 0 {
|
||||||
_, _ = w.WriteRune(',')
|
_, _ = w.WriteRune(',')
|
||||||
@@ -64,12 +64,14 @@ func (err *CephMissingMonitorError) writeNames(w *strings.Builder) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (err *CephMissingMonitorError) writeAddrs(w *strings.Builder) {
|
func (err *CephMissingMonitorError) writeAddrs(w *strings.Builder) {
|
||||||
_, _ = w.WriteString(" mon_initial_members:")
|
if len(err.Addrs) > 0 {
|
||||||
for i, addr := range err.Addrs {
|
_, _ = w.WriteString(" mon_host:")
|
||||||
if i != 0 {
|
for i, addr := range err.Addrs {
|
||||||
_, _ = w.WriteRune(',')
|
if i != 0 {
|
||||||
|
_, _ = w.WriteRune(',')
|
||||||
|
}
|
||||||
|
_, _ = w.WriteString(addr.String())
|
||||||
}
|
}
|
||||||
_, _ = w.WriteString(addr.String())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,14 +159,19 @@ func (m *Zones) scanCephMonitors(_ *ScanOptions) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// flag monitors based on config
|
if cfg != nil {
|
||||||
todo := newCephScanTODO(cfg)
|
// store FSID
|
||||||
m.ForEachMachine(func(p *Machine) bool {
|
m.CephFSID = cfg.Global.FSID
|
||||||
p.CephMonitor = todo.checkMachine(p)
|
|
||||||
return false
|
// flag monitors based on config
|
||||||
})
|
todo := newCephScanTODO(cfg)
|
||||||
if err := todo.Missing(); err != nil {
|
m.ForEachMachine(func(p *Machine) bool {
|
||||||
return core.Wrap(err, "ceph")
|
p.CephMonitor = todo.checkMachine(p)
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
if err := todo.Missing(); err != nil {
|
||||||
|
return core.Wrap(err, "ceph")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure every zone has one
|
// make sure every zone has one
|
||||||
|
|||||||
+17
-3
@@ -11,15 +11,24 @@ import (
|
|||||||
type Env struct {
|
type Env struct {
|
||||||
ZoneIterator
|
ZoneIterator
|
||||||
|
|
||||||
export bool
|
cephFSID string
|
||||||
|
export bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Env returns a shell environment factory
|
// Env returns a shell environment factory
|
||||||
func (m *Zones) Env(export bool) *Env {
|
func (m *Zones) Env(export bool) (*Env, error) {
|
||||||
return &Env{
|
fsid, err := m.GetCephFSID()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
env := &Env{
|
||||||
ZoneIterator: m,
|
ZoneIterator: m,
|
||||||
|
cephFSID: fsid.String(),
|
||||||
export: export,
|
export: export,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return env, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Zones returns the list of Zone IDs
|
// Zones returns the list of Zone IDs
|
||||||
@@ -38,7 +47,12 @@ func (m *Env) Zones() []int {
|
|||||||
func (m *Env) WriteTo(w io.Writer) (int64, error) {
|
func (m *Env) WriteTo(w io.Writer) (int64, error) {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
|
|
||||||
|
if m.cephFSID != "" {
|
||||||
|
m.writeEnvVar(&buf, m.cephFSID, "FSID")
|
||||||
|
}
|
||||||
|
|
||||||
m.writeEnvVarInts(&buf, m.Zones(), "ZONES")
|
m.writeEnvVarInts(&buf, m.Zones(), "ZONES")
|
||||||
|
|
||||||
m.ForEachZone(func(z *Zone) bool {
|
m.ForEachZone(func(z *Zone) bool {
|
||||||
m.writeEnvZone(&buf, z)
|
m.writeEnvZone(&buf, z)
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package zones
|
||||||
|
|
||||||
|
import "darvaza.org/slog"
|
||||||
|
|
||||||
|
type logger interface {
|
||||||
|
withDebug() (slog.Logger, bool)
|
||||||
|
withInfo() (slog.Logger, bool)
|
||||||
|
|
||||||
|
debug() slog.Logger
|
||||||
|
info() slog.Logger
|
||||||
|
warn(error) slog.Logger
|
||||||
|
error(error) slog.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ logger = (*Zones)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
func (z *Zones) withDebug() (slog.Logger, bool) {
|
||||||
|
return z.debug().WithEnabled()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (z *Zones) withInfo() (slog.Logger, bool) {
|
||||||
|
return z.debug().WithEnabled()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (z *Zones) debug() slog.Logger {
|
||||||
|
return z.log.Debug()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (z *Zones) info() slog.Logger {
|
||||||
|
return z.log.Info()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (z *Zones) warn(err error) slog.Logger {
|
||||||
|
l := z.log.Warn()
|
||||||
|
if err != nil {
|
||||||
|
l = l.WithField(slog.ErrorFieldName, err)
|
||||||
|
}
|
||||||
|
return l
|
||||||
|
}
|
||||||
|
|
||||||
|
func (z *Zones) error(err error) slog.Logger {
|
||||||
|
l := z.log.Error()
|
||||||
|
if err != nil {
|
||||||
|
l = l.WithField(slog.ErrorFieldName, err)
|
||||||
|
}
|
||||||
|
return l
|
||||||
|
}
|
||||||
@@ -10,6 +10,8 @@ import (
|
|||||||
// A Machine is a machine on a Zone
|
// A Machine is a machine on a Zone
|
||||||
type Machine struct {
|
type Machine struct {
|
||||||
zone *Zone
|
zone *Zone
|
||||||
|
logger
|
||||||
|
|
||||||
ID int `toml:"id"`
|
ID int `toml:"id"`
|
||||||
Name string `toml:"-" json:"-" yaml:"-"`
|
Name string `toml:"-" json:"-" yaml:"-"`
|
||||||
|
|
||||||
|
|||||||
+26
-1
@@ -5,10 +5,12 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"darvaza.org/resolver"
|
"darvaza.org/resolver"
|
||||||
|
"darvaza.org/slog"
|
||||||
|
"darvaza.org/slog/handlers/discard"
|
||||||
"github.com/hack-pad/hackpadfs/os"
|
"github.com/hack-pad/hackpadfs/os"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A ScanOption preconfigures the Zones before scanning
|
// A ScanOption pre-configures the Zones before scanning
|
||||||
type ScanOption func(*Zones, *ScanOptions) error
|
type ScanOption func(*Zones, *ScanOptions) error
|
||||||
|
|
||||||
// ScanOptions contains flags used by the initial scan
|
// ScanOptions contains flags used by the initial scan
|
||||||
@@ -17,6 +19,10 @@ type ScanOptions struct {
|
|||||||
// pre-populate Machine.PublicAddresses during the
|
// pre-populate Machine.PublicAddresses during the
|
||||||
// initial scan
|
// initial scan
|
||||||
DontResolvePublicAddresses bool
|
DontResolvePublicAddresses bool
|
||||||
|
|
||||||
|
// Logger specifies the logger to be used. otherwise
|
||||||
|
// the scanner will be mute
|
||||||
|
slog.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResolvePublicAddresses instructs the scanner to use
|
// ResolvePublicAddresses instructs the scanner to use
|
||||||
@@ -55,6 +61,19 @@ func WithResolver(h resolver.Resolver) ScanOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithLogger specifies what to use for logging
|
||||||
|
func WithLogger(log slog.Logger) ScanOption {
|
||||||
|
return func(m *Zones, opt *ScanOptions) error {
|
||||||
|
if log == nil {
|
||||||
|
log = discard.New()
|
||||||
|
}
|
||||||
|
|
||||||
|
opt.Logger = log
|
||||||
|
m.log = log
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Zones) setDefaults(opt *ScanOptions) error {
|
func (m *Zones) setDefaults(opt *ScanOptions) error {
|
||||||
if m.resolver == nil {
|
if m.resolver == nil {
|
||||||
h := resolver.NewCloudflareLookuper()
|
h := resolver.NewCloudflareLookuper()
|
||||||
@@ -64,6 +83,12 @@ func (m *Zones) setDefaults(opt *ScanOptions) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if opt.Logger == nil {
|
||||||
|
if err := WithLogger(nil)(m, opt); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-4
@@ -32,8 +32,9 @@ func (m *Zones) scanDirectory(_ *ScanOptions) error {
|
|||||||
for _, e := range entries {
|
for _, e := range entries {
|
||||||
if e.IsDir() {
|
if e.IsDir() {
|
||||||
z := &Zone{
|
z := &Zone{
|
||||||
zones: m,
|
zones: m,
|
||||||
Name: e.Name(),
|
logger: m,
|
||||||
|
Name: e.Name(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := z.scan(); err != nil {
|
if err := z.scan(); err != nil {
|
||||||
@@ -132,8 +133,9 @@ func (z *Zone) scan() error {
|
|||||||
for _, e := range entries {
|
for _, e := range entries {
|
||||||
if e.IsDir() {
|
if e.IsDir() {
|
||||||
m := &Machine{
|
m := &Machine{
|
||||||
zone: z,
|
zone: z,
|
||||||
Name: e.Name(),
|
logger: z,
|
||||||
|
Name: e.Name(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := m.init(); err != nil {
|
if err := m.init(); err != nil {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ package zones
|
|||||||
func (m *Zones) SyncAll() error {
|
func (m *Zones) SyncAll() error {
|
||||||
for _, fn := range []func() error{
|
for _, fn := range []func() error{
|
||||||
m.SyncAllWireguard,
|
m.SyncAllWireguard,
|
||||||
|
m.SyncAllCeph,
|
||||||
} {
|
} {
|
||||||
if err := fn(); err != nil {
|
if err := fn(); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -31,3 +32,13 @@ func (m *Zones) SyncAllWireguard() error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SyncAllCeph updates the ceph.conf file
|
||||||
|
func (m *Zones) SyncAllCeph() error {
|
||||||
|
cfg, err := m.GenCephConfig()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return m.WriteCephConfig(cfg)
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"darvaza.org/resolver"
|
"darvaza.org/resolver"
|
||||||
|
"darvaza.org/slog"
|
||||||
"github.com/gofrs/uuid/v5"
|
"github.com/gofrs/uuid/v5"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -87,6 +88,7 @@ func FilterMachines(m MachineIterator, cond func(*Machine) bool) (Machines, int)
|
|||||||
// Zone represents one zone in a cluster
|
// Zone represents one zone in a cluster
|
||||||
type Zone struct {
|
type Zone struct {
|
||||||
zones *Zones
|
zones *Zones
|
||||||
|
logger
|
||||||
|
|
||||||
ID int `toml:"id"`
|
ID int `toml:"id"`
|
||||||
Name string `toml:"name"`
|
Name string `toml:"name"`
|
||||||
@@ -141,6 +143,7 @@ func (z *Zone) GatewayIDs() ([]int, int) {
|
|||||||
// Zones represents all zones in a cluster
|
// Zones represents all zones in a cluster
|
||||||
type Zones struct {
|
type Zones struct {
|
||||||
dir fs.FS
|
dir fs.FS
|
||||||
|
log slog.Logger
|
||||||
resolver resolver.Resolver
|
resolver resolver.Resolver
|
||||||
domain string
|
domain string
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user