String usageDesc = "network bytes sent";
if (networkInfo.getHostId() != 0) {
hostId = networkInfo.getHostId();
usageDesc += " for Host: " + networkInfo.getHostId();
}
UsageVO usageRecord =
new UsageVO(networkInfo.getZoneId(), account.getId(), account.getDomainId(), usageDesc, totalBytesSent + " bytes sent",
UsageTypes.NETWORK_BYTES_SENT, new Double(totalBytesSent), hostId, networkInfo.getHostType(), networkInfo.getNetworkId(), startDate, endDate);
usageRecords.add(usageRecord);
// Create the usage record for bytes received
usageDesc = "network bytes received";
if (networkInfo.getHostId() != 0) {
usageDesc += " for Host: " + networkInfo.getHostId();
}
usageRecord =
new UsageVO(networkInfo.getZoneId(), account.getId(), account.getDomainId(), usageDesc, totalBytesReceived + " bytes received",
UsageTypes.NETWORK_BYTES_RECEIVED, new Double(totalBytesReceived), hostId, networkInfo.getHostType(), networkInfo.getNetworkId(), startDate,
endDate);
usageRecords.add(usageRecord);
} else {
// Don't charge anything if there were zero bytes processed