mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Support Direct Download on Ceph (#11069)
This commit is contained in:
parent
0bd35a5403
commit
16c60c7528
@ -224,10 +224,35 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||||||
} else {
|
} else {
|
||||||
Script.runSimpleBashScript("mv " + templateFilePath + " " + destinationFile);
|
Script.runSimpleBashScript("mv " + templateFilePath + " " + destinationFile);
|
||||||
}
|
}
|
||||||
|
} else if (destPool.getType() == StoragePoolType.RBD) {
|
||||||
|
String temporaryExtractFilePath = sourceFile.getParent() + File.separator + templateUuid;
|
||||||
|
extractDownloadedTemplate(templateFilePath, destPool, temporaryExtractFilePath);
|
||||||
|
createTemplateOnRBDFromDirectDownloadFile(temporaryExtractFilePath, templateUuid, destPool, timeout);
|
||||||
}
|
}
|
||||||
return destPool.getPhysicalDisk(templateUuid);
|
return destPool.getPhysicalDisk(templateUuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createTemplateOnRBDFromDirectDownloadFile(String srcTemplateFilePath, String templateUuid, KVMStoragePool destPool, int timeout) {
|
||||||
|
try {
|
||||||
|
QemuImg.PhysicalDiskFormat srcFileFormat = QemuImg.PhysicalDiskFormat.QCOW2;
|
||||||
|
QemuImgFile srcFile = new QemuImgFile(srcTemplateFilePath, srcFileFormat);
|
||||||
|
QemuImg qemu = new QemuImg(timeout);
|
||||||
|
Map<String, String> info = qemu.info(srcFile);
|
||||||
|
Long virtualSize = Long.parseLong(info.get(QemuImg.VIRTUAL_SIZE));
|
||||||
|
KVMPhysicalDisk destDisk = new KVMPhysicalDisk(destPool.getSourceDir() + "/" + templateUuid, templateUuid, destPool);
|
||||||
|
destDisk.setFormat(PhysicalDiskFormat.RAW);
|
||||||
|
destDisk.setSize(virtualSize);
|
||||||
|
destDisk.setVirtualSize(virtualSize);
|
||||||
|
QemuImgFile destFile = new QemuImgFile(KVMPhysicalDisk.RBDStringBuilder(destPool, destDisk.getPath()));
|
||||||
|
destFile.setFormat(PhysicalDiskFormat.RAW);
|
||||||
|
qemu.convert(srcFile, destFile);
|
||||||
|
} catch (LibvirtException | QemuImgException e) {
|
||||||
|
String err = String.format("Error creating template from direct download file on pool %s: %s", destPool.getUuid(), e.getMessage());
|
||||||
|
logger.error(err, e);
|
||||||
|
throw new CloudRuntimeException(err, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public StorageVol getVolume(StoragePool pool, String volName) {
|
public StorageVol getVolume(StoragePool pool, String volName) {
|
||||||
StorageVol vol = null;
|
StorageVol vol = null;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user