CLOUDSTACK-8066: There is not way to know the size of the snapshot created.

(cherry picked from commit 9153b8bede)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Sanjay Tripathi 2014-12-17 15:51:47 +05:30 committed by Rohit Yadav
parent c06ca09b54
commit 8676ff26e0
5 changed files with 22 additions and 0 deletions

View File

@ -613,6 +613,7 @@ public class ApiConstants {
public static final String REGION_LEVEL_VPC = "regionlevelvpc";
public static final String STRECHED_L2_SUBNET = "strechedl2subnet";
public static final String NETWORK_SPANNED_ZONES = "zonesnetworkspans";
public static final String PHYSICAL_SIZE = "physicalsize";
public enum HostDetails {
all, capacity, events, stats, min;

View File

@ -86,6 +86,10 @@ public class SnapshotResponse extends BaseResponse implements ControlledEntityRe
@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")
private Snapshot.State state;
@SerializedName(ApiConstants.PHYSICAL_SIZE)
@Param(description = "physical size of backedup snapshot on image store")
private long physicalSize;
@SerializedName(ApiConstants.ZONE_ID)
@Param(description = "id of the availability zone")
private String zoneId;
@ -166,6 +170,10 @@ public class SnapshotResponse extends BaseResponse implements ControlledEntityRe
this.state = state;
}
public void setPhysicaSize(long physicalSize) {
this.physicalSize = physicalSize;
}
@Override
public void setProjectId(String projectId) {
this.projectId = projectId;

View File

@ -36,4 +36,6 @@ public interface SnapshotInfo extends DataObject, Snapshot {
ObjectInDataStoreStateMachine.State getStatus();
boolean isRevertable();
long getPhysicalSize();
}

View File

@ -138,6 +138,16 @@ public class SnapshotObject implements SnapshotInfo {
return false;
}
@Override
public long getPhysicalSize() {
long physicalSize = 0;
SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Image);
if (snapshotStore != null) {
physicalSize = snapshotStore.getPhysicalSize();
}
return physicalSize;
}
@Override
public VolumeInfo getBaseVolume() {
return volFactory.getVolume(snapshot.getVolumeId());

View File

@ -470,6 +470,7 @@ public class ApiResponseHelper implements ResponseGenerator {
snapshotResponse.setRevertable(false);
} else {
snapshotResponse.setRevertable(snapshotInfo.isRevertable());
snapshotResponse.setPhysicaSize(snapshotInfo.getPhysicalSize());
}
// set tag information