Pearl1594 commented on code in PR #14166:
URL: https://github.com/apache/cloudstack/pull/14166#discussion_r4670294817
##########
engine/components-api/src/main/java/com/cloud/event/UsageEventUtils.java:
##########
@@ -94,6 +108,52 @@ public static void publishUsageEvent(String usageType, long
accountId, long zone
}
+ // named distinctly, rather than as another publishUsageEvent(...)
overload, because its parameter shape
+ // (Map<String, String>, boolean) is only distinguishable at compile time
from the existing (Long, boolean)
+ // overload above when neither argument is a literal null - several
existing call sites pass null literals
+ // here, which would make an overload ambiguous
+ public static void publishUsageEventWithDetails(String usageType, long
accountId, long zoneId, long resourceId, String resourceName, Long offeringId,
Long templateId,
+ Long size, String entityType, String
entityUUID, Map<String, String> details, boolean displayResource) {
+ if (displayResource) {
+ saveUsageEvent(usageType, accountId, zoneId, resourceId,
resourceName, offeringId, templateId, size, details);
+ }
+ publishUsageEvent(usageType, accountId, zoneId, entityType,
entityUUID);
+ }
+
+ /**
+ * Emits one {@code usageType} usage event per network a NIC is actually
billed against - its primary
+ * network, plus any additional networks it is associated with as a
multi-VLAN trunk nic. An ordinary,
+ * non-trunk nic has exactly one such network, so this is identical to
today's single-event behaviour for
+ * every legacy nic. Each event carries the network id as a detail, so the
usage-processing side can
+ * disambiguate rows when a trunk nic's networks share the same network
offering.
+ */
+ public static void publishNicNetworkOfferingUsageEvents(String usageType,
long accountId, long zoneId, long vmId, String entityType, String entityUUID,
+ Nic nic, long isDefault, boolean displayResource) {
+ NetworkVO primaryNetwork = s_networkDao.findById(nic.getNetworkId());
+ if (primaryNetwork != null) {
+ publishNicNetworkOfferingUsageEvent(usageType, accountId, zoneId,
vmId, entityType, entityUUID, nic.getId(), primaryNetwork, isDefault,
displayResource);
+ }
+ if (nic.getMultiNetwork()) {
+ for (NicNetworkMapVO association :
s_nicNetworkMapDao.listByNicId(nic.getId())) {
+ NetworkVO associatedNetwork =
s_networkDao.findById(association.getNetworkId());
+ if (associatedNetwork != null) {
+ publishNicNetworkOfferingUsageEvent(usageType, accountId,
zoneId, vmId, entityType, entityUUID, nic.getId(), associatedNetwork, isDefault,
Review Comment:
Fixed in #14803
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]