CLOUDSTACK-5796. [VMware] Size column is not getting updated in snapshot_store_ref table when a snapshot is backed up in secondary storage.

Calculate and update the size of a backed up snapshot. This snapshot size is in turn used to update the secondary_storage count for an account.
(cherry picked from commit e8ba2d0850)

Signed-off-by: Animesh Chaturvedi <animesh@apache.org>
This commit is contained in:
Likitha Shetty 2014-01-27 17:52:16 +05:30 committed by Animesh Chaturvedi
parent ce1b393f73
commit d4a3f7be81
1 changed files with 19 additions and 2 deletions

View File

@ -985,7 +985,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
String backupUuid = UUID.randomUUID().toString();
Pair<String, String[]> snapshotInfo = exportVolumeToSecondaryStroage(vmMo, volumePath, secStorageUrl,
installPath, backupUuid, workerVmName);
return new Ternary<String, String, String[]>(backupUuid + "/" + backupUuid, snapshotInfo.first(), snapshotInfo.second());
return new Ternary<String, String, String[]>(backupUuid, snapshotInfo.first(), snapshotInfo.second());
}
@Override
@ -1067,8 +1067,25 @@ public class VmwareStorageProcessor implements StorageProcessor {
answer = new CopyCmdAnswer(details);
} else {
details = "Successfully backedUp the snapshot with Uuid: " + snapshotUuid + " to secondary storage.";
// Get snapshot physical size
long physicalSize = 0l;
String secondaryMountPoint = mountService.getMountPoint(secondaryStorageUrl);
String snapshotDir = destSnapshot.getPath() + "/" + snapshotBackupUuid;
File[] files = new File(secondaryMountPoint + "/" + snapshotDir).listFiles();
if(files != null) {
for(File file : files) {
String fileName = file.getName();
if(fileName.toLowerCase().startsWith(snapshotBackupUuid) && fileName.toLowerCase().endsWith(".vmdk")) {
physicalSize = new File(secondaryMountPoint + "/" + snapshotDir + "/" + fileName).length();
break;
}
}
}
SnapshotObjectTO newSnapshot = new SnapshotObjectTO();
newSnapshot.setPath(destSnapshot.getPath() + "/" + snapshotBackupUuid);
newSnapshot.setPath(snapshotDir + "/" + snapshotBackupUuid);
newSnapshot.setPhysicalSize(physicalSize);
answer = new CopyCmdAnswer(newSnapshot);
}
} finally {