Skip to content
This repository was archived by the owner on Jan 15, 2020. It is now read-only.

Commit 9153b8b

Browse files
CLOUDSTACK-8066: There is not way to know the size of the snapshot created.
1 parent cf1eed4 commit 9153b8b

5 files changed

Lines changed: 22 additions & 0 deletions

File tree

api/src/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ public class ApiConstants {
613613
public static final String REGION_LEVEL_VPC = "regionlevelvpc";
614614
public static final String STRECHED_L2_SUBNET = "strechedl2subnet";
615615
public static final String NETWORK_SPANNED_ZONES = "zonesnetworkspans";
616+
public static final String PHYSICAL_SIZE = "physicalsize";
616617

617618
public enum HostDetails {
618619
all, capacity, events, stats, min;

api/src/org/apache/cloudstack/api/response/SnapshotResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ public class SnapshotResponse extends BaseResponse implements ControlledEntityRe
8686
@Param(description = "the state of the snapshot. BackedUp means that snapshot is ready to be used; Creating - the snapshot is being allocated on the primary storage; BackingUp - the snapshot is being backed up on secondary storage")
8787
private Snapshot.State state;
8888

89+
@SerializedName(ApiConstants.PHYSICAL_SIZE)
90+
@Param(description = "physical size of backedup snapshot on image store")
91+
private long physicalSize;
92+
8993
@SerializedName(ApiConstants.ZONE_ID)
9094
@Param(description = "id of the availability zone")
9195
private String zoneId;
@@ -166,6 +170,10 @@ public void setState(Snapshot.State state) {
166170
this.state = state;
167171
}
168172

173+
public void setPhysicaSize(long physicalSize) {
174+
this.physicalSize = physicalSize;
175+
}
176+
169177
@Override
170178
public void setProjectId(String projectId) {
171179
this.projectId = projectId;

engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotInfo.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@ public interface SnapshotInfo extends DataObject, Snapshot {
3636
ObjectInDataStoreStateMachine.State getStatus();
3737

3838
boolean isRevertable();
39+
40+
long getPhysicalSize();
3941
}

engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ public boolean isRevertable() {
138138
return false;
139139
}
140140

141+
@Override
142+
public long getPhysicalSize() {
143+
long physicalSize = 0;
144+
SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Image);
145+
if (snapshotStore != null) {
146+
physicalSize = snapshotStore.getPhysicalSize();
147+
}
148+
return physicalSize;
149+
}
150+
141151
@Override
142152
public VolumeInfo getBaseVolume() {
143153
return volFactory.getVolume(snapshot.getVolumeId());

server/src/com/cloud/api/ApiResponseHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ public SnapshotResponse createSnapshotResponse(Snapshot snapshot) {
493493
snapshotResponse.setRevertable(false);
494494
} else {
495495
snapshotResponse.setRevertable(snapshotInfo.isRevertable());
496+
snapshotResponse.setPhysicaSize(snapshotInfo.getPhysicalSize());
496497
}
497498

498499
// set tag information

0 commit comments

Comments
 (0)