cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kis...@apache.org
Subject [2/2] git commit: updated refs/heads/master to 0eb67bf
Date Fri, 09 Aug 2013 09:24:57 GMT
CLOUDSTACK-4146, CLOUDSTACK-4147: Fix KVM snapshot upgrade.
when migrating KVM snapshot path, CONCAT is not required. back_snap_id is complete path for
KVM snapshots


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

Branch: refs/heads/master
Commit: 0eb67bff12eca324d2421358a13057db81c0e41b
Parents: 32701f0
Author: Kishan Kavala <kishan@cloud.com>
Authored: Fri Aug 9 14:45:37 2013 +0530
Committer: Kishan Kavala <kishan@cloud.com>
Committed: Fri Aug 9 14:50:26 2013 +0530

----------------------------------------------------------------------
 .../src/com/cloud/upgrade/dao/Upgrade410to420.java     | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0eb67bff/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 43931e8..fbec107 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
@@ -1293,7 +1293,7 @@ public class Upgrade410to420 implements DbUpgrade {
                 // Above path should change to /snapshots/1/2/6/i-2-6-VM_ROOT-6_20121219072022
                 int index = backUpPath.indexOf("snapshots"+File.separator);
                 if (index > 1){
-                    String correctedPath = File.separator + backUpPath.substring(index);
+                    String correctedPath = backUpPath.substring(index);
                     s_logger.debug("Updating Snapshot with id: "+id+" original backup path:
"+backUpPath+ " updated backup path: "+correctedPath);
                     pstmt = conn.prepareStatement("UPDATE `cloud`.`snapshots` set backup_snap_id=?
where id = ?");
                     pstmt.setString(1, correctedPath);
@@ -1960,10 +1960,17 @@ public class Upgrade410to420 implements DbUpgrade {
 
         s_logger.debug("Updating snapshot_store_ref table from snapshots table");
         try {
+            //Update all snapshots except KVM snapshots
             snapshotStoreInsert = conn
-                    .prepareStatement("INSERT INTO `cloud`.`snapshot_store_ref` (store_id,
 snapshot_id, created, size, parent_snapshot_id, install_path, volume_id, update_count, ref_cnt,
store_role, state) select sechost_id, id, created, size, prev_snap_id, CONCAT('snapshots',
'/', account_id, '/', volume_id, '/', backup_snap_id), volume_id, 0, 0, 'Image', 'Ready' from
`cloud`.`snapshots` where status = 'BackedUp' and sechost_id is not null and removed is null");
+                    .prepareStatement("INSERT INTO `cloud`.`snapshot_store_ref` (store_id,
 snapshot_id, created, size, parent_snapshot_id, install_path, volume_id, update_count, ref_cnt,
store_role, state) select sechost_id, id, created, size, prev_snap_id, CONCAT('snapshots',
'/', account_id, '/', volume_id, '/', backup_snap_id), volume_id, 0, 0, 'Image', 'Ready' from
`cloud`.`snapshots` where status = 'BackedUp' and hypervisor_type <> 'KVM' and sechost_id
is not null and removed is null");
             int rowCount = snapshotStoreInsert.executeUpdate();
-            s_logger.debug("Insert modified " + rowCount + " rows");
+            s_logger.debug("Inserted " + rowCount + " snapshots into snapshot_store_ref");
+
+            //backsnap_id for KVM snapshots is complate path. CONCAT is not required
+            snapshotStoreInsert = conn
+                    .prepareStatement("INSERT INTO `cloud`.`snapshot_store_ref` (store_id,
 snapshot_id, created, size, parent_snapshot_id, install_path, volume_id, update_count, ref_cnt,
store_role, state) select sechost_id, id, created, size, prev_snap_id, backup_snap_id, volume_id,
0, 0, 'Image', 'Ready' from `cloud`.`snapshots` where status = 'BackedUp' and hypervisor_type
= 'KVM' and sechost_id is not null and removed is null");
+            rowCount = snapshotStoreInsert.executeUpdate();
+            s_logger.debug("Inserted " + rowCount + " KVM snapshots into snapshot_store_ref");
         }
         catch (SQLException e) {
             String msg = "Unable to migrate snapshot_store_ref." + e.getMessage();


Mime
View raw message