|
59 | 59 | import com.cloud.event.EventTypes; |
60 | 60 | import com.cloud.event.EventUtils; |
61 | 61 | import com.cloud.event.EventVO; |
| 62 | +import com.cloud.event.UsageEventVO; |
62 | 63 | import com.cloud.event.dao.EventDao; |
| 64 | +import com.cloud.event.dao.UsageEventDao; |
63 | 65 | import com.cloud.exception.InvalidParameterValueException; |
64 | 66 | import com.cloud.exception.PermissionDeniedException; |
65 | 67 | import com.cloud.exception.ResourceAllocationException; |
@@ -138,6 +140,7 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma |
138 | 140 | @Inject protected AsyncJobManager _asyncMgr; |
139 | 141 | @Inject protected AccountManager _accountMgr; |
140 | 142 | @Inject protected ClusterDao _clusterDao; |
| 143 | + @Inject private UsageEventDao _usageEventDao; |
141 | 144 | String _name; |
142 | 145 | private int _totalRetries; |
143 | 146 | private int _pauseInterval; |
@@ -524,6 +527,8 @@ public boolean backupSnapshotToSecondaryStorage(SnapshotVO ss, long startEventId |
524 | 527 | event.setDescription("Backed up snapshot id: " + snapshotId + " to secondary for volume:" + volumeId); |
525 | 528 | event.setLevel(EventVO.LEVEL_INFO); |
526 | 529 | event.setParameters(eventParams); |
| 530 | + UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_SNAPSHOT_CREATE, snapshot.getAccountId(), volume.getDataCenterId(), snapshotId, snapshotName, null, null, volume.getSize()); |
| 531 | + _usageEventDao.persist(usageEvent); |
527 | 532 |
|
528 | 533 | } |
529 | 534 | else { |
@@ -769,6 +774,12 @@ public boolean destroySnapshotBackUp(long userId, long snapshotId, long policyId |
769 | 774 | event.setLevel(success ? EventVO.LEVEL_INFO : EventVO.LEVEL_ERROR); |
770 | 775 | _eventDao.persist(event); |
771 | 776 |
|
| 777 | + if(success){ |
| 778 | + UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_SNAPSHOT_DELETE, snapshot.getAccountId(), volume.getDataCenterId(), snapshotId, snapshot.getName(), null, null, volume.getSize()); |
| 779 | + _usageEventDao.persist(usageEvent); |
| 780 | + } |
| 781 | + |
| 782 | + |
772 | 783 | return success; |
773 | 784 |
|
774 | 785 | } |
@@ -955,6 +966,8 @@ else if (answer != null) { |
955 | 966 | event.setParameters(eventParams); |
956 | 967 | event.setLevel(EventVO.LEVEL_INFO); |
957 | 968 | _eventDao.persist(event); |
| 969 | + UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_SNAPSHOT_DELETE, snapshot.getAccountId(), volume.getDataCenterId(), snapshot.getId(), snapshot.getName(), null, null, volume.getSize()); |
| 970 | + _usageEventDao.persist(usageEvent); |
958 | 971 | } |
959 | 972 | } |
960 | 973 | } |
|
0 commit comments