CLOUDSTACK-1395 Upgrade script for cpu and ram overcommit. It sets the overcommit values of all the clusters to 1.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/355589c1 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/355589c1 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/355589c1 Branch: refs/heads/kvm-vnc-listen Commit: 355589c1f0c583cbbdc601f74dba504064f81bac Parents: 7a3a1c7 Author: Bharat Kumar <[email protected]> Authored: Mon Apr 1 10:43:16 2013 +0530 Committer: Abhinandan Prateek <[email protected]> Committed: Mon Apr 1 10:43:16 2013 +0530 ---------------------------------------------------------------------- .../src/com/cloud/upgrade/dao/Upgrade410to420.java | 37 +++++++++++++++ 1 files changed, 37 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/355589c1/server/src/com/cloud/upgrade/dao/Upgrade410to420.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/upgrade/dao/Upgrade410to420.java b/server/src/com/cloud/upgrade/dao/Upgrade410to420.java index d26da4d..8ce118f 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");
