diff --git a/server/src/com/cloud/upgrade/dao/Upgrade410to420.java b/server/src/com/cloud/upgrade/dao/Upgrade410to420.java index d26da4dc916..8ce118f3cbc 100644 --- a/server/src/com/cloud/upgrade/dao/Upgrade410to420.java +++ b/server/src/com/cloud/upgrade/dao/Upgrade410to420.java @@ -76,8 +76,45 @@ public class Upgrade410to420 implements DbUpgrade { } } } + updateCluster_details(conn); } + //update the cluster_details table with default overcommit ratios. + private void updateCluster_details(Connection conn) { + PreparedStatement pstmt = null; + PreparedStatement pstmt1 = null; + PreparedStatement pstmt2 =null; + ResultSet rs = null; + + try { + pstmt = conn.prepareStatement("select id from `cloud`.`cluster`"); + pstmt1=conn.prepareStatement("INSERT INTO `cloud`.`cluster_details` (cluster_id, name, value) VALUES(?, 'cpuOvercommitRatio', '1')"); + pstmt2=conn.prepareStatement("INSERT INTO `cloud`.`cluster_details` (cluster_id, name, value) VALUES(?, 'memoryOvercommitRatio', '1')"); + rs = pstmt.executeQuery(); + while (rs.next()) { + long id = rs.getLong(1); + //update cluster_details table with the default overcommit ratios. + pstmt1.setLong(1,id); + pstmt1.execute(); + pstmt2.setLong(1,id); + pstmt2.execute(); + } + } catch (SQLException e) { + throw new CloudRuntimeException("Unable to update cluster_details with default overcommit ratios.", e); + } finally { + try { + if (rs != null) { + rs.close(); + } + if (pstmt != null) { + pstmt.close(); + } + } catch (SQLException e) { + } + } + } + + @Override public File[] getCleanupScripts() { String script = Script.findScript("", "db/schema-410to420-cleanup.sql");