You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mc...@apache.org on 2013/07/24 18:57:16 UTC
[4/4] git commit: updated refs/heads/master to df452ba
CLOUDSTACK-3741:Object_Store_Refactor - [KVM] Creation of Template from
Snapshot Fails.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/df452ba1
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/df452ba1
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/df452ba1
Branch: refs/heads/master
Commit: df452ba13a7307dc1e9dc41ede9335e22dc423c2
Parents: d22bea6
Author: Min Chen <mi...@citrix.com>
Authored: Wed Jul 24 09:25:20 2013 -0700
Committer: Min Chen <mi...@citrix.com>
Committed: Wed Jul 24 09:49:28 2013 -0700
----------------------------------------------------------------------
.../resource/NfsSecondaryStorageResource.java | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/df452ba1/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 5318e09..29c05d5 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
@@ -417,15 +417,21 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
} else if (srcData.getHypervisorType() == HypervisorType.KVM) {
File srcFile = getFile(srcData.getPath(), srcDataStore.getUrl());
File destFile = getFile(destData.getPath(), destDataStore.getUrl());
- s_logger.debug("copy snapshot to template");
- Script.runSimpleBashScript("cp " + srcFile.getAbsolutePath() + " " + destFile.getAbsolutePath());
+ // get snapshot file name, add extension if it is missing
+ String templateName = srcFile.getName();
+ if (!templateName.endsWith(ImageFormat.QCOW2.getFileExtension())) {
+ templateName = templateName + ImageFormat.QCOW2.getFileExtension();
+ }
+ String destFileFullPath = destFile.getAbsolutePath() + File.separator + templateName;
+ 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 {
processor.configure("qcow2 processor", params);
String destPath = destFile.getAbsolutePath();
- String templateName = srcFile.getName();
FormatInfo info = processor.process(destPath, null, templateName);
TemplateLocation loc = new TemplateLocation(_storage, destPath);
loc.create(1, true, srcFile.getName());
@@ -434,7 +440,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
TemplateProp prop = loc.getTemplateInfo();
TemplateObjectTO newTemplate = new TemplateObjectTO();
newTemplate.setPath(destData.getPath() + File.separator + templateName);
- newTemplate.setFormat(ImageFormat.VHD);
+ newTemplate.setFormat(ImageFormat.QCOW2);
newTemplate.setSize(prop.getSize());
return new CopyCmdAnswer(newTemplate);
} catch (ConfigurationException e) {
@@ -481,7 +487,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
return answer;
}
s_logger.debug("starting copy template to swift");
- DataTO newTemplate = (DataTO)answer.getNewData();
+ DataTO newTemplate = answer.getNewData();
File templateFile = getFile(newTemplate.getPath(), ((NfsTO) srcDataStore).getUrl());
SwiftTO swift = (SwiftTO)destDataStore;
String containterName = SwiftUtil.getContainerName(destData.getObjectType().toString(), destData.getId());