Skip to content

Commit 03975f1

Browse files
sureshanapartiLocharla, Sandeep
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 1dcf89a commit 03975f1

7 files changed

Lines changed: 56 additions & 4 deletions

File tree

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;
@@ -203,6 +207,10 @@ public void setKVMSnapshotEnabled(boolean kvmSnapshotEnabled) {
203207
this.kvmSnapshotEnabled = kvmSnapshotEnabled;
204208
}
205209

210+
public void setSnapshotShowChainSize(boolean snapshotShowChainSize) {
211+
this.snapshotShowChainSize = snapshotShowChainSize;
212+
}
213+
206214
public void setApiLimitInterval(Integer apiLimitInterval) {
207215
this.apiLimitInterval = apiLimitInterval;
208216
}

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
@@ -4721,6 +4721,7 @@ public Map<String, Object> listCapabilities(final ListCapabilitiesCmd cmd) {
47214721
final long diskOffMinSize = VolumeOrchestrationService.CustomDiskOfferingMinSize.value();
47224722
final long diskOffMaxSize = VolumeOrchestrationService.CustomDiskOfferingMaxSize.value();
47234723
final boolean KVMSnapshotEnabled = SnapshotManager.KVMSnapshotEnabled.value();
4724+
final boolean SnapshotShowChainSize = SnapshotManager.snapshotShowChainSize.value();
47244725

47254726
final boolean userPublicTemplateEnabled = TemplateManager.AllowPublicUserTemplates.valueIn(caller.getId());
47264727

@@ -4761,6 +4762,7 @@ public Map<String, Object> listCapabilities(final ListCapabilitiesCmd cmd) {
47614762
capabilities.put("customDiskOffMaxSize", diskOffMaxSize);
47624763
capabilities.put("regionSecondaryEnabled", regionSecondaryEnabled);
47634764
capabilities.put("KVMSnapshotEnabled", KVMSnapshotEnabled);
4765+
capabilities.put("SnapshotShowChainSize", SnapshotShowChainSize);
47644766
capabilities.put("allowUserViewDestroyedVM", allowUserViewDestroyedVM);
47654767
capabilities.put("allowUserExpungeRecoverVM", allowUserExpungeRecoverVM);
47664768
capabilities.put("allowUserExpungeRecoverVolume", allowUserExpungeRecoverVolume);

ui/src/components/view/ListView.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,20 @@
758758
>{{ text }}</router-link>
759759
<span v-else>{{ text }}</span>
760760
</template>
761+
<template v-if="column.key === 'parentname' && ['snapshot'].includes($route.path.split('/')[1])">
762+
<router-link
763+
v-if="record.parent && $router.resolve('/snapshot/' + record.parent).matched[0].redirect !== '/exception/404'"
764+
:to="{ path: '/snapshot/' + record.parent }"
765+
>{{ text }}</router-link>
766+
<span v-else>{{ text }}</span>
767+
</template>
768+
<template v-if="column.key === 'parentName' && ['vmsnapshot'].includes($route.path.split('/')[1])">
769+
<router-link
770+
v-if="record.parent && $router.resolve('/vmsnapshot/' + record.parent).matched[0].redirect !== '/exception/404'"
771+
:to="{ path: '/vmsnapshot/' + record.parent }"
772+
>{{ text }}</router-link>
773+
<span v-else>{{ text }}</span>
774+
</template>
761775
<template v-if="column.key === 'templateversion'">
762776
<span> {{ record.version }} </span>
763777
</template>

ui/src/config/section/storage.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export default {
9292
}
9393
],
9494
searchFilters: () => {
95-
var filters = ['name', 'zoneid', 'domainid', 'account', 'state', 'tags', 'serviceofferingid', 'diskofferingid', 'isencrypted']
95+
const filters = ['name', 'zoneid', 'domainid', 'account', 'state', 'tags', 'serviceofferingid', 'diskofferingid', 'isencrypted']
9696
if (['Admin', 'DomainAdmin'].includes(store.getters.userInfo.roletype)) {
9797
filters.push('storageid')
9898
}
@@ -311,7 +311,10 @@ export default {
311311
permission: ['listSnapshots'],
312312
resourceType: 'Snapshot',
313313
columns: () => {
314-
var fields = ['name', 'state', 'volumename', 'intervaltype', 'physicalsize', 'created']
314+
const fields = ['name', 'state', 'volumename', 'intervaltype', 'physicalsize', 'created']
315+
if (store.getters.features.snapshotshowchainsize) {
316+
fields.splice(fields.indexOf('created'), 0, 'chainsize', 'parentname')
317+
}
315318
if (['Admin', 'DomainAdmin'].includes(store.getters.userInfo.roletype)) {
316319
fields.push('account')
317320
if (store.getters.listAllProjects) {
@@ -324,7 +327,13 @@ export default {
324327
fields.push('zonename')
325328
return fields
326329
},
327-
details: ['name', 'id', 'volumename', 'volumetype', 'snapshottype', 'intervaltype', 'physicalsize', 'virtualsize', 'chainsize', 'account', 'domain', 'created'],
330+
details: () => {
331+
const fields = ['name', 'id', 'volumename', 'volumetype', 'snapshottype', 'intervaltype', 'physicalsize', 'virtualsize', 'account', 'domain', 'created']
332+
if (store.getters.features.snapshotshowchainsize) {
333+
fields.splice(fields.indexOf('account'), 0, 'chainsize', 'parentname')
334+
}
335+
return fields
336+
},
328337
tabs: [
329338
{
330339
name: 'details',
@@ -346,7 +355,7 @@ export default {
346355
}
347356
],
348357
searchFilters: () => {
349-
var filters = ['name', 'domainid', 'account', 'tags', 'zoneid']
358+
const filters = ['name', 'domainid', 'account', 'tags', 'zoneid']
350359
if (['Admin', 'DomainAdmin'].includes(store.getters.userInfo.roletype)) {
351360
filters.push('storageid')
352361
filters.push('imagestoreid')

0 commit comments

Comments
 (0)