ceph: zones.Zones.WriteCephConfig() and ceph.Config.WriteTo() [WIP]
Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package ceph
|
package ceph
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
|
|
||||||
@@ -14,6 +15,13 @@ type Config struct {
|
|||||||
Global GlobalConfig `ini:"global"`
|
Global GlobalConfig `ini:"global"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WriteTo writes a Wireguard [Config] onto the provided [io.Writer]
|
||||||
|
func (*Config) WriteTo(w io.Writer) (int64, error) {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
|
||||||
|
return buf.WriteTo(w)
|
||||||
|
}
|
||||||
|
|
||||||
// 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"`
|
||||||
|
|||||||
@@ -16,3 +16,15 @@ func (m *Zones) GetCephConfig() (*ceph.Config, error) {
|
|||||||
r := bytes.NewReader(data)
|
r := bytes.NewReader(data)
|
||||||
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
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user