Support Synology iSCSI administration

This commit is contained in:
2022-08-04 21:51:16 +02:00
parent d8f25cbba6
commit 1a58d00221
+66 -20
View File
@@ -282,31 +282,77 @@ func (d *iscsiDriver) mountVolume(v *iscsiVolume) error {
// Wait for Physical Volume to appear // Wait for Physical Volume to appear
time.Sleep(500 * time.Millisecond) time.Sleep(500 * time.Millisecond)
// Get target device out := ""
cmd := "ls /dev/disk/by-path | grep \"" + v.TargetIQN + "\" | head -n 1" errMsg := ""
out, errMsg := util.ExecuteCommandString(cmd)
if len(out) > 0 { diskPathFolder := "/dev/disk/by-path"
logrus.Debug(out) fi, err := os.Lstat(diskPathFolder)
} if os.IsNotExist(err) {
if len(errMsg) > 0 { // Disk By Path doesn't exist
err := fmt.Errorf("Unable to find device: %s", errMsg)
return err iscsiPathFolder := "/host/tmp/iscsi"
fi, err = os.Lstat(iscsiPathFolder)
if os.IsNotExist(err) {
// iSCSI Administration folder doesn't exist
return err
} else {
// iSCSI Administration folder exists, seen on Synology systems
// Get target device
cmd := "ls /host/tmp/iscsi | grep \"" + v.TargetIQN + "\" | head -n 1"
out, errMsg = util.ExecuteCommandString(cmd)
if len(out) > 0 {
logrus.Debug(out)
}
if len(errMsg) > 0 {
err := fmt.Errorf("Unable to find device: %s", errMsg)
return err
}
cmd = "readlink -nf /host/tmp/iscsi/" + out
out, errMsg = util.ExecuteCommandString(cmd)
if len(out) > 0 {
logrus.Debug(out)
}
if len(errMsg) > 0 {
err := fmt.Errorf("Unable to locate device: %s", errMsg)
return err
}
}
} else {
// Disk By Path exists
// Get target device
cmd := "ls /dev/disk/by-path | grep \"" + v.TargetIQN + "\" | head -n 1"
out, errMsg = util.ExecuteCommandString(cmd)
if len(out) > 0 {
logrus.Debug(out)
}
if len(errMsg) > 0 {
err := fmt.Errorf("Unable to find device: %s", errMsg)
return err
}
cmd = "readlink -nf /dev/disk/by-path/" + out
out, errMsg = util.ExecuteCommandString(cmd)
if len(out) > 0 {
logrus.Debug(out)
}
if len(errMsg) > 0 {
err := fmt.Errorf("Unable to locate device: %s", errMsg)
return err
}
} }
cmd = "readlink -nf /dev/disk/by-path/" + out _ = fi
out, errMsg = util.ExecuteCommandString(cmd)
if len(out) > 0 {
logrus.Debug(out)
}
if len(errMsg) > 0 {
err := fmt.Errorf("Unable to locate device: %s", errMsg)
return err
}
// Mount // Mount
cmd = "mount " + out + " " + v.Mountpoint cmd := "mount " + out + " " + v.Mountpoint
out, errMsg = util.ExecuteCommandString(cmd) out, errMsg = util.ExecuteCommandString(cmd)
if len(out) > 0 { if len(out) > 0 {