You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2022/09/30 11:02:10 UTC
[GitHub] [cloudstack] GutoVeronezi commented on a diff in pull request #6772: Fix to make recovered volumes be accounted for by Usage
GutoVeronezi commented on code in PR #6772:
URL: https://github.com/apache/cloudstack/pull/6772#discussion_r984474774
##########
server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java:
##########
@@ -1709,9 +1709,30 @@ public Volume recoverVolume(long volumeId) {
_resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.volume, volume.isDisplay());
_resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.primary_storage, volume.isDisplay(), new Long(volume.getSize()));
+
+ publishVolumeCreationUsageEvent(volume);
+
return volume;
}
+ public void publishVolumeCreationUsageEvent(Volume volume) {
+ Long diskOfferingId = volume.getDiskOfferingId();
+ Long offeringId = null;
+ if (diskOfferingId != null) {
+ DiskOfferingVO offering = _diskOfferingDao.findById(diskOfferingId);
+ if (offering != null && !offering.isComputeOnly()) {
+ offeringId = offering.getId();
+ }
+ }
+ UsageEventUtils
+ .publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), offeringId,
+ volume.getTemplateId(), volume.getSize(), Volume.class.getName(), volume.getUuid(), volume.isDisplayVolume());
Review Comment:
```suggestion
volume.getTemplateId(), volume.getSize(), Volume.class.getName(), volume.getUuid(), volume.isDisplay());
```
As reporter by SonarCloud, `isDisplayVolume` is deprecated; we can use `isDisplay` instead.
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org