mirror of https://github.com/apache/cloudstack.git
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:
parent
58a0a7b1a3
commit
874c7be67b
|
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue