Updated Branches:
  refs/heads/master 723ef6e49 -> 62d60c2b7

CLOUDSTACK-4668: Upgrade to 4.2 fails with NullPointerException when 
hypervisor_type is null for a cluster entry

Changes:
- Care for null value during comparing the hypervisor_type
- Do not consider removed clusters
- Method rename according to coding conventions


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f2ea699d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f2ea699d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f2ea699d

Branch: refs/heads/master
Commit: f2ea699d12e0b58f25f86b38a6018fa1c0a5d2f9
Parents: 723ef6e
Author: Prachi Damle <[email protected]>
Authored: Fri Sep 13 13:46:29 2013 -0700
Committer: Prachi Damle <[email protected]>
Committed: Wed Sep 18 16:52:01 2013 -0700

----------------------------------------------------------------------
 engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f2ea699d/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java 
b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
index 02dd9c5..9bd6116 100755
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
@@ -84,7 +84,7 @@ public class Upgrade410to420 implements DbUpgrade {
         createPlaceHolderNics(conn);
         updateRemoteAccessVpn(conn);
         updateSystemVmTemplates(conn);
-        updateCluster_details(conn);
+        updateOverCommitRatioClusterDetails(conn);
         updatePrimaryStore(conn);
         addEgressFwRulesForSRXGuestNw(conn);
         upgradeEIPNetworkOfferings(conn);
@@ -853,7 +853,7 @@ public class Upgrade410to420 implements DbUpgrade {
     }
 
     //update the cluster_details table with default overcommit ratios.
-    private void updateCluster_details(Connection conn) {
+    private void updateOverCommitRatioClusterDetails(Connection conn) {
         PreparedStatement pstmt = null;
         PreparedStatement pstmt1 = null;
         PreparedStatement pstmt2 =null;
@@ -862,7 +862,7 @@ public class Upgrade410to420 implements DbUpgrade {
         ResultSet rscpu_global = null;
         ResultSet rsmem_global = null;
         try {
-            pstmt = conn.prepareStatement("select id, hypervisor_type from 
`cloud`.`cluster`");
+            pstmt = conn.prepareStatement("select id, hypervisor_type from 
`cloud`.`cluster` WHERE removed IS NULL");
             pstmt1=conn.prepareStatement("INSERT INTO 
`cloud`.`cluster_details` (cluster_id, name, value)  VALUES(?, 
'cpuOvercommitRatio', ?)");
             pstmt2=conn.prepareStatement("INSERT INTO 
`cloud`.`cluster_details` (cluster_id, name, value)  VALUES(?, 
'memoryOvercommitRatio', ?)");
             pstmt3=conn.prepareStatement("select value from 
`cloud`.`configuration` where name=?");
@@ -881,7 +881,7 @@ public class Upgrade410to420 implements DbUpgrade {
             while (rs1.next()) {
                 long id = rs1.getLong(1);
                 String hypervisor_type = rs1.getString(2);
-                if 
(hypervisor_type.equalsIgnoreCase(HypervisorType.VMware.toString())) {
+                if 
(HypervisorType.VMware.toString().equalsIgnoreCase(hypervisor_type)) {
                     pstmt1.setLong(1,id);
                     pstmt1.setString(2,global_cpu_overprovisioning_factor);
                     pstmt1.execute();

Reply via email to