nvazquez commented on code in PR #11069:
URL: https://github.com/apache/cloudstack/pull/11069#discussion_r2161437030


##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java:
##########
@@ -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()));

Review Comment:
   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



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to