Oved Ourfali has uploaded a new change for review.

Change subject: core: fix class cast exception
......................................................................

core: fix class cast exception

This patch checks whether the mem size and CPU cores are integers or
strings, as it was changed recently in VDSM.

Change-Id: Ie35ada2685d71c6b295e3f39811d3f592d690fb3
Signed-off-by: Oved Ourfali <[email protected]>
---
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
1 file changed, 12 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/70/18170/1

diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
index 62c0c6a..4c5a266 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
@@ -1622,14 +1622,24 @@
                     vmStatic.setOrigin(OriginType.EXTERNAL);
                 }
 
-                vmStatic.setNumOfSockets(Integer.parseInt((String) 
vmInfo.get(VdsProperties.num_of_cpus)));
-                vmStatic.setMemSizeMb(Integer.parseInt((String) 
vmInfo.get(VdsProperties.mem_size_mb)));
+                
vmStatic.setNumOfSockets(parseIntVdsProperty(vmInfo.get(VdsProperties.num_of_cpus)));
+                
vmStatic.setMemSizeMb(parseIntVdsProperty(vmInfo.get(VdsProperties.mem_size_mb)));
+
                 _externalVmsToAdd.add(vmStatic);
                 log.infoFormat("Importing VM {0} as {1}, as it is running on 
the on Host, but does not exist in the engine.", vmNameOnHost, 
vmStatic.getName());
             }
         }
     }
 
+    // Some properties were changed recently from String to Integer
+    // This method checks what type is the property, and returns int
+    private int parseIntVdsProperty(Object vdsProperty) {
+        if (vdsProperty instanceof Integer) {
+            return (Integer) vdsProperty;
+        } else {
+            return Integer.parseInt((String) vdsProperty);
+        }
+    }
 
     private void updateRepository(List<VM> running) {
         for (VmInternalData vmInternalData : _runningVms.values()) {


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

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

Reply via email to