From 10a6c4f582db565630309d4817e47598bf23f60c Mon Sep 17 00:00:00 2001 From: Likitha Shetty Date: Wed, 1 Jan 2014 14:21:32 +0530 Subject: [PATCH] CLOUDSTACK-5704. OVA files exist for templates created from volumes. Don't package the OVF and VMDK files into OVA after a template is created from volume. Since packaging process contains reading and writing from the NFS mount, it doubles the amount of data that needs to be moved around --- .../resource/VmwareStorageProcessor.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java index 44703d7896c..07b8db0bc01 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java +++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java @@ -635,9 +635,22 @@ public class VmwareStorageProcessor implements StorageProcessor { VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first())); clonedVm = cloneResult.first(); - clonedVm.exportVm(secondaryMountPoint + "/" + installPath, templateUniqueName, true, false); + clonedVm.exportVm(secondaryMountPoint + "/" + installPath, templateUniqueName, false, false); - long physicalSize = new File(installFullPath + "/" + templateUniqueName + ".ova").length(); + // Get VMDK filename + String templateVMDKName = ""; + File[] files = new File(installFullPath).listFiles(); + if(files != null) { + for(File file : files) { + String fileName = file.getName(); + if(fileName.toLowerCase().startsWith(templateUniqueName) && fileName.toLowerCase().endsWith(".vmdk")) { + templateVMDKName += fileName; + break; + } + } + } + + long physicalSize = new File(installFullPath + "/" + templateVMDKName).length(); VmdkProcessor processor = new VmdkProcessor(); Map params = new HashMap(); params.put(StorageLayer.InstanceConfigKey, _storage); @@ -645,6 +658,7 @@ public class VmwareStorageProcessor implements StorageProcessor { long virtualSize = processor.getTemplateVirtualSize(installFullPath, templateUniqueName); postCreatePrivateTemplate(installFullPath, templateId, templateUniqueName, physicalSize, virtualSize); + writeMetaOvaForTemplate(installFullPath, templateUniqueName + ".ovf", templateVMDKName, templateUniqueName, physicalSize); return new Ternary(installPath + "/" + templateUniqueName + ".ova", physicalSize, virtualSize); } finally {