Maor Lipchuk has uploaded a new change for review.

Change subject: core: Fix IndexOutOfBoundsException in plug FC disk
......................................................................

core: Fix IndexOutOfBoundsException in plug FC disk

attach detach and plug disk throws an exception of index out of bounds
exception.
The reason for that is that the LUN FC which the disk is related to does not 
contains any
connections in it, compared to ISCSI lun which must have connections
related to it.

The proposed fix is to use FCP storage type if the LUN does not contain
any connections in it.

Change-Id: I6414445b9a74be299205ff7fc9a21d1388a29687
Bug-Url: https://bugzilla.redhat.com/882825
Signed-off-by: Maor Lipchuk <mlipc...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractDiskVmCommand.java
1 file changed, 17 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/24/9724/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractDiskVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractDiskVmCommand.java
index d66f29d..aee10ec 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractDiskVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractDiskVmCommand.java
@@ -11,6 +11,7 @@
 import org.ovirt.engine.core.common.businessentities.DiskInterface;
 import org.ovirt.engine.core.common.businessentities.LUNs;
 import org.ovirt.engine.core.common.businessentities.LunDisk;
+import org.ovirt.engine.core.common.businessentities.StorageType;
 import org.ovirt.engine.core.common.businessentities.VM;
 import org.ovirt.engine.core.common.businessentities.VMStatus;
 import org.ovirt.engine.core.common.businessentities.VmDevice;
@@ -51,11 +52,8 @@
             LunDisk lunDisk = (LunDisk) disk;
             if (commandType == VDSCommandType.HotPlugDisk) {
                 LUNs lun = lunDisk.getLun();
-                lun.setLunConnections(new 
ArrayList<storage_server_connections>(getDbFacade()
-                        .getStorageServerConnectionDao()
-                        .getAllForLun(lun.getLUN_id())));
                 if (!StorageHelperDirector.getInstance()
-                        
.getItem(lun.getLunConnections().get(0).getstorage_type())
+                        .getItem(getLunStorageType(lun))
                         .ConnectStorageToLunByVdsId(null,
                                 getVm().getrun_on_vds().getValue(),
                                 lun,
@@ -68,6 +66,21 @@
                 getVm().getId(), disk, vmDevice));
     }
 
+    /**
+     * Return the storage type which the Lun is related to. If the LUN has no 
connections we assume that it is FCP
+     * storage type, since FCP does not represent connections, if other wise, 
we return the storage type of the first
+     * connection
+     *
+     * @param lun
+     * @return
+     */
+    private StorageType getLunStorageType(LUNs lun) {
+        lun.setLunConnections(new 
ArrayList<storage_server_connections>(getDbFacade()
+                .getStorageServerConnectionDao()
+                .getAllForLun(lun.getLUN_id())));
+        return lun.getLunConnections().isEmpty() ? StorageType.FCP : 
lun.getLunConnections().get(0).getstorage_type();
+    }
+
     protected boolean isDiskPassPciAndIdeLimit(Disk diskInfo) {
         List<VmNetworkInterface> vmInterfaces = 
getVmNetworkInterfaceDao().getAllForVm(getVmId());
         List<Disk> allVmDisks = new 
ArrayList<Disk>(getVm().getDiskMap().values());


--
To view, visit http://gerrit.ovirt.org/9724
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6414445b9a74be299205ff7fc9a21d1388a29687
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Maor Lipchuk <mlipc...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to