Martin Peřina has uploaded a new change for review.

Change subject: core: webadmin: Fix NPE in VdsArchitectureHelper
......................................................................

core: webadmin: Fix NPE in VdsArchitectureHelper

Fixes NullPointerException in VdsArchitectureHelper which can occur if
we try to test fence agent settings for a new host which was not yet
saved in database.

Change-Id: I361c930d01a17da8bc1085286fdb845af0b5c237
Bug-Url: https://bugzilla.redhat.com/1205584
Signed-off-by: Martin Perina <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetNewVdsFenceStatusQuery.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsArchitectureHelper.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/GetNewVdsFenceStatusParameters.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java
4 files changed, 19 insertions(+), 4 deletions(-)


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

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetNewVdsFenceStatusQuery.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetNewVdsFenceStatusQuery.java
index 93263f0..3e95a5c 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetNewVdsFenceStatusQuery.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetNewVdsFenceStatusQuery.java
@@ -23,6 +23,7 @@
         VDS tempVar = new VDS();
         tempVar.setId((Guid) ((id != null) ? id : Guid.Empty));
         tempVar.setStoragePoolId(getParameters().getStoragePoolId());
+        tempVar.setVdsGroupId(getParameters().getVdsGroupId());
         if (getParameters().getOrder() == FenceAgentOrder.Primary) {
         tempVar.setManagementIp(getParameters().getManagementIp());
         tempVar.setPmOptionsMap(getParameters().getFencingOptions());
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsArchitectureHelper.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsArchitectureHelper.java
index fd5c909..f4a9ed4 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsArchitectureHelper.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsArchitectureHelper.java
@@ -23,11 +23,14 @@
     public static ArchitectureType getArchitecture(VdsStatic host) {
         VDSGroup cluster = 
DbFacade.getInstance().getVdsGroupDao().get(host.getVdsGroupId());
         VdsDynamic vdsDynamic = 
DbFacade.getInstance().getVdsDynamicDao().get(host.getId());
-        ServerCpu cpu = 
CpuFlagsManagerHandler.FindMaxServerCpuByFlags(vdsDynamic.getcpu_flags(), 
cluster.getcompatibility_version());
-        if (cpu != null && cpu.getArchitecture() != null) {
-            return cpu.getArchitecture();
+        if (vdsDynamic != null) {
+            ServerCpu cpu = 
CpuFlagsManagerHandler.FindMaxServerCpuByFlags(vdsDynamic.getcpu_flags(),
+                    cluster.getcompatibility_version());
+            if (cpu != null && cpu.getArchitecture() != null) {
+                return cpu.getArchitecture();
+            }
         }
-        // take architecture from the cluster if it is null on the host level
+        // take architecture from the cluster if it is null on the host level 
or host is not yet saved in db
         log.info("Failed to get architecture type from host information for 
host '{}'. Using cluster '{}' architecture value instead.", host.getName(), 
cluster.getName());
         return cluster.getArchitecture();
     }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/GetNewVdsFenceStatusParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/GetNewVdsFenceStatusParameters.java
index 0d075bf..412644c 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/GetNewVdsFenceStatusParameters.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/GetNewVdsFenceStatusParameters.java
@@ -101,4 +101,14 @@
     public void setPmProxyPreferences(String pmProxyPreferences) {
         this.pmProxyPreferences = pmProxyPreferences;
     }
+
+    private Guid vdsGroupId;
+
+    public Guid getVdsGroupId() {
+        return vdsGroupId;
+    }
+
+    public void setVdsGroupId(Guid vdsGroupId) {
+        this.vdsGroupId = vdsGroupId;
+    }
 }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java
index ce13ee6..6cdfa2b 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java
@@ -1620,6 +1620,7 @@
         param.setStoragePoolId(cluster.getStoragePoolId() != null ? 
cluster.getStoragePoolId() : Guid.Empty);
         param.setFencingOptions(getPmOptionsMap());
         param.setPmProxyPreferences(getPmProxyPreferences());
+        param.setVdsGroupId(cluster.getId());
 
         Frontend.getInstance().runQuery(VdcQueryType.GetNewVdsFenceStatus, 
param, new AsyncQuery(this, new INewAsyncCallback() {
 


-- 
To view, visit https://gerrit.ovirt.org/39181
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I361c930d01a17da8bc1085286fdb845af0b5c237
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Martin Peřina <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to