mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-5701: physical size is not getting updated in snapshot_store_ref table.
This commit is contained in:
parent
e5283e966e
commit
3ad0e8fb47
@ -38,6 +38,7 @@ public class SnapshotObjectTO implements DataTO {
|
||||
private long id;
|
||||
private boolean quiescevm;
|
||||
private String[] parents;
|
||||
private Long physicalSize = (long) 0;
|
||||
|
||||
|
||||
public SnapshotObjectTO() {
|
||||
@ -94,6 +95,14 @@ public class SnapshotObjectTO implements DataTO {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public Long getPhysicalSize() {
|
||||
return this.physicalSize;
|
||||
}
|
||||
|
||||
public void setPhysicalSize(Long physicalSize ) {
|
||||
this.physicalSize = physicalSize;
|
||||
}
|
||||
|
||||
public VolumeObjectTO getVolume() {
|
||||
return volume;
|
||||
}
|
||||
|
||||
@ -278,6 +278,7 @@ public class SnapshotObject implements SnapshotInfo {
|
||||
} else if (answer instanceof CopyCmdAnswer) {
|
||||
SnapshotObjectTO snapshotTO = (SnapshotObjectTO)((CopyCmdAnswer)answer).getNewData();
|
||||
snapshotStore.setInstallPath(snapshotTO.getPath());
|
||||
snapshotStore.setSize(snapshotTO.getPhysicalSize());
|
||||
if (snapshotTO.getParentSnapshotPath() == null) {
|
||||
snapshotStore.setParentSnapshotId(0L);
|
||||
}
|
||||
|
||||
@ -115,6 +115,7 @@ public class ObjectInDataStoreManagerImpl implements ObjectInDataStoreManager {
|
||||
ss.setDataStoreId(dataStore.getId());
|
||||
ss.setRole(dataStore.getRole());
|
||||
ss.setVolumeId(snapshotInfo.getVolumeId());
|
||||
ss.setSize(snapshotInfo.getSize()); // this is the virtual size of snapshot in primary storage.
|
||||
SnapshotDataStoreVO snapshotDataStoreVO = snapshotDataStoreDao.findParent(dataStore.getRole(), dataStore.getId(), snapshotInfo.getVolumeId());
|
||||
if (snapshotDataStoreVO != null) {
|
||||
ss.setParentSnapshotId(snapshotDataStoreVO.getSnapshotId());
|
||||
|
||||
@ -1104,6 +1104,16 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
|
||||
}
|
||||
|
||||
protected Long getSnapshotSize(Connection conn, String primaryStorageSRUuid, String snapshotUuid, Boolean isISCSI, int wait) {
|
||||
String physicalSize = hypervisorResource.callHostPluginAsync(conn, "vmopsSnapshot", "getSnapshotSize", wait,
|
||||
"primaryStorageSRUuid", primaryStorageSRUuid, "snapshotUuid", snapshotUuid, "isISCSI", isISCSI.toString());
|
||||
if (physicalSize == null || physicalSize.isEmpty()) {
|
||||
return (long) 0;
|
||||
} else {
|
||||
return Long.parseLong(physicalSize);
|
||||
}
|
||||
}
|
||||
|
||||
protected String backupSnapshot(Connection conn, String primaryStorageSRUuid, String localMountPoint, String path, String secondaryStorageMountPath,
|
||||
String snapshotUuid, String prevBackupUuid, Boolean isISCSI, int wait) {
|
||||
String backupSnapshotUuid = null;
|
||||
@ -1134,7 +1144,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
// indicator of success.
|
||||
if (status != null && status.equalsIgnoreCase("1") && backupSnapshotUuid != null) {
|
||||
s_logger.debug("Successfully copied backupUuid: " + backupSnapshotUuid + " to secondary storage");
|
||||
return backupSnapshotUuid;
|
||||
return results;
|
||||
} else {
|
||||
errMsg =
|
||||
"Could not copy backupUuid: " + backupSnapshotUuid + " from primary storage " + primaryStorageSRUuid + " to secondary storage " +
|
||||
@ -1230,6 +1240,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
String details = null;
|
||||
String snapshotBackupUuid = null;
|
||||
boolean fullbackup = true;
|
||||
Long physicalSize = null;
|
||||
try {
|
||||
SR primaryStorageSR = hypervisorResource.getSRByNameLabelandHost(conn, primaryStorageNameLabel);
|
||||
if (primaryStorageSR == null) {
|
||||
@ -1276,6 +1287,8 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
snapshotSr = hypervisorResource.createNfsSRbyURI(conn, new URI(snapshotMountpoint), false);
|
||||
VDI backedVdi = hypervisorResource.cloudVDIcopy(conn, snapshotVdi, snapshotSr, wait);
|
||||
snapshotBackupUuid = backedVdi.getUuid(conn);
|
||||
String primarySRuuid = snapshotSr.getUuid(conn);
|
||||
physicalSize = getSnapshotSize(conn, primarySRuuid, snapshotBackupUuid, isISCSI, wait);
|
||||
|
||||
if (destStore instanceof SwiftTO) {
|
||||
try {
|
||||
@ -1328,9 +1341,12 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
throw new CloudRuntimeException("S3 upload of snapshots " + snapshotPaUuid + " failed");
|
||||
}
|
||||
} else {
|
||||
snapshotBackupUuid =
|
||||
String results =
|
||||
backupSnapshot(conn, primaryStorageSRUuid, localMountPoint, folder, secondaryStorageMountPath, snapshotUuid, prevBackupUuid, isISCSI, wait);
|
||||
|
||||
String[] tmp = results.split("#");
|
||||
snapshotBackupUuid = tmp[1];
|
||||
physicalSize = Long.parseLong(tmp[2]);
|
||||
finalPath = folder + File.separator + snapshotBackupUuid;
|
||||
}
|
||||
}
|
||||
@ -1339,6 +1355,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
|
||||
SnapshotObjectTO newSnapshot = new SnapshotObjectTO();
|
||||
newSnapshot.setPath(finalPath);
|
||||
newSnapshot.setPhysicalSize(physicalSize);
|
||||
if (fullbackup) {
|
||||
newSnapshot.setParentSnapshotPath(null);
|
||||
} else {
|
||||
|
||||
@ -487,6 +487,18 @@ def getVhdParent(session, args):
|
||||
|
||||
return baseCopyUuid
|
||||
|
||||
def getSnapshotSize(session, args):
|
||||
primaryStorageSRUuid = args['primaryStorageSRUuid']
|
||||
snapshotUuid = args['snapshotUuid']
|
||||
isISCSI = getIsTrueString(args['isISCSI'])
|
||||
|
||||
primarySRPath = getPrimarySRPath(primaryStorageSRUuid, isISCSI)
|
||||
logging.debug("primarySRPath: " + primarySRPath)
|
||||
|
||||
snapshotVHD = getVHD(snapshotUuid, isISCSI)
|
||||
snapshotPath = os.path.join(primarySRPath, snapshotVHD)
|
||||
physicalSize = vhdutil.getSizePhys(snapshotPath)
|
||||
return str(physicalSize)
|
||||
|
||||
def backupSnapshot(session, args):
|
||||
logging.debug("Called backupSnapshot with " + str(args))
|
||||
@ -515,6 +527,7 @@ def backupSnapshot(session, args):
|
||||
prevBackupUuid = prevBackupUuid.split("/")[-1]
|
||||
# Check existence of snapshot on primary storage
|
||||
isfile(baseCopyPath, isISCSI)
|
||||
physicalSize = vhdutil.getSizePhys(baseCopyPath)
|
||||
if prevBackupUuid:
|
||||
# Check existence of prevBackupFile
|
||||
prevBackupVHD = getBackupVHD(prevBackupUuid)
|
||||
@ -535,7 +548,7 @@ def backupSnapshot(session, args):
|
||||
# If there was a previous snapshot
|
||||
setParent(prevBackupFile, backupFile)
|
||||
|
||||
txt = "1#" + backupUuid
|
||||
txt = "1#" + backupUuid + "#" + str(physicalSize)
|
||||
return txt
|
||||
|
||||
@echo
|
||||
@ -596,6 +609,6 @@ def revert_memory_snapshot(session, args):
|
||||
return "0"
|
||||
|
||||
if __name__ == "__main__":
|
||||
XenAPIPlugin.dispatch({"getVhdParent":getVhdParent, "create_secondary_storage_folder":create_secondary_storage_folder, "delete_secondary_storage_folder":delete_secondary_storage_folder, "post_create_private_template":post_create_private_template, "backupSnapshot": backupSnapshot, "deleteSnapshotBackup": deleteSnapshotBackup, "unmountSnapshotsDir": unmountSnapshotsDir, "revert_memory_snapshot":revert_memory_snapshot})
|
||||
XenAPIPlugin.dispatch({"getVhdParent":getVhdParent, "create_secondary_storage_folder":create_secondary_storage_folder, "delete_secondary_storage_folder":delete_secondary_storage_folder, "post_create_private_template":post_create_private_template, "backupSnapshot": backupSnapshot, "deleteSnapshotBackup": deleteSnapshotBackup, "unmountSnapshotsDir": unmountSnapshotsDir, "revert_memory_snapshot":revert_memory_snapshot, "getSnapshotSize":getSnapshotSize})
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user