test(zfspv): adding zfs property update test cases

Signed-off-by: Pawan <pawan@mayadata.io>
This commit is contained in:
Pawan 2019-12-05 16:57:34 +05:30 committed by Kiran Mova
parent 620be59016
commit 754755439b
7 changed files with 180 additions and 41 deletions

View file

@ -89,7 +89,7 @@ func (c *ZVController) syncZV(zv *apis.ZFSVolume) error {
// the volume. And if it is set then volume has already been
// created and this event is for property change only.
if zv.Finalizers != nil {
err = zfs.SetZvolProp(zv)
err = zfs.SetVolumeProp(zv)
} else {
err = zfs.CreateVolume(zv)
if err == nil {

View file

@ -36,6 +36,7 @@ const (
ZFSCreateArg = "create"
ZFSDestroyArg = "destroy"
ZFSSetArg = "set"
ZFSGetArg = "get"
ZFSListArg = "list"
)
@ -270,8 +271,26 @@ func UmountZFSDataset(vol *apis.ZFSVolume) error {
return SetDatasetMountProp(volume, "none")
}
// SetZvolProp sets the volume property
func SetZvolProp(vol *apis.ZFSVolume) error {
// GetVolumeProperty gets zfs properties for the volume
func GetVolumeProperty(vol *apis.ZFSVolume, prop string) (string, error) {
var ZFSVolArg []string
volume := vol.Spec.PoolName + "/" + vol.Name
ZFSVolArg = append(ZFSVolArg, ZFSGetArg, "-pH", "-o", "value", prop, volume)
cmd := exec.Command(ZFSVolCmd, ZFSVolArg...)
out, err := cmd.CombinedOutput()
if err != nil {
logrus.Errorf("zfs: could not get %s on dataset %v cmd %v error: %s",
prop, volume, ZFSVolArg, string(out))
return "", err
}
val := out[:len(out)-1]
return string(val), nil
}
// SetVolumeProp sets the volume property
func SetVolumeProp(vol *apis.ZFSVolume) error {
var err error
volume := vol.Spec.PoolName + "/" + vol.Name