Support Synology iSCSI administration
This commit is contained in:
@@ -282,9 +282,52 @@ 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)
|
||||||
|
|
||||||
|
out := ""
|
||||||
|
errMsg := ""
|
||||||
|
|
||||||
|
diskPathFolder := "/dev/disk/by-path"
|
||||||
|
fi, err := os.Lstat(diskPathFolder)
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
// Disk By Path doesn't exist
|
||||||
|
|
||||||
|
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
|
// Get target device
|
||||||
cmd := "ls /dev/disk/by-path | grep \"" + v.TargetIQN + "\" | head -n 1"
|
cmd := "ls /dev/disk/by-path | grep \"" + v.TargetIQN + "\" | head -n 1"
|
||||||
out, errMsg := util.ExecuteCommandString(cmd)
|
out, errMsg = util.ExecuteCommandString(cmd)
|
||||||
|
|
||||||
if len(out) > 0 {
|
if len(out) > 0 {
|
||||||
logrus.Debug(out)
|
logrus.Debug(out)
|
||||||
@@ -304,9 +347,12 @@ func (d *iscsiDriver) mountVolume(v *iscsiVolume) error {
|
|||||||
err := fmt.Errorf("Unable to locate device: %s", errMsg)
|
err := fmt.Errorf("Unable to locate device: %s", errMsg)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = fi
|
||||||
|
|
||||||
// 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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user