|
@@ -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
|
|
|
|
|
- cmd := "ls /dev/disk/by-path | grep \"" + v.TargetIQN + "\" | head -n 1"
|
|
|
|
|
- out, errMsg := util.ExecuteCommandString(cmd)
|
|
|
|
|
|
|
+ out := ""
|
|
|
|
|
+ errMsg := ""
|
|
|
|
|
|
|
|
- if len(out) > 0 {
|
|
|
|
|
- logrus.Debug(out)
|
|
|
|
|
- }
|
|
|
|
|
- if len(errMsg) > 0 {
|
|
|
|
|
- err := fmt.Errorf("Unable to find device: %s", errMsg)
|
|
|
|
|
- return err
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ diskPathFolder := "/dev/disk/by-path"
|
|
|
|
|
+ fi, err := os.Lstat(diskPathFolder)
|
|
|
|
|
+ if os.IsNotExist(err) {
|
|
|
|
|
+ // Disk By Path doesn't exist
|
|
|
|
|
|
|
|
- cmd = "readlink -nf /dev/disk/by-path/" + out
|
|
|
|
|
- out, errMsg = util.ExecuteCommandString(cmd)
|
|
|
|
|
|
|
+ iscsiPathFolder := "/host/tmp/iscsi"
|
|
|
|
|
+ fi, err = os.Lstat(iscsiPathFolder)
|
|
|
|
|
+ if os.IsNotExist(err) {
|
|
|
|
|
+ // iSCSI Administration folder doesn't exist
|
|
|
|
|
|
|
|
- if len(out) > 0 {
|
|
|
|
|
- logrus.Debug(out)
|
|
|
|
|
- }
|
|
|
|
|
- if len(errMsg) > 0 {
|
|
|
|
|
- err := fmt.Errorf("Unable to locate device: %s", errMsg)
|
|
|
|
|
- return err
|
|
|
|
|
|
|
+ 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
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ _ = 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 {
|