Liron Aravot has uploaded a new change for review.

Change subject: core: validate that lun has valid LunType
......................................................................

core: validate that lun has valid LunType

adding lun disk through rest API could be done with no lun type which
led to save the lun connections with UNKNOWN lun type. Having the lun
connections without 'real' type caused to NPE in various cases.

Change-Id: I302b399fd93419fb1f621fd315b50d5971ae9c11
Signed-off-by: Liron Aravot <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddDiskCommand.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java
M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
M 
frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
6 files changed, 16 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/37/8437/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 6951ab1..be670ce 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
@@ -96,12 +96,16 @@
     }
 
     private boolean checkIfLunDiskCanBeAdded() {
-        boolean returnValue = true;
-        if (getDiskLunMapDao().getDiskIdByLunId(((LunDisk) 
getParameters().getDiskInfo()).getLun().getLUN_id()) != null) {
-            returnValue = false;
-            
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_DISK_LUN_IS_ALREADY_IN_USE);
+        LUNs lun = ((LunDisk) getParameters().getDiskInfo()).getLun();
+        if (lun.getLunType() == StorageType.UNKNOWN) {
+            
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_DISK_LUN_HAS_NO_VALID_TYPE);
+            return false;
         }
-        return returnValue;
+        if (getDiskLunMapDao().getDiskIdByLunId(lun.getLUN_id()) != null) {
+            
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_DISK_LUN_IS_ALREADY_IN_USE);
+            return false;
+        }
+        return true;
     }
 
     private boolean checkIfImageDiskCanBeAdded(VM vm) {
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java
index ea944ad..b00e470 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java
@@ -107,6 +107,7 @@
     ACTION_TYPE_FAILED_DISK_MAX_SIZE_EXCEEDED,
     ACTION_TYPE_FAILED_DISK_CONFIGURATION_NOT_SUPPORTED,
     ACTION_TYPE_FAILED_DISK_LUN_IS_ALREADY_IN_USE,
+    ACTION_TYPE_FAILED_DISK_LUN_HAS_NO_VALID_TYPE,
     ACTION_TYPE_FAILED_MIGRATION_IN_PROGRESS,
     ACTION_TYPE_FAILED_MIGRATION_TO_SAME_HOST,
     ACTION_TYPE_FAILED_VDS_VM_CLUSTER,
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
index 1f6c0c3..39277fb 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -162,6 +162,7 @@
 ACTION_TYPE_FAILED_DEDICATED_VDS_NOT_IN_SAME_CLUSTER=Cannot ${action} ${type}. 
Dedicated Host Cluster is not identical to VM Cluster.
 ACTION_TYPE_FAILED_DISK_CONFIGURATION_NOT_SUPPORTED=Cannot ${action} ${type}. 
The selected disk configuration is not supported.
 ACTION_TYPE_FAILED_DISK_LUN_IS_ALREADY_IN_USE=Cannot ${action} ${type}. The 
provided lun is used by another disk.
+ACTION_TYPE_FAILED_DISK_LUN_HAS_NO_VALID_TYPE=Cannot ${action} ${type}. The 
provided lun has no valid lun type.
 ACTION_TYPE_FAILED_MIGRATION_IN_PROGRESS=Cannot ${action} ${type}. VM 
migration is in progress
 ACTION_TYPE_FAILED_MIGRATION_TO_SAME_HOST=Cannot ${action} ${type}. source and 
destination is the same.
 ACTION_TYPE_FAILED_INVALID_CUSTOM_VM_PROPERTIES_INVALID_SYNTAX=Cannot 
${action} ${type} if custom VM properties are in invalid format. Please check 
the input.
diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
index d15f358..6393079 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
@@ -415,6 +415,9 @@
     @DefaultStringValue("Cannot ${action} ${type}. The provided lun is used by 
another disk.")
     String ACTION_TYPE_FAILED_DISK_LUN_IS_ALREADY_IN_USE();
 
+    @DefaultStringValue("Cannot ${action} ${type}. The provided lun has no 
valid lun type.")
+    String ACTION_TYPE_FAILED_DISK_LUN_HAS_NO_VALID_TYPE();
+
     @DefaultStringValue("Cannot ${action} ${type}. source and destination is 
the same.")
     String ACTION_TYPE_FAILED_MIGRATION_TO_SAME_HOST();
 
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index 9478c2b..84dd2a7 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -161,6 +161,7 @@
 ACTION_TYPE_FAILED_DEDICATED_VDS_NOT_IN_SAME_CLUSTER=Cannot ${action} ${type}. 
Dedicated Host Cluster is not identical to VM Cluster.
 ACTION_TYPE_FAILED_DISK_CONFIGURATION_NOT_SUPPORTED=Cannot ${action} ${type}. 
The selected disk configuration is not supported.
 ACTION_TYPE_FAILED_DISK_LUN_IS_ALREADY_IN_USE=Cannot ${action} ${type}. The 
provided lun is used by another disk.
+ACTION_TYPE_FAILED_DISK_LUN_HAS_NO_VALID_TYPE=Cannot ${action} ${type}. The 
provided lun has no valid lun type.
 ACTION_TYPE_FAILED_MIGRATION_IN_PROGRESS=Cannot ${action} ${type}. VM 
migration is in progress
 ACTION_TYPE_FAILED_MIGRATION_TO_SAME_HOST=Cannot ${action} ${type}. source and 
destination is the same.
 ACTION_TYPE_FAILED_INVALID_CUSTOM_VM_PROPERTIES_INVALID_SYNTAX=Cannot 
${action} ${type} if custom VM properties are in invalid format. Please check 
the input.
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index 61207fb..3d77e37 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -158,6 +158,7 @@
 ACTION_TYPE_FAILED_DISK_SPACE_LOW=Cannot ${action} ${type}. Low disk space on 
relevant Storage Domain.
 ACTION_TYPE_FAILED_DEDICATED_VDS_NOT_IN_SAME_CLUSTER=Cannot ${action} ${type}. 
Dedicated Host Cluster is not identical to VM Cluster.
 ACTION_TYPE_FAILED_DISK_CONFIGURATION_NOT_SUPPORTED=Cannot ${action} ${type}. 
The selected disk configuration is not supported.
+ACTION_TYPE_FAILED_DISK_LUN_HAS_NO_VALID_TYPE=Cannot ${action} ${type}. The 
provided lun has no valid lun type.
 ACTION_TYPE_FAILED_DISK_LUN_IS_ALREADY_IN_USE=Cannot ${action} ${type}. The 
provided lun is used by another disk.
 ACTION_TYPE_FAILED_MIGRATION_IN_PROGRESS=Cannot ${action} ${type}. VM 
migration is in progress
 ACTION_TYPE_FAILED_MIGRATION_TO_SAME_HOST=Cannot ${action} ${type}. source and 
destination is the same.


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I302b399fd93419fb1f621fd315b50d5971ae9c11
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