Skip to content

Commit 903b92f

Browse files
author
Kishan Kavala
committed
CLOUDSTACK-4295 : TemplateTO should contain physical size along with virtual size. Usage ignores templates with size 0
1 parent 3be5605 commit 903b92f

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎engine/api/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public class TemplateObjectTO implements DataTO {
3939
private String name;
4040
private String guestOsType;
4141
private Long size;
42+
private Long physicalSize;
4243
private Hypervisor.HypervisorType hypervisorType;
4344

4445
public TemplateObjectTO() {
@@ -200,6 +201,14 @@ public void setSize(Long size) {
200201
this.size = size;
201202
}
202203

204+
public Long getPhysicalSize() {
205+
return physicalSize;
206+
}
207+
208+
public void setPhysicalSize(Long physicalSize) {
209+
this.physicalSize = physicalSize;
210+
}
211+
203212
@Override
204213
public String toString() {
205214
return new StringBuilder("TemplateTO[id=").append(id).append("|origUrl=").append(origUrl)

‎engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answe
198198
templateStoreRef.setDownloadPercent(100);
199199
templateStoreRef.setDownloadState(Status.DOWNLOADED);
200200
templateStoreRef.setSize(newTemplate.getSize());
201+
templateStoreRef.setPhysicalSize(newTemplate.getPhysicalSize());
201202
templateStoreDao.update(templateStoreRef.getId(), templateStoreRef);
202203
if (this.getDataStore().getRole() == DataStoreRole.Image) {
203204
VMTemplateVO templateVO = this.imageDao.findById(this.getId());

‎services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ protected Answer copySnapshotToTemplateFromNfsToNfsXenserver(CopyCommand cmd, Sn
382382
newTemplate.setPath(destData.getPath() + File.separator + templateName);
383383
newTemplate.setFormat(ImageFormat.VHD);
384384
newTemplate.setSize(prop.getSize());
385+
newTemplate.setPhysicalSize(prop.getPhysicalSize());
385386
return new CopyCmdAnswer(newTemplate);
386387
} catch (ConfigurationException e) {
387388
s_logger.debug("Failed to create template from snapshot: " + e.toString());
@@ -444,6 +445,7 @@ protected Answer copySnapshotToTemplateFromNfsToNfs(CopyCommand cmd, SnapshotObj
444445
newTemplate.setPath(destData.getPath() + File.separator + templateName + "." + ImageFormat.QCOW2.getFileExtension());
445446
newTemplate.setFormat(ImageFormat.QCOW2);
446447
newTemplate.setSize(prop.getSize());
448+
newTemplate.setPhysicalSize(prop.getPhysicalSize());
447449
return new CopyCmdAnswer(newTemplate);
448450
} catch (ConfigurationException e) {
449451
s_logger.debug("Failed to create template:" + e.toString());

0 commit comments

Comments
 (0)