mirror of https://github.com/apache/cloudstack.git
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.
This commit is contained in:
parent
39447cce6e
commit
4583bac05b
|
|
@ -957,7 +957,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
|
||||
|
|
@ -1040,8 +1040,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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue