|
213 | 213 | import com.cloud.service.dao.ServiceOfferingDao; |
214 | 214 | import com.cloud.storage.DiskOfferingVO; |
215 | 215 | import com.cloud.storage.ScopeType; |
216 | | -import com.cloud.storage.Storage.ImageFormat; |
217 | 216 | import com.cloud.storage.Storage; |
| 217 | +import com.cloud.storage.Storage.ImageFormat; |
218 | 218 | import com.cloud.storage.StorageManager; |
219 | 219 | import com.cloud.storage.StoragePool; |
220 | 220 | import com.cloud.storage.VMTemplateVO; |
@@ -2208,9 +2208,14 @@ private void advanceStop(final VMInstanceVO vm, final boolean cleanUpEvenIfUnabl |
2208 | 2208 |
|
2209 | 2209 | boolean result = stateTransitTo(vm, Event.OperationSucceeded, null); |
2210 | 2210 | if (result) { |
2211 | | - if (VirtualMachine.Type.User.equals(vm.type) && ResourceCountRunningVMsonly.value()) { |
2212 | | - ServiceOfferingVO offering = _offeringDao.findById(vm.getId(), vm.getServiceOfferingId()); |
2213 | | - resourceCountDecrement(vm.getAccountId(),new Long(offering.getCpu()), new Long(offering.getRamSize())); |
| 2211 | + if (VirtualMachine.Type.User.equals(vm.type)) { |
| 2212 | + vm.setPowerState(PowerState.PowerOff); |
| 2213 | + _vmDao.update(vm.getId(), vm); |
| 2214 | + |
| 2215 | + if (ResourceCountRunningVMsonly.value()) { |
| 2216 | + ServiceOfferingVO offering = _offeringDao.findById(vm.getId(), vm.getServiceOfferingId()); |
| 2217 | + resourceCountDecrement(vm.getAccountId(),new Long(offering.getCpu()), new Long(offering.getRamSize())); |
| 2218 | + } |
2214 | 2219 | } |
2215 | 2220 | } else { |
2216 | 2221 | throw new CloudRuntimeException("unable to stop " + vm); |
|
0 commit comments