zones: introduce Zones.CephFSID and Zones.GetCephFSID()

the accessor doesn't generate one if needed yet

Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
2023-09-05 12:04:22 +00:00
parent a8849b747c
commit 0fb8c1d44b
4 changed files with 25 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
package zones
import (
"darvaza.org/core"
"github.com/gofrs/uuid/v5"
)
// GetCephFSID returns our Ceph's FSID
func (m *Zones) GetCephFSID() (uuid.UUID, error) {
if core.IsZero(m.CephFSID) {
// TODO: generate one
return uuid.Nil, nil
}
return m.CephFSID, nil
}
+7
View File
@@ -6,6 +6,7 @@ import (
"sort"
"darvaza.org/resolver"
"github.com/gofrs/uuid/v5"
)
var (
@@ -135,15 +136,21 @@ func (z *Zone) GatewayIDs() ([]int, int) {
return out, len(out)
}
// revive:disable:line-length-limit
// Zones represents all zones in a cluster
type Zones struct {
dir fs.FS
resolver resolver.Resolver
domain string
CephFSID uuid.UUID `toml:"ceph_fsid,omitempty" json:"ceph_fsid,omitempty" yaml:"ceph_fsid,omitempty"`
Zones []*Zone `toml:"zones"`
}
// revive:enable:line-length-limit
// ForEachMachine calls a function for each Machine in the cluster
// until instructed to terminate the loop
func (m *Zones) ForEachMachine(fn func(*Machine) bool) {