Skip to content

Commit e8ba2d0

Browse files
author
Likitha Shetty
committed
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.
1 parent 6d14751 commit e8ba2d0

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

‎plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ private Ternary<String, String, String[]> backupSnapshotToSecondaryStorage(Virtu
985985
String backupUuid = UUID.randomUUID().toString();
986986
Pair<String, String[]> snapshotInfo = exportVolumeToSecondaryStroage(vmMo, volumePath, secStorageUrl,
987987
installPath, backupUuid, workerVmName);
988-
return new Ternary<String, String, String[]>(backupUuid + "/" + backupUuid, snapshotInfo.first(), snapshotInfo.second());
988+
return new Ternary<String, String, String[]>(backupUuid, snapshotInfo.first(), snapshotInfo.second());
989989
}
990990

991991
@Override
@@ -1067,8 +1067,25 @@ public Answer backupSnapshot(CopyCommand cmd) {
10671067
answer = new CopyCmdAnswer(details);
10681068
} else {
10691069
details = "Successfully backedUp the snapshot with Uuid: " + snapshotUuid + " to secondary storage.";
1070+
1071+
// Get snapshot physical size
1072+
long physicalSize = 0l;
1073+
String secondaryMountPoint = mountService.getMountPoint(secondaryStorageUrl);
1074+
String snapshotDir = destSnapshot.getPath() + "/" + snapshotBackupUuid;
1075+
File[] files = new File(secondaryMountPoint + "/" + snapshotDir).listFiles();
1076+
if(files != null) {
1077+
for(File file : files) {
1078+
String fileName = file.getName();
1079+
if(fileName.toLowerCase().startsWith(snapshotBackupUuid) && fileName.toLowerCase().endsWith(".vmdk")) {
1080+
physicalSize = new File(secondaryMountPoint + "/" + snapshotDir + "/" + fileName).length();
1081+
break;
1082+
}
1083+
}
1084+
}
1085+
10701086
SnapshotObjectTO newSnapshot = new SnapshotObjectTO();
1071-
newSnapshot.setPath(destSnapshot.getPath() + "/" + snapshotBackupUuid);
1087+
newSnapshot.setPath(snapshotDir + "/" + snapshotBackupUuid);
1088+
newSnapshot.setPhysicalSize(physicalSize);
10721089
answer = new CopyCmdAnswer(newSnapshot);
10731090
}
10741091
} finally {

0 commit comments

Comments
 (0)