From 8b7c1d7c5e1d7b4396c57d4cf20b24217335bc8e Mon Sep 17 00:00:00 2001 From: Mike Tutkowski Date: Wed, 12 Nov 2014 21:03:03 -0700 Subject: [PATCH] CLOUDSTACK-7898: Add properties file in same folder as template --- .../Xenserver625StorageProcessor.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java index 20baffd6bf4..eec01db832a 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java @@ -904,10 +904,29 @@ public class Xenserver625StorageProcessor extends XenServerStorageProcessor { } destVdi = VDI.getByUuid(conn, destVdiUuid); - String templatePath = destDir + "/" + destVdiUuid + ".vhd"; - templatePath = templatePath.replaceAll("//","/"); + + // scan makes XenServer pick up VDI physicalSize + destSr.scan(conn); + + String templateUuid = destVdi.getUuid(conn); + String templateFilename = templateUuid + ".vhd"; + long virtualSize = destVdi.getVirtualSize(conn); + long physicalSize = destVdi.getPhysicalUtilisation(conn); + + String templatePath = destNfsPath + "/" + destDir; + + templatePath = templatePath.replaceAll("//", "/"); + + result = hypervisorResource.postCreatePrivateTemplate(conn, templatePath, templateFilename, templateUuid, nameLabel, null, + physicalSize, virtualSize, destObj.getId()); + + if (!result) { + throw new CloudRuntimeException("Could not create the template.properties file on secondary storage dir"); + } + TemplateObjectTO newTemplate = new TemplateObjectTO(); - newTemplate.setPath(templatePath); + + newTemplate.setPath(destDir + "/" + templateFilename); newTemplate.setFormat(Storage.ImageFormat.VHD); newTemplate.setSize(destVdi.getVirtualSize(conn)); newTemplate.setPhysicalSize(destVdi.getPhysicalUtilisation(conn));