server: add conditions for custom offerings (#4540)

Bug/unmanaged ingest exception.

Co-authored-by: Dirk Klahre <Dirk.Klahre@Itelligence.de>
This commit is contained in:
DK101010 2020-12-21 08:08:38 +01:00 committed by GitHub
parent 58a0a7b1a3
commit 874c7be67b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -7400,20 +7400,21 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
*/
private void postProcessingUnmanageVM(UserVmVO vm) {
ServiceOfferingVO offering = _serviceOfferingDao.findById(vm.getServiceOfferingId());
Long cpu = offering.getCpu() != null ? new Long(offering.getCpu()) : 0L;
Long ram = offering.getRamSize() != null ? new Long(offering.getRamSize()) : 0L;
// First generate a VM stop event if the VM was not stopped already
if (vm.getState() != State.Stopped) {
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VM_STOP, vm.getAccountId(), vm.getDataCenterId(),
vm.getId(), vm.getHostName(), vm.getServiceOfferingId(), vm.getTemplateId(),
vm.getHypervisorType().toString(), VirtualMachine.class.getName(), vm.getUuid(), vm.isDisplayVm());
resourceCountDecrement(vm.getAccountId(), vm.isDisplayVm(), new Long(offering.getCpu()), new Long(offering.getRamSize()));
resourceCountDecrement(vm.getAccountId(), vm.isDisplayVm(), cpu, ram);
}
// VM destroy usage event
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VM_DESTROY, vm.getAccountId(), vm.getDataCenterId(),
vm.getId(), vm.getHostName(), vm.getServiceOfferingId(), vm.getTemplateId(),
vm.getHypervisorType().toString(), VirtualMachine.class.getName(), vm.getUuid(), vm.isDisplayVm());
resourceCountDecrement(vm.getAccountId(), vm.isDisplayVm(), new Long(offering.getCpu()), new Long(offering.getRamSize()));
resourceCountDecrement(vm.getAccountId(), vm.isDisplayVm(), cpu, ram);
}
/*