Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,7 @@ public class ApiConstants {
public static final String NETWORK_SPANNED_ZONES = "zonesnetworkspans";
public static final String METADATA = "metadata";
public static final String PHYSICAL_SIZE = "physicalsize";
public static final String CHAIN_SIZE = "chainsize";
public static final String OVM3_POOL = "ovm3pool";
public static final String OVM3_CLUSTER = "ovm3cluster";
public static final String OVM3_VIP = "ovm3vip";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ public class SnapshotResponse extends BaseResponseWithTagInformation implements
@Param(description = "physical size of backedup snapshot on image store")
private long physicalSize;

@SerializedName(ApiConstants.CHAIN_SIZE)
@Param(description = "chain size of snapshot including all parent snapshots. Shown only for incremental snapshots if snapshot.show.chain.size setting is set to true", since = "4.21.0")
private Long chainSize;

@SerializedName(ApiConstants.ZONE_ID)
@Param(description = "id of the availability zone")
private String zoneId;
Expand Down Expand Up @@ -244,6 +248,10 @@ public void setPhysicalSize(long physicalSize) {
this.physicalSize = physicalSize;
}

public void setChainSize(long chainSize) {
this.chainSize = chainSize;
}

@Override
public void setProjectId(String projectId) {
this.projectId = projectId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import com.cloud.storage.VMTemplateStorageResourceAssoc;
import com.cloud.storage.Volume.Type;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.snapshot.SnapshotManager;
import com.cloud.user.Account;
import com.cloud.user.AccountService;
import com.cloud.utils.db.Filter;
Expand Down Expand Up @@ -96,9 +97,27 @@ private void setSnapshotInfoDetailsInResponse(SnapshotJoinVO snapshot, SnapshotR
} else {
snapshotResponse.setRevertable(snapshotInfo.isRevertable());
snapshotResponse.setPhysicalSize(snapshotInfo.getPhysicalSize());

boolean showChainSize = SnapshotManager.snapshotShowChainSize.valueIn(snapshot.getDataCenterId());
if (showChainSize && snapshotInfo.getParent() != null) {
long chainSize = calculateChainSize(snapshotInfo);
snapshotResponse.setChainSize(chainSize);
}
}
}

private long calculateChainSize(SnapshotInfo snapshotInfo) {
long chainSize = snapshotInfo.getPhysicalSize();
SnapshotInfo parent = snapshotInfo.getParent();

while (parent != null) {
chainSize += parent.getPhysicalSize();
parent = parent.getParent();
}

return chainSize;
}

private String getSnapshotStatus(SnapshotJoinVO snapshot) {
String status = snapshot.getStatus().toString();
if (snapshot.getDownloadState() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public interface SnapshotManager extends Configurable {
ConfigKey<Integer> snapshotDeltaMax = new ConfigKey<>(Integer.class, "snapshot.delta.max", "Snapshots", "16", "Max delta snapshots between two full snapshots. " +
"Only valid for KVM and XenServer.", true, ConfigKey.Scope.Global, null);

ConfigKey<Boolean> snapshotShowChainSize = new ConfigKey<>(Boolean.class, "snapshot.show.chain.size", "Snapshots", "false",
"Whether to show chain size (sum of physical size of snapshot and all its parents) for incremental snapshots in the snapshot response",
true, ConfigKey.Scope.Global, null);

void deletePoliciesForVolume(Long volumeId);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public String getConfigComponentName() {
@Override
public ConfigKey<?>[] getConfigKeys() {
return new ConfigKey<?>[] {BackupRetryAttempts, BackupRetryInterval, SnapshotHourlyMax, SnapshotDailyMax, SnapshotMonthlyMax, SnapshotWeeklyMax, usageSnapshotSelection,
SnapshotInfo.BackupSnapshotAfterTakingSnapshot, VmStorageSnapshotKvm, kvmIncrementalSnapshot, snapshotDeltaMax};
SnapshotInfo.BackupSnapshotAfterTakingSnapshot, VmStorageSnapshotKvm, kvmIncrementalSnapshot, snapshotDeltaMax, snapshotShowChainSize};
}

@Override
Expand Down
1 change: 1 addition & 0 deletions ui/public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@
"label.certificate.upload.failed": "Certificate upload failed",
"label.certificate.upload.failed.description": "Failed to update SSL Certificate. Failed to pass certificate validation check.",
"label.certificateid": "Certificate ID",
"label.chainsize": "Chain size",
"label.change": "Change",
"label.change.affinity": "Change affinity",
"label.change.bgp.peers": "Change BGP peers",
Expand Down
17 changes: 14 additions & 3 deletions ui/src/components/view/DetailsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,22 @@
</div>
<div v-else-if="['template', 'iso'].includes($route.meta.name) && item === 'size'">
<div>
{{ parseFloat(dataResource.size / (1024.0 * 1024.0 * 1024.0)).toFixed(2) }} GiB
{{ sizeInGiB(dataResource.size) }} GiB
</div>
</div>
<div v-else-if="['volume', 'snapshot', 'template', 'iso'].includes($route.meta.name) && item === 'physicalsize'">
<div>
{{ parseFloat(dataResource.physicalsize / (1024.0 * 1024.0 * 1024.0)).toFixed(2) }} GiB
{{ sizeInGiB(dataResource.physicalsize) }} GiB
</div>
</div>
<div v-else-if="['volume', 'snapshot', 'template', 'iso'].includes($route.meta.name) && item === 'virtualsize'">
<div>
{{ parseFloat(dataResource.virtualsize / (1024.0 * 1024.0 * 1024.0)).toFixed(2) }} GiB
{{ sizeInGiB(dataResource.virtualsize) }} GiB
</div>
</div>
<div v-else-if="$route.meta.name === 'snapshot' && item === 'chainsize'">
<div>
{{ sizeInGiB(dataResource.chainsize) }} GiB
</div>
</div>
<div v-else-if="['name', 'type'].includes(item)">
Expand Down Expand Up @@ -472,6 +477,12 @@ export default {
}

return `label.${source}`
},
sizeInGiB (sizeInBytes) {
if (!sizeInBytes || sizeInBytes === 0) {
return '0.00'
}
return parseFloat(sizeInBytes / (1024.0 * 1024.0 * 1024.0)).toFixed(2)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/config/section/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ export default {
fields.push('zonename')
return fields
},
details: ['name', 'id', 'volumename', 'volumetype', 'snapshottype', 'intervaltype', 'physicalsize', 'virtualsize', 'account', 'domain', 'created'],
details: ['name', 'id', 'volumename', 'volumetype', 'snapshottype', 'intervaltype', 'physicalsize', 'virtualsize', 'chainsize', 'account', 'domain', 'created'],
tabs: [
{
name: 'details',
Expand Down
Loading