Updated Branches: refs/heads/master 2b1266e27 -> 44cae4601
CLOUDSTACK-3741: generate template.properties so that KVM processor will not fail with FileNotFound. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/44cae460 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/44cae460 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/44cae460 Branch: refs/heads/master Commit: 44cae460147898186a56d7d022c734e3ac86e4dc Parents: 2b1266e Author: Min Chen <[email protected]> Authored: Wed Jul 24 17:49:10 2013 -0700 Committer: Min Chen <[email protected]> Committed: Wed Jul 24 17:51:28 2013 -0700 ---------------------------------------------------------------------- .../resource/NfsSecondaryStorageResource.java | 23 ++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/44cae460/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java ---------------------------------------------------------------------- diff --git a/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java b/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java index 082fc6c..e7dc62d 100755 --- a/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java +++ b/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java @@ -423,11 +423,26 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S String destFileFullPath = destFile.getAbsolutePath() + File.separator + templateName + "." + ImageFormat.QCOW2.getFileExtension(); s_logger.debug("copy snapshot " + srcFile.getAbsolutePath() + " to template " + destFileFullPath); Script.runSimpleBashScript("cp " + srcFile.getAbsolutePath() + " " + destFileFullPath); - // template post processing - QCOW2Processor processor = new QCOW2Processor(); - Map<String, Object> params = new HashMap<String, Object>(); - params.put(StorageLayer.InstanceConfigKey, _storage); try { + // generate template.properties file + String metaFileName = destFile.getAbsolutePath() + File.separator + "template.properties"; + _storage.create(destFile.getAbsolutePath(), "template.properties"); + File metaFile = new File(metaFileName); + FileWriter writer = new FileWriter(metaFile); + BufferedWriter bufferWriter = new BufferedWriter(writer); + bufferWriter.write("uniquename=" + destData.getName()); + bufferWriter.write("\n"); + bufferWriter.write("filename=" + templateName + "." + ImageFormat.QCOW2.getFileExtension()); + bufferWriter.write("\n"); + long size = this._storage.getSize(destFileFullPath); + bufferWriter.write("size=" + size); + bufferWriter.close(); + writer.close(); + // template post processing + QCOW2Processor processor = new QCOW2Processor(); + Map<String, Object> params = new HashMap<String, Object>(); + params.put(StorageLayer.InstanceConfigKey, _storage); + processor.configure("qcow2 processor", params); String destPath = destFile.getAbsolutePath(); FormatInfo info = processor.process(destPath, null, templateName);
