Skip to content

Commit 8913e4b

Browse files
Show parent snapshot (along with the chain size) for incremental snapshots
1 parent 3828a3b commit 8913e4b

File tree

6 files changed

+36
-2
lines changed

6 files changed

+36
-2
lines changed

api/src/main/java/org/apache/cloudstack/api/command/user/config/ListCapabilitiesCmd.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public void execute() {
5151
response.setDiskOffMaxSize((Long)capabilities.get("customDiskOffMaxSize"));
5252
response.setRegionSecondaryEnabled((Boolean)capabilities.get("regionSecondaryEnabled"));
5353
response.setKVMSnapshotEnabled((Boolean)capabilities.get("KVMSnapshotEnabled"));
54+
response.setSnapshotShowChainSize((Boolean)capabilities.get("SnapshotShowChainSize"));
5455
response.setAllowUserViewDestroyedVM((Boolean)capabilities.get("allowUserViewDestroyedVM"));
5556
response.setAllowUserExpungeRecoverVM((Boolean)capabilities.get("allowUserExpungeRecoverVM"));
5657
response.setAllowUserExpungeRecoverVolume((Boolean)capabilities.get("allowUserExpungeRecoverVolume"));

api/src/main/java/org/apache/cloudstack/api/response/CapabilitiesResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ public class CapabilitiesResponse extends BaseResponse {
7373
@Param(description = "True if Snapshot is supported for KVM host, false otherwise")
7474
private boolean kvmSnapshotEnabled;
7575

76+
@SerializedName("snapshotshowchainsize")
77+
@Param(description = "True to show the parent and chain size (sum of physical size of snapshot and all its parents) for incremental snapshots", since = "4.22.1")
78+
private boolean snapshotShowChainSize;
79+
7680
@SerializedName("apilimitmax")
7781
@Param(description = "Max allowed number of api requests within the specified interval")
7882
private Integer apiLimitMax;
@@ -197,6 +201,10 @@ public void setKVMSnapshotEnabled(boolean kvmSnapshotEnabled) {
197201
this.kvmSnapshotEnabled = kvmSnapshotEnabled;
198202
}
199203

204+
public void setSnapshotShowChainSize(boolean snapshotShowChainSize) {
205+
this.snapshotShowChainSize = snapshotShowChainSize;
206+
}
207+
200208
public void setApiLimitInterval(Integer apiLimitInterval) {
201209
this.apiLimitInterval = apiLimitInterval;
202210
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ public class SnapshotResponse extends BaseResponseWithTagInformation implements
155155
@Param(description = "download progress of a snapshot", since = "4.19.0")
156156
private Map<String, String> downloadDetails;
157157

158+
@SerializedName("parent")
159+
@Param(description = "The parent ID of the Snapshot", since = "4.22.1")
160+
private String parent;
161+
162+
@SerializedName("parentname")
163+
@Param(description = "The parent name of the Snapshot", since = "4.22.1")
164+
private String parentName;
165+
158166
public SnapshotResponse() {
159167
tags = new LinkedHashSet<ResourceTagResponse>();
160168
}
@@ -313,4 +321,12 @@ public void setDatastoreType(String datastoreType) {
313321
public void setDownloadDetails(Map<String, String> downloadDetails) {
314322
this.downloadDetails = downloadDetails;
315323
}
324+
325+
public void setParent(String parent) {
326+
this.parent = parent;
327+
}
328+
329+
public void setParentName(String parentName) {
330+
this.parentName = parentName;
331+
}
316332
}

server/src/main/java/com/cloud/api/query/dao/SnapshotJoinDaoImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ private void setSnapshotInfoDetailsInResponse(SnapshotJoinVO snapshot, SnapshotR
109109
if (showChainSize && snapshotInfo.getParent() != null) {
110110
long chainSize = calculateChainSize(snapshotInfo);
111111
snapshotResponse.setChainSize(chainSize);
112+
snapshotResponse.setParent(snapshotInfo.getParent().getUuid());
113+
snapshotResponse.setParentName(snapshotInfo.getParent().getName());
112114
}
113115
}
114116
}

server/src/main/java/com/cloud/server/ManagementServerImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4799,6 +4799,7 @@ public Map<String, Object> listCapabilities(final ListCapabilitiesCmd cmd) {
47994799
final long diskOffMinSize = VolumeOrchestrationService.CustomDiskOfferingMinSize.value();
48004800
final long diskOffMaxSize = VolumeOrchestrationService.CustomDiskOfferingMaxSize.value();
48014801
final boolean KVMSnapshotEnabled = SnapshotManager.KVMSnapshotEnabled.value();
4802+
final boolean SnapshotShowChainSize = SnapshotManager.snapshotShowChainSize.value();
48024803

48034804
final boolean userPublicTemplateEnabled = TemplateManager.AllowPublicUserTemplates.valueIn(caller.getId());
48044805

@@ -4839,6 +4840,7 @@ public Map<String, Object> listCapabilities(final ListCapabilitiesCmd cmd) {
48394840
capabilities.put("customDiskOffMaxSize", diskOffMaxSize);
48404841
capabilities.put("regionSecondaryEnabled", regionSecondaryEnabled);
48414842
capabilities.put("KVMSnapshotEnabled", KVMSnapshotEnabled);
4843+
capabilities.put("SnapshotShowChainSize", SnapshotShowChainSize);
48424844
capabilities.put("allowUserViewDestroyedVM", allowUserViewDestroyedVM);
48434845
capabilities.put("allowUserExpungeRecoverVM", allowUserExpungeRecoverVM);
48444846
capabilities.put("allowUserExpungeRecoverVolume", allowUserExpungeRecoverVolume);

ui/src/config/section/storage.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,12 @@ export default {
311311
permission: ['listSnapshots'],
312312
resourceType: 'Snapshot',
313313
columns: () => {
314-
var fields = ['name', 'state', 'volumename', 'intervaltype', 'physicalsize', 'created']
314+
var fields = ['name', 'state', 'volumename', 'intervaltype', 'physicalsize']
315+
if (store.getters.features.snapshotshowchainsize) {
316+
fields.push('chainsize')
317+
fields.push('parentname')
318+
}
319+
fields.push('created')
315320
if (['Admin', 'DomainAdmin'].includes(store.getters.userInfo.roletype)) {
316321
fields.push('account')
317322
if (store.getters.listAllProjects) {
@@ -324,7 +329,7 @@ export default {
324329
fields.push('zonename')
325330
return fields
326331
},
327-
details: ['name', 'id', 'volumename', 'volumetype', 'snapshottype', 'intervaltype', 'physicalsize', 'virtualsize', 'chainsize', 'account', 'domain', 'created'],
332+
details: ['name', 'id', 'volumename', 'volumetype', 'snapshottype', 'intervaltype', 'physicalsize', 'virtualsize', 'chainsize', 'parentname', 'account', 'domain', 'created'],
328333
tabs: [
329334
{
330335
name: 'details',

0 commit comments

Comments
 (0)