set template size when creating template from snapshot

This commit is contained in:
Edison Su 2013-05-13 16:45:03 -07:00
parent a7480530f7
commit 0ce01e56db
3 changed files with 12 additions and 1 deletions

View File

@ -39,6 +39,7 @@ public class TemplateObjectTO implements DataTO {
private DataStoreTO imageDataStore;
private String name;
private String guestOsType;
private Long size;
public TemplateObjectTO() {
@ -159,4 +160,12 @@ public class TemplateObjectTO implements DataTO {
public void setGuestOsType(String guestOsType) {
this.guestOsType = guestOsType;
}
public Long getSize() {
return size;
}
public void setSize(Long size) {
this.size = size;
}
}

View File

@ -226,6 +226,7 @@ public class TemplateObject implements TemplateInfo {
if (this.getDataStore().getRole() == DataStoreRole.Image) {
VMTemplateVO templateVO = this.imageDao.findById(this.getId());
templateVO.setFormat(newTemplate.getFormat());
templateVO.setSize(newTemplate.getSize());
this.imageDao.update(templateVO.getId(), templateVO);
}
}

View File

@ -367,10 +367,11 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
loc.create(1, true, templateName);
loc.addFormat(info);
loc.save();
TemplateProp prop = loc.getTemplateInfo();
TemplateObjectTO newTemplate = new TemplateObjectTO();
newTemplate.setPath(destData.getPath() + File.separator + templateName);
newTemplate.setFormat(ImageFormat.VHD);
newTemplate.setSize(prop.getSize());
return new CopyCmdAnswer(newTemplate);
} catch (ConfigurationException e) {
s_logger.debug("Failed to create template from snapshot: " + e.toString());