Skip to content
Open
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
6 changes: 4 additions & 2 deletions server/src/main/java/com/cloud/api/ApiResponseHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -4364,7 +4364,7 @@ public UsageRecordResponse createUsageResponse(Usage usageRecord, Map<String, Se
} else if (usageRecord.getUsageType() == UsageTypes.BACKUP) {
resourceType = ResourceObjectType.Backup;
final StringBuilder builder = new StringBuilder();
builder.append("Backup usage of size ").append(usageRecord.getUsageDisplay());
builder.append("Backup usage");
if (vmInstance != null) {
resourceId = vmInstance.getId();
usageRecResponse.setResourceName(vmInstance.getInstanceName());
Expand All @@ -4377,9 +4377,11 @@ public UsageRecordResponse createUsageResponse(Usage usageRecord, Map<String, Se
.append(" (").append(backupOffering.getUuid()).append(", user ad-hoc/scheduled backup allowed: ")
.append(backupOffering.isUserDrivenBackupAllowed()).append(")");
}

}
builder.append(" with size ").append(toHumanReadableSize(usageRecord.getVirtualSize()));
usageRecResponse.setDescription(builder.toString());
usageRecResponse.setSize(usageRecord.getSize());
usageRecResponse.setVirtualSize(usageRecord.getVirtualSize());
} else if (usageRecord.getUsageType() == UsageTypes.VM_SNAPSHOT) {
resourceType = ResourceObjectType.VMSnapshot;
VMSnapshotVO vmSnapshotVO = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,11 @@ public static boolean parse(AccountVO account, Date startDate, Date endDate) {
DecimalFormat dFormat = new DecimalFormat("#.######");
String usageDisplay = dFormat.format(usage);

final Double rawUsage = (double) usageBackup.getSize();
final String description = String.format("Backup usage VM ID: %d, backup offering: %d", vmId, offeringId);

final UsageVO usageRecord =
new UsageVO(zoneId, account.getAccountId(), account.getDomainId(), description, usageDisplay + " Hrs",
UsageTypes.BACKUP, new Double(usage), vmId, null, offeringId, null, vmId,
UsageTypes.BACKUP, (double) usage, vmId, null, offeringId, null, vmId,
usageBackup.getSize(), usageBackup.getProtectedSize(), startDate, endDate);
s_usageDao.persist(usageRecord);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private static void createUsageRecord(int usageType, long runningTime, Date star
String usageDesc = "VMSnapshot Id: " + vmSnapshotId + " On Primary Usage: VM Id: " + vmId;
usageDesc += " Size: " + toHumanReadableSize(virtualSize);

UsageVO usageRecord = new UsageVO(zoneId, account.getId(), account.getDomainId(), usageDesc, usageDisplay + " Hrs", usageType, new Double(usage), vmId, name, null, null,
UsageVO usageRecord = new UsageVO(zoneId, account.getId(), account.getDomainId(), usageDesc, usageDisplay + " Hrs", usageType, (double) usage, vmId, name, null, null,
vmSnapshotId, physicalSize, virtualSize, startDate, endDate);
s_usageDao.persist(usageRecord);
}
Expand Down
Loading