sureshanaparti commented on code in PR #12465:
URL: https://github.com/apache/cloudstack/pull/12465#discussion_r2704738727
##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java:
##########
@@ -1873,6 +1882,31 @@ public Answer createSnapshot(final CreateObjectCommand
cmd) {
}
}
+ private long getRdbSnapshotSize(String poolPath, String diskName, String
snapshotName, String rbdMonitor, String authUser, String authSecret) {
+ logger.debug("Get RBD snapshot size for {}/{}@{}", poolPath, diskName,
snapshotName);
+ //cmd: rbd du <pool>/<disk-name>@<snapshot-name> --format json
--mon-host <monitor-host> --id <user> --key <key> 2>/dev/null
+ String snapshotDetailsInJson =
Script.runSimpleBashScript(String.format("rbd du %s/%s@%s --format json
--mon-host %s --id %s --key %s 2>/dev/null", poolPath, diskName, snapshotName,
rbdMonitor, authUser, authSecret));
+ if (StringUtils.isNotBlank(snapshotDetailsInJson)) {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ JsonNode root = mapper.readTree(snapshotDetailsInJson);
+ for (JsonNode image : root.path("images")) {
+ if (snapshotName.equals(image.path("snapshot").asText())) {
+ long usedSizeInBytes =
image.path("used_size").asLong();
+ if (usedSizeInBytes > 0) {
+ logger.debug("RBD snapshot {}/{}@{} used size in
bytes: {}", poolPath, diskName, snapshotName, usedSizeInBytes);
+ return usedSizeInBytes;
+ }
+ }
+ }
+ } catch (JsonProcessingException e) {
+ logger.error("Unable to get the RBD snapshot size", e);
+ }
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]