Liron Aravot has uploaded a new change for review.

Change subject: core: WIP: verify iscsi lun connection when adding lun disk
......................................................................

core: WIP: verify iscsi lun connection when adding lun disk

When adding a lun disk there's no validation whether the connection
details are valid. This patch attempts to connect the storage server
while adding a lun to validate the connections.

Change-Id: I8aa07be1fd6d6021481c8c0291458aff403304ee
Bug-Url: https://bugzilla.redhat.com/866580
Signed-off-by: Liron Aravot <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddDiskCommand.java
1 file changed, 20 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/00/8900/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddDiskCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddDiskCommand.java
index ada94b0..5a99b75 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddDiskCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddDiskCommand.java
@@ -12,6 +12,9 @@
 import org.ovirt.engine.core.bll.quota.StorageQuotaValidationParameter;
 import org.ovirt.engine.core.bll.snapshots.SnapshotsValidator;
 import org.ovirt.engine.core.bll.storage.StorageDomainCommandBase;
+import org.ovirt.engine.core.bll.storage.StorageHandlingCommandBase;
+import org.ovirt.engine.core.bll.storage.StorageHelperDirector;
+import 
org.ovirt.engine.core.bll.storage.ConnectAllHostsToLunCommand.ConnectAllHostsToLunCommandReturnValue;
 import org.ovirt.engine.core.bll.utils.PermissionSubject;
 import org.ovirt.engine.core.bll.utils.VmDeviceUtils;
 import org.ovirt.engine.core.bll.utils.WipeAfterDeleteUtils;
@@ -33,6 +36,7 @@
 import org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotType;
 import org.ovirt.engine.core.common.businessentities.StoragePoolIsoMapId;
 import org.ovirt.engine.core.common.businessentities.StorageType;
+import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VM;
 import org.ovirt.engine.core.common.businessentities.VMStatus;
 import org.ovirt.engine.core.common.businessentities.VmDeviceId;
@@ -42,6 +46,7 @@
 import 
org.ovirt.engine.core.common.businessentities.storage_server_connections;
 import org.ovirt.engine.core.common.config.Config;
 import org.ovirt.engine.core.common.config.ConfigValues;
+import org.ovirt.engine.core.common.errors.VdcBLLException;
 import org.ovirt.engine.core.common.locks.LockingGroup;
 import org.ovirt.engine.core.common.utils.VmDeviceType;
 import org.ovirt.engine.core.common.validation.group.UpdateEntity;
@@ -117,7 +122,21 @@
         if (getDiskLunMapDao().getDiskIdByLunId(lun.getLUN_id()) != null) {
             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_DISK_LUN_IS_ALREADY_IN_USE);
         }
-        return true;
+
+
+        List<VDS> vdss = 
StorageHandlingCommandBase.GetAllRunningVdssInPool(getStoragePool());
+        if (vdss.isEmpty()) {
+            return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_NO_VDS_IN_POOL);
+        }
+
+        try {
+            return StorageHelperDirector.getInstance()
+                    .getItem(getStorageDomain().getstorage_type())
+                    .ConnectStorageToLunByVdsId(null, vdss.get(0).getId(), 
lun, getStoragePool().getId());
+        } catch (VdcBLLException e) {
+            log.error(e);
+            return false;
+        }
     }
 
     private boolean checkIfImageDiskCanBeAdded(VM vm) {


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8aa07be1fd6d6021481c8c0291458aff403304ee
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Liron Aravot <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to