Tal Nisan has uploaded a new change for review.

Change subject: webadmin: Display correct error when adding new storage
......................................................................

webadmin: Display correct error when adding new storage

When adding a new Storage Domain (of NFS/Local type) the error displayed
when the connection was failed was always "Error creating a storage domain"
instead of the actual error from VDSM (no permission error etc.), the connect
command was changed to propegated the VDSM error to the client there it will
be tranlsated and be displayed as the translated user friendly value

Change-Id: Ib8f721d3f10596253ca194a36139ba9ebcdff246
Bug-Url: https://bugzilla.redhat.com/843440
Signed-off-by: Tal Nisan <tni...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddStorageServerConnectionCommand.java
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java
M 
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
M 
frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
4 files changed, 19 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/81/13681/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddStorageServerConnectionCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddStorageServerConnectionCommand.java
index 631fd80..3c4f232 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddStorageServerConnectionCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddStorageServerConnectionCommand.java
@@ -13,6 +13,8 @@
 import org.ovirt.engine.core.common.businessentities.StorageType;
 import org.ovirt.engine.core.common.businessentities.VDSStatus;
 import org.ovirt.engine.core.common.businessentities.storage_pool;
+import org.ovirt.engine.core.common.errors.VdcBllErrors;
+import org.ovirt.engine.core.common.errors.VdcFault;
 import org.ovirt.engine.core.common.locks.LockingGroup;
 import org.ovirt.engine.core.common.utils.Pair;
 import org.ovirt.engine.core.common.validation.NfsMountPointConstraint;
@@ -34,16 +36,22 @@
     protected void executeCommand() {
         StorageServerConnections currConnection = getConnection();
         boolean isValidConnection = true;
-        isValidConnection = connect(getVds().getId()).getFirst();
+        Pair<Boolean, Integer> result = connect(getVds().getId());
+        isValidConnection = result.getFirst();
 
         // Add storage Connection to the database.
         if (isValidConnection && 
(StringUtils.isNotEmpty(currConnection.getid())
                 || 
getDbFacade().getStorageServerConnectionDao().get(currConnection.getid()) == 
null)) {
             currConnection.setid(Guid.NewGuid().toString());
             getDbFacade().getStorageServerConnectionDao().save(currConnection);
+            getReturnValue().setActionReturnValue(getConnection().getid());
+            setSucceeded(true);
         }
-        getReturnValue().setActionReturnValue(getConnection().getid());
-        setSucceeded(true);
+        else {
+            VdcFault fault = new VdcFault();
+            fault.setError(VdcBllErrors.forValue(result.getSecond()));
+            getReturnValue().setFault(fault);
+        }
     }
 
     @Override
diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java
index d04484a..53e688d 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java
@@ -800,7 +800,11 @@
 
     private static void runActionExecutionFailed(VdcActionType actionType, 
VdcFault fault) {
         if (getEventsHandler() != null) {
-            
fault.setMessage(vdsmErrorsTranslator.TranslateErrorTextSingle(fault.getMessage()));
+            // The VdcFault error property takes precedence, if it's null we 
try to translate the message property
+            String translatedMessage =
+                    
vdsmErrorsTranslator.TranslateErrorTextSingle(fault.getError() == null ? 
fault.getMessage()
+                            : fault.getError().toString());
+            fault.setMessage(translatedMessage);
             getEventsHandler().runActionExecutionFailed(actionType, fault);
         }
     }
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
index f204b3e..5670e92 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
+++ 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
@@ -458,6 +458,8 @@
 
        String VdcActionType___AttachUserToVmFromPoolAndRun();
 
+       String VdcActionType___AddStorageServerConnection();
+
        String VdcActionType___DataCenters();
 
        String VdcActionType___Clusters();
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
 
b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
index f3b1c18..5ab208f 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
+++ 
b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
@@ -226,6 +226,7 @@
 VdcActionType___AddVmAndAttachToUser=Add VM and Attach to User
 VdcActionType___AttachUserToVmFromPool=Attach User to a specific VM from VM 
Pool
 VdcActionType___AttachUserToVmFromPoolAndRun=Run VM from VM Pool (User Portal)
+VdcActionType___AddStorageServerConnection=Add Storage Connection
 VdcActionType___DataCenters=Data Centers
 VdcActionType___Clusters=Clusters
 VdcActionType___Hosts=Hosts


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

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

Reply via email to