Skip to content
Merged
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
13 changes: 12 additions & 1 deletion server/src/main/java/com/cloud/usage/UsageServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import javax.naming.ConfigurationException;

import com.cloud.domain.Domain;
import com.cloud.offerings.NetworkOfferingVO;
import com.cloud.offerings.dao.NetworkOfferingDao;
import org.apache.cloudstack.api.command.admin.usage.GenerateUsageRecordsCmd;
import org.apache.cloudstack.api.command.admin.usage.ListUsageRecordsCmd;
import org.apache.cloudstack.api.command.admin.usage.RemoveRawUsageRecordsCmd;
Expand Down Expand Up @@ -122,6 +124,8 @@ public class UsageServiceImpl extends ManagerBase implements UsageService, Manag
private IPAddressDao _ipDao;
@Inject
private HostDao _hostDao;
@Inject
private NetworkOfferingDao _networkOfferingDao;

public UsageServiceImpl() {
}
Expand Down Expand Up @@ -253,6 +257,7 @@ public Pair<List<? extends Usage>, Integer> getUsageRecords(ListUsageRecordsCmd
}

Long usageDbId = null;
boolean offeringExistsForNetworkOfferingType = false;

switch (usageType.intValue()) {
case UsageTypes.NETWORK_BYTES_RECEIVED:
Expand Down Expand Up @@ -326,13 +331,19 @@ public Pair<List<? extends Usage>, Integer> getUsageRecords(ListUsageRecordsCmd
usageDbId = ip.getId();
}
break;
case UsageTypes.NETWORK_OFFERING:
NetworkOfferingVO networkOffering = _networkOfferingDao.findByUuidIncludingRemoved(usageId);
if (networkOffering != null) {
offeringExistsForNetworkOfferingType = true;
sc.addAnd("offeringId", SearchCriteria.Op.EQ, networkOffering.getId());
}
default:
break;
}

if (usageDbId != null) {
sc.addAnd("usageId", SearchCriteria.Op.EQ, usageDbId);
} else {
} else if (!offeringExistsForNetworkOfferingType) {
// return an empty list if usageId was not found
return new Pair<List<? extends Usage>, Integer>(new ArrayList<Usage>(), new Integer(0));
}
Expand Down