Updated Branches: refs/heads/4.2-forward d28cca7bf -> 8dfd34cd7
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/f4e4be01 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f4e4be01 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f4e4be01 Branch: refs/heads/4.2-forward Commit: f4e4be01ff1f7cd2d1aafb2bb3dc2b4cd94cec58 Parents: d28cca7 Author: Prachi Damle <[email protected]> Authored: Fri Sep 13 13:46:29 2013 -0700 Committer: Prachi Damle <[email protected]> Committed: Fri Sep 13 16:55:37 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/f4e4be01/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 3c753e9..43f03c0 100755 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java @@ -83,7 +83,7 @@ public class Upgrade410to420 implements DbUpgrade { createPlaceHolderNics(conn); updateRemoteAccessVpn(conn); updateSystemVmTemplates(conn); - updateCluster_details(conn); + updateOverCommitRatioClusterDetails(conn); updatePrimaryStore(conn); addEgressFwRulesForSRXGuestNw(conn); upgradeEIPNetworkOfferings(conn); @@ -898,7 +898,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; @@ -907,7 +907,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=?"); @@ -926,7 +926,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();
