pkg/ceph: [WIP]

Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
2023-08-28 15:44:45 +01:00
parent 805bac01ec
commit f293ead8d5
7 changed files with 206 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
package zones
import (
"bytes"
"git.jpi.io/amery/jpictl/pkg/ceph"
)
// GetCephConfig reads the ceph.conf file
func (m *Zones) GetCephConfig() (*ceph.Config, error) {
data, err := m.ReadFile("ceph.conf")
if err != nil {
return nil, err
}
r := bytes.NewReader(data)
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
}
+16
View File
@@ -2,6 +2,8 @@ package zones
import (
"io/fs"
"log"
"os"
"sort"
)
@@ -12,6 +14,7 @@ func (m *Zones) scan(opts *ScanOptions) error {
m.scanZoneIDs,
m.scanSort,
m.scanGateways,
m.scanCephMonitors,
} {
if err := fn(opts); err != nil {
return err
@@ -121,6 +124,19 @@ func (m *Zones) scanGateways(_ *ScanOptions) error {
return err
}
func (m *Zones) scanCephMonitors(_ *ScanOptions) error {
cfg, err := m.GetCephConfig()
switch {
case os.IsNotExist(err):
err = nil
case err != nil:
return err
}
log.Print(cfg)
return nil
}
func (z *Zone) scan() error {
// each directory is a machine
entries, err := fs.ReadDir(z.zones.dir, z.Name)