Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Support Direct Download on Ceph
  • Loading branch information
nvazquez committed Jun 22, 2025
commit 8e199cae1cc7d654be6cc0784882e1c5f37e2134
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,35 @@ public KVMPhysicalDisk createTemplateFromDirectDownloadFile(String templateFileP
} else {
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);
}

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()));

@wido wido Jun 23, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line here makes that it doesn't need ceph.conf, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my case the logs indicated that qemu img was looking for ceph.conf at diferent directories and failed as it couldn't find it. Probably it could be some misconfiguration at my side, will explore

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was initially testing on 4.20 branch and the RBDStringBuilder was accepting more parameters, I have now recreated the env using this PR packages and I don't observe the failure anymore

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) {
StorageVol vol = null;

Expand Down