mirror of
https://github.com/gluster/glusterd2.git
synced 2026-02-06 15:46:00 +01:00
be capitalized,make first letter as lower case Signed-off-by: Madhu Rajanna <mrajanna@redhat.com>
41 lines
1006 B
Go
41 lines
1006 B
Go
package afr
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/gluster/glusterd2/glusterd2/volume"
|
|
"github.com/gluster/glusterd2/glusterd2/xlator"
|
|
)
|
|
|
|
var names = [...]string{"replicate", "afr"}
|
|
|
|
// isVolReplicate returns true if volume is of type replicate, disperse, distreplicate or distdisperse
|
|
// otherwise it returns false
|
|
func isVolReplicate(vType volume.VolType) bool {
|
|
if vType == volume.Replicate || vType == volume.Disperse || vType == volume.DistReplicate || vType == volume.DistDisperse {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
func validateOptions(v *volume.Volinfo, key string, value string) error {
|
|
switch key {
|
|
case "metadata-self-heal":
|
|
if v.Subvols[0].ReplicaCount == 1 {
|
|
return errors.New("option cannot be set for a non replicate volume")
|
|
}
|
|
case "self-heal-daemon":
|
|
if !isVolReplicate(v.Type) {
|
|
return errors.New("option cannot be set for a non replicate volume")
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func init() {
|
|
for _, name := range names {
|
|
xlator.RegisterValidationFunc(name, validateOptions)
|
|
}
|
|
}
|