|
|
@ -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 |
|
|
|