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 {