CLOUDSTACK-3706:[Object_Store_Refactor] Failed to create template from

stopped guest vm's root disk.
This commit is contained in:
Min Chen 2013-08-14 11:54:36 -07:00
parent b727001f48
commit 67beef15c9
2 changed files with 14 additions and 4 deletions

View File

@ -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);
}

View File

@ -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();