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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to