Updated Branches: refs/heads/4.2 4ee6a6d3a -> 30484fb7f
CLOUDSTACK-3706:[Object_Store_Refactor] Failed to create template from stopped guest vm's root disk. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/30484fb7 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/30484fb7 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/30484fb7 Branch: refs/heads/4.2 Commit: 30484fb7f8e71ef99b35a7e64c53b3ff3fa560be Parents: 4ee6a6d Author: Min Chen <[email protected]> Authored: Wed Aug 14 11:54:36 2013 -0700 Committer: Min Chen <[email protected]> Committed: Wed Aug 14 11:54:36 2013 -0700 ---------------------------------------------------------------------- .../storage/image/store/TemplateObject.java | 4 +++- .../storage/resource/NfsSecondaryStorageResource.java | 14 +++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30484fb7/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java ---------------------------------------------------------------------- diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java index 174d5ca..b04ca6c 100644 --- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java +++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java @@ -202,7 +202,9 @@ public class TemplateObject implements TemplateInfo { templateStoreDao.update(templateStoreRef.getId(), templateStoreRef); if (this.getDataStore().getRole() == DataStoreRole.Image) { VMTemplateVO templateVO = this.imageDao.findById(this.getId()); - templateVO.setFormat(newTemplate.getFormat()); + if (newTemplate.getFormat() != null) { + templateVO.setFormat(newTemplate.getFormat()); + } templateVO.setSize(newTemplate.getSize()); this.imageDao.update(templateVO.getId(), templateVO); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30484fb7/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 e45b685..f2b40f2 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 @@ -737,13 +737,21 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S final String bucket = s3.getBucketName(); File srcFile = _storage.getFile(templatePath); + // guard the case where templatePath does not have file extension, since we are not completely sure + // about hypervisor, so we check each extension if (!srcFile.exists()) { srcFile = _storage.getFile(templatePath + ".qcow2"); if (!srcFile.exists()) { - return new CopyCmdAnswer("Can't find src file:" + templatePath); + srcFile = _storage.getFile(templatePath + ".vhd"); + if (!srcFile.exists()) { + srcFile = _storage.getFile(templatePath + ".ova"); + if (!srcFile.exists()) { + return new CopyCmdAnswer("Can't find src file:" + templatePath); + } + } } } - ImageFormat format = this.getTemplateFormat(templatePath); + ImageFormat format = this.getTemplateFormat(srcFile.getName()); String key = destData.getPath() + S3Utils.SEPARATOR + srcFile.getName(); putFile(s3, srcFile, bucket, key); @@ -1386,7 +1394,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S private Answer execute(ListTemplateCommand cmd) { if (!_inSystemVM) { - return new ListTemplateAnswer(null, null); + return new ListTemplateAnswer(null, null); } DataStoreTO store = cmd.getDataStore();
