Skip to content

Commit 835ca8e

Browse files
committed
CLOUDSTACK-7018: Restore VM - missing destroyed usage event for the destroyed root volume. Also removed the resource count logic since we destroy the old root volume and create a new one.
1 parent 8a21633 commit 835ca8e

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

server/src/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4732,21 +4732,20 @@ public UserVm restoreVMInternal(Account caller, UserVmVO vm, Long newTemplateId)
47324732
} else {
47334733
newVol = volumeMgr.allocateDuplicateVolume(root, null);
47344734
}
4735-
// 1. Save usage event and update resource count for user vm volumes
4736-
_resourceLimitMgr.incrementResourceCount(vm.getAccountId(), ResourceType.volume);
4737-
//2. Create Usage event for the newly created volume
4735+
4736+
// Create Usage event for the newly created volume
47384737
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_CREATE, newVol.getAccountId(), newVol.getDataCenterId(), newVol.getId(), newVol.getName(), newVol.getDiskOfferingId(), templateId, newVol.getSize());
47394738
_usageEventDao.persist(usageEvent);
47404739

47414740
handleManagedStorage(vm, root);
47424741

47434742
_volsDao.attachVolume(newVol.getId(), vmId, newVol.getDeviceId());
47444743

4745-
/* Detach and destory the old root volume */
4746-
4744+
// Detach, destroy and create the usage event for the old root volume.
47474745
_volsDao.detachVolume(root.getId());
4748-
47494746
volumeMgr.destroyVolume(root);
4747+
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_DELETE, root.getAccountId(), root.getDataCenterId(), root.getId(), root.getName(),
4748+
Volume.class.getName(), root.getUuid(), root.isDisplayVolume());
47504749

47514750
// For VMware hypervisor since the old root volume is replaced by the new root volume, force expunge old root volume if it has been created in storage
47524751
if (vm.getHypervisorType() == HypervisorType.VMware) {

0 commit comments

Comments
 (0)