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 @@
private IPAddressDao _ipDao;
@Inject
private HostDao _hostDao;
@Inject
private NetworkOfferingDao _networkOfferingDao;

public UsageServiceImpl() {
}
Expand Down Expand Up @@ -253,6 +257,7 @@
}

Long usageDbId = null;
boolean offeringExistsForNetworkOfferingType = false;

Check warning on line 260 in server/src/main/java/com/cloud/usage/UsageServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/usage/UsageServiceImpl.java#L260

Added line #L260 was not covered by tests

switch (usageType.intValue()) {
case UsageTypes.NETWORK_BYTES_RECEIVED:
Expand Down Expand Up @@ -326,13 +331,19 @@
usageDbId = ip.getId();
}
break;
case UsageTypes.NETWORK_OFFERING:
NetworkOfferingVO networkOffering = _networkOfferingDao.findByUuidIncludingRemoved(usageId);

Check warning on line 335 in server/src/main/java/com/cloud/usage/UsageServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/usage/UsageServiceImpl.java#L335

Added line #L335 was not covered by tests
if (networkOffering != null) {
offeringExistsForNetworkOfferingType = true;
sc.addAnd("offeringId", SearchCriteria.Op.EQ, networkOffering.getId());

Check warning on line 338 in server/src/main/java/com/cloud/usage/UsageServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/usage/UsageServiceImpl.java#L337-L338

Added lines #L337 - L338 were not covered by tests
}
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