CLOUDSTACK-4295 : TemplateTO should contain physical size along with virtual size. Usage ignores templates with size 0

This commit is contained in:
Kishan Kavala 2013-08-14 15:07:46 +05:30
parent d771e3fa5b
commit 21831211f6
3 changed files with 12 additions and 0 deletions

View File

@ -39,6 +39,7 @@ public class TemplateObjectTO implements DataTO {
private String name;
private String guestOsType;
private Long size;
private Long physicalSize;
private Hypervisor.HypervisorType hypervisorType;
public TemplateObjectTO() {
@ -200,6 +201,14 @@ public class TemplateObjectTO implements DataTO {
this.size = size;
}
public Long getPhysicalSize() {
return physicalSize;
}
public void setPhysicalSize(Long physicalSize) {
this.physicalSize = physicalSize;
}
@Override
public String toString() {
return new StringBuilder("TemplateTO[id=").append(id).append("|origUrl=").append(origUrl)

View File

@ -198,6 +198,7 @@ public class TemplateObject implements TemplateInfo {
templateStoreRef.setDownloadPercent(100);
templateStoreRef.setDownloadState(Status.DOWNLOADED);
templateStoreRef.setSize(newTemplate.getSize());
templateStoreRef.setPhysicalSize(newTemplate.getPhysicalSize());
templateStoreDao.update(templateStoreRef.getId(), templateStoreRef);
if (this.getDataStore().getRole() == DataStoreRole.Image) {
VMTemplateVO templateVO = this.imageDao.findById(this.getId());

View File

@ -382,6 +382,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
newTemplate.setPath(destData.getPath() + File.separator + templateName);
newTemplate.setFormat(ImageFormat.VHD);
newTemplate.setSize(prop.getSize());
newTemplate.setPhysicalSize(prop.getPhysicalSize());
return new CopyCmdAnswer(newTemplate);
} catch (ConfigurationException e) {
s_logger.debug("Failed to create template from snapshot: " + e.toString());
@ -444,6 +445,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
newTemplate.setPath(destData.getPath() + File.separator + templateName + "." + ImageFormat.QCOW2.getFileExtension());
newTemplate.setFormat(ImageFormat.QCOW2);
newTemplate.setSize(prop.getSize());
newTemplate.setPhysicalSize(prop.getPhysicalSize());
return new CopyCmdAnswer(newTemplate);
} catch (ConfigurationException e) {
s_logger.debug("Failed to create template:" + e.toString());