Skip to content

Commit 189b0e4

Browse files
PranaliMyadvr
authored andcommitted
CLOUDSTACK-10060: ListUsage API always displays the Virtual size as '0' for Usage type=9 (snapshot) (#2257)
Bug Description: In the listUsage API, the Virtual Size of Snapshot is always displayed as '0'. Root Cause: In case of snapshots, the usage is accounted for depending on the value of the global parameter, 'usage.snapshot.virtualsize.select'. If set to 'true', the usage calculation is done based on the Virtual Size, and if set to false, it is done based on the Physical size. In the Usage API, this value, (i.e. virtual or physical) is displayed as 'Size' field correctly, but the field 'VirtualSize' is always displayed as 0. This is misleading. Expected Output: Since this is a Usage API, ideally only that size should be displayed which is used for billing, depending on the value of 'usage.snapshot.virtualsize.select'. There is another API - the ListSnapshot API that displays both, the physical as well as Virtual size and can be used to know both the sizes. Fix Implemented: Skipped showing the 'VirtualSize' Field for type=snapshot
1 parent c3ed1b3 commit 189b0e4

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

usage/src/com/cloud/usage/parser/StorageUsageParser.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,11 @@ private static void createUsageRecord(long zoneId, int type, long runningTime, D
181181
usageDesc += "Snapshot ";
182182
break;
183183
}
184-
// Create the usage record
185-
usageDesc += "Id:" + storageId + " Size:" + size + "VirtualSize:" + virtualSize;
184+
//Create the usage record
185+
usageDesc += "Id:" + storageId + " Size:" + size;
186+
if (type != StorageTypes.SNAPSHOT) {
187+
usageDesc += " VirtualSize:" + virtualSize;
188+
}
186189

187190
//ToDo: get zone id
188191
UsageVO usageRecord =

0 commit comments

Comments
 (0)