Skip to content

Commit 65e9beb

Browse files
Show parent snapshot (along with the chain size) for incremental snapshots (#12468)
* Show parent snapshot (along with the chain size) for incremental snapshots * review * review changes
1 parent 7786cf9 commit 65e9beb

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
@@ -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/components/view/ListView.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,20 @@
739739
>{{ text }}</router-link>
740740
<span v-else>{{ text }}</span>
741741
</template>
742+
<template v-if="column.key === 'parentname' && ['snapshot'].includes($route.path.split('/')[1])">
743+
<router-link
744+
v-if="record.parent && $router.resolve('/snapshot/' + record.parent).matched[0].redirect !== '/exception/404'"
745+
:to="{ path: '/snapshot/' + record.parent }"
746+
>{{ text }}</router-link>
747+
<span v-else>{{ text }}</span>
748+
</template>
749+
<template v-if="column.key === 'parentName' && ['vmsnapshot'].includes($route.path.split('/')[1])">
750+
<router-link
751+
v-if="record.parent && $router.resolve('/vmsnapshot/' + record.parent).matched[0].redirect !== '/exception/404'"
752+
:to="{ path: '/vmsnapshot/' + record.parent }"
753+
>{{ text }}</router-link>
754+
<span v-else>{{ text }}</span>
755+
</template>
742756
<template v-if="column.key === 'templateversion'">
743757
<span> {{ record.version }} </span>
744758
</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)