Skip to content

Commit 874c7be

Browse files
DK101010Dirk Klahre
andauthored
server: add conditions for custom offerings (#4540)
Bug/unmanaged ingest exception. Co-authored-by: Dirk Klahre <Dirk.Klahre@Itelligence.de>
1 parent 58a0a7b commit 874c7be

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7400,20 +7400,21 @@ private void removeVMFromAffinityGroups(long vmId) {
74007400
*/
74017401
private void postProcessingUnmanageVM(UserVmVO vm) {
74027402
ServiceOfferingVO offering = _serviceOfferingDao.findById(vm.getServiceOfferingId());
7403-
7403+
Long cpu = offering.getCpu() != null ? new Long(offering.getCpu()) : 0L;
7404+
Long ram = offering.getRamSize() != null ? new Long(offering.getRamSize()) : 0L;
74047405
// First generate a VM stop event if the VM was not stopped already
74057406
if (vm.getState() != State.Stopped) {
74067407
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VM_STOP, vm.getAccountId(), vm.getDataCenterId(),
74077408
vm.getId(), vm.getHostName(), vm.getServiceOfferingId(), vm.getTemplateId(),
74087409
vm.getHypervisorType().toString(), VirtualMachine.class.getName(), vm.getUuid(), vm.isDisplayVm());
7409-
resourceCountDecrement(vm.getAccountId(), vm.isDisplayVm(), new Long(offering.getCpu()), new Long(offering.getRamSize()));
7410+
resourceCountDecrement(vm.getAccountId(), vm.isDisplayVm(), cpu, ram);
74107411
}
74117412

74127413
// VM destroy usage event
74137414
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VM_DESTROY, vm.getAccountId(), vm.getDataCenterId(),
74147415
vm.getId(), vm.getHostName(), vm.getServiceOfferingId(), vm.getTemplateId(),
74157416
vm.getHypervisorType().toString(), VirtualMachine.class.getName(), vm.getUuid(), vm.isDisplayVm());
7416-
resourceCountDecrement(vm.getAccountId(), vm.isDisplayVm(), new Long(offering.getCpu()), new Long(offering.getRamSize()));
7417+
resourceCountDecrement(vm.getAccountId(), vm.isDisplayVm(), cpu, ram);
74177418
}
74187419

74197420
/*

0 commit comments

Comments
 (0)