Skip to content

Commit d36bfd0

Browse files
sureshanapartidhslove
authored andcommitted
Show parent snapshot (along with the chain size) for incremental snapshots (apache#12468)
* Show parent snapshot (along with the chain size) for incremental snapshots * review * review changes
1 parent 22dd892 commit d36bfd0

File tree

7 files changed

+56
-4
lines changed

7 files changed

+56
-4
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
@@ -63,6 +63,7 @@ public void execute() {
6363
response.setDiskOffMaxSize((Long)capabilities.get("customDiskOffMaxSize"));
6464
response.setRegionSecondaryEnabled((Boolean)capabilities.get("regionSecondaryEnabled"));
6565
response.setKVMSnapshotEnabled((Boolean)capabilities.get("KVMSnapshotEnabled"));
66+
response.setSnapshotShowChainSize((Boolean)capabilities.get("SnapshotShowChainSize"));
6667
response.setAllowUserViewDestroyedVM((Boolean)capabilities.get("allowUserViewDestroyedVM"));
6768
response.setAllowUserExpungeRecoverVM((Boolean)capabilities.get("allowUserExpungeRecoverVM"));
6869
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
@@ -75,6 +75,10 @@ public class CapabilitiesResponse extends BaseResponse {
7575
@Param(description = "True if Snapshot is supported for KVM host, false otherwise")
7676
private boolean kvmSnapshotEnabled;
7777

78+
@SerializedName("snapshotshowchainsize")
79+
@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")
80+
private boolean snapshotShowChainSize;
81+
7882
@SerializedName("apilimitmax")
7983
@Param(description = "Max allowed number of api requests within the specified interval")
8084
private Integer apiLimitMax;
@@ -239,6 +243,10 @@ public void setKVMSnapshotEnabled(boolean kvmSnapshotEnabled) {
239243
this.kvmSnapshotEnabled = kvmSnapshotEnabled;
240244
}
241245

246+
public void setSnapshotShowChainSize(boolean snapshotShowChainSize) {
247+
this.snapshotShowChainSize = snapshotShowChainSize;
248+
}
249+
242250
public void setApiLimitInterval(Integer apiLimitInterval) {
243251
this.apiLimitInterval = apiLimitInterval;
244252
}

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
@@ -7538,6 +7538,7 @@ public Map<String, Object> listCapabilities(final ListCapabilitiesCmd cmd) {
75387538
final long diskOffMinSize = VolumeOrchestrationService.CustomDiskOfferingMinSize.value();
75397539
final long diskOffMaxSize = VolumeOrchestrationService.CustomDiskOfferingMaxSize.value();
75407540
final boolean KVMSnapshotEnabled = SnapshotManager.KVMSnapshotEnabled.value();
7541+
final boolean SnapshotShowChainSize = SnapshotManager.snapshotShowChainSize.value();
75417542

75427543
final boolean userPublicTemplateEnabled = TemplateManager.AllowPublicUserTemplates.valueIn(caller.getId());
75437544

@@ -7588,6 +7589,7 @@ public Map<String, Object> listCapabilities(final ListCapabilitiesCmd cmd) {
75887589
capabilities.put("customDiskOffMaxSize", diskOffMaxSize);
75897590
capabilities.put("regionSecondaryEnabled", regionSecondaryEnabled);
75907591
capabilities.put("KVMSnapshotEnabled", KVMSnapshotEnabled);
7592+
capabilities.put("SnapshotShowChainSize", SnapshotShowChainSize);
75917593
capabilities.put("allowUserViewDestroyedVM", allowUserViewDestroyedVM);
75927594
capabilities.put("allowUserExpungeRecoverVM", allowUserExpungeRecoverVM);
75937595
capabilities.put("allowUserExpungeRecoverVolume", allowUserExpungeRecoverVolume);

ui/src/components/view/ListView.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,20 @@
729729
>{{ text }}</router-link>
730730
<span v-else>{{ text }}</span>
731731
</template>
732+
<template v-if="column.key === 'parentname' && ['snapshot'].includes($route.path.split('/')[1])">
733+
<router-link
734+
v-if="record.parent && $router.resolve('/snapshot/' + record.parent).matched[0].redirect !== '/exception/404'"
735+
:to="{ path: '/snapshot/' + record.parent }"
736+
>{{ text }}</router-link>
737+
<span v-else>{{ text }}</span>
738+
</template>
739+
<template v-if="column.key === 'parentName' && ['vmsnapshot'].includes($route.path.split('/')[1])">
740+
<router-link
741+
v-if="record.parent && $router.resolve('/vmsnapshot/' + record.parent).matched[0].redirect !== '/exception/404'"
742+
:to="{ path: '/vmsnapshot/' + record.parent }"
743+
>{{ text }}</router-link>
744+
<span v-else>{{ text }}</span>
745+
</template>
732746
<template v-if="column.key === 'templateversion'">
733747
<span> {{ record.version }} </span>
734748
</template>

ui/src/config/section/storage.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export default {
9494
}
9595
],
9696
searchFilters: () => {
97-
var filters = ['name', 'zoneid', 'domainid', 'account', 'state', 'tags', 'serviceofferingid', 'diskofferingid', 'isencrypted']
97+
const filters = ['name', 'zoneid', 'domainid', 'account', 'state', 'tags', 'serviceofferingid', 'diskofferingid', 'isencrypted']
9898
if (['Admin', 'DomainAdmin'].includes(store.getters.userInfo.roletype)) {
9999
filters.push('storageid')
100100
}
@@ -326,7 +326,10 @@ export default {
326326
permission: ['listSnapshots'],
327327
resourceType: 'Snapshot',
328328
columns: () => {
329-
var fields = ['name', 'state', 'volumename', 'intervaltype', 'physicalsize', 'created']
329+
const fields = ['name', 'state', 'volumename', 'intervaltype', 'physicalsize', 'created']
330+
if (store.getters.features.snapshotshowchainsize) {
331+
fields.splice(fields.indexOf('created'), 0, 'chainsize', 'parentname')
332+
}
330333
if (['Admin', 'DomainAdmin'].includes(store.getters.userInfo.roletype)) {
331334
fields.push('account')
332335
if (store.getters.listAllProjects) {
@@ -339,7 +342,13 @@ export default {
339342
fields.push('zonename')
340343
return fields
341344
},
342-
details: ['name', 'id', 'volumename', 'volumetype', 'snapshottype', 'intervaltype', 'physicalsize', 'virtualsize', 'chainsize', 'account', 'domain', 'created'],
345+
details: () => {
346+
const fields = ['name', 'id', 'volumename', 'volumetype', 'snapshottype', 'intervaltype', 'physicalsize', 'virtualsize', 'account', 'domain', 'created']
347+
if (store.getters.features.snapshotshowchainsize) {
348+
fields.splice(fields.indexOf('account'), 0, 'chainsize', 'parentname')
349+
}
350+
return fields
351+
},
343352
tabs: [
344353
{
345354
name: 'details',
@@ -361,7 +370,7 @@ export default {
361370
}
362371
],
363372
searchFilters: () => {
364-
var filters = ['name', 'domainid', 'account', 'tags', 'zoneid']
373+
const filters = ['name', 'domainid', 'account', 'tags', 'zoneid']
365374
if (['Admin', 'DomainAdmin'].includes(store.getters.userInfo.roletype)) {
366375
filters.push('storageid')
367376
filters.push('imagestoreid')

0 commit comments

Comments
 (0)