Source:
<code>private void saveDataToDb() { if (_saveVdsDynamic) { _vdsManager.updateDynamicData(_vds.getDynamicData()); } if (_saveVdsStatistics) { VdsStatistics stat = _vds.getStatisticsData(); _vdsManager.updateStatisticsData(stat); checkVdsMemoryThreshold(stat); checkVdsCpuThreshold(stat); checkVdsNetworkThreshold(stat); checkVdsSwapThreshold(stat); final List<VdsNetworkStatistics> statistics = new LinkedList<VdsNetworkStatistics>(); for (VdsNetworkInterface iface : _vds.getInterfaces()) { statistics.add(iface.getStatistics()); } if (!statistics.isEmpty()) { TransactionSupport.executeInScope(TransactionScopeOption.Required, new TransactionMethod<Void>() { @Override public Void runInTransaction() { getDbFacade().getInterfaceDao().massUpdateStatisticsForVds(statistics); return null; } }); } } for (VmDynamic vmDynamic : _vmDynamicToSave.values()) { <START> if (vmDynamic.getStatus() == VMStatus.Up) { <END> vmDynamic.setReason(""); } } getDbFacade().getVmDynamicDao().updateAllInBatch(_vmDynamicToSave.values()); getDbFacade().getVmStatisticsDao().updateAllInBatch(_vmStatisticsToSave.values()); final List<VmNetworkStatistics> allVmInterfaceStatistics = new LinkedList<VmNetworkStatistics>(); for (List<VmNetworkInterface> list : _vmInterfaceStatisticsToSave.values()) { for (VmNetworkInterface iface : list) { allVmInterfaceStatistics.add(iface.getStatistics()); } } getDbFacade().getVmNetworkStatisticsDao().updateAllInBatch(allVmInterfaceStatistics); getDbFacade().getDiskImageDynamicDao().updateAllInBatch(_vmDiskImageDynamicToSave.values()); getDbFacade().getLunDao().updateAllInBatch(vmLunDisksToSave); saveVmDevicesToDb(); saveVmGuestAgentNetworkDevices(); getVdsEventListener().addExternallyManagedVms(_externalVmsToAdd); }</code><technical_language>clearing this start command? of this scenario: user stop vm some reason, start fails start, vm is reason, user didnt stop vm again</technical_language>

Target:
private void saveDataToDb() { if (_saveVdsDynamic) { _vdsManager.updateDynamicData(_vds.getDynamicData()); } if (_saveVdsStatistics) { VdsStatistics stat = _vds.getStatisticsData(); _vdsManager.updateStatisticsData(stat); checkVdsMemoryThreshold(stat); checkVdsCpuThreshold(stat); checkVdsNetworkThreshold(stat); checkVdsSwapThreshold(stat); final List<VdsNetworkStatistics> statistics = new LinkedList<VdsNetworkStatistics>(); for (VdsNetworkInterface iface : _vds.getInterfaces()) { statistics.add(iface.getStatistics()); } if (!statistics.isEmpty()) { TransactionSupport.executeInScope(TransactionScopeOption.Required, new TransactionMethod<Void>() { @Override public Void runInTransaction() { getDbFacade().getInterfaceDao().massUpdateStatisticsForVds(statistics); return null; } }); } } getDbFacade().getVmDynamicDao().updateAllInBatch(_vmDynamicToSave.values()); getDbFacade().getVmStatisticsDao().updateAllInBatch(_vmStatisticsToSave.values()); final List<VmNetworkStatistics> allVmInterfaceStatistics = new LinkedList<VmNetworkStatistics>(); for (List<VmNetworkInterface> list : _vmInterfaceStatisticsToSave.values()) { for (VmNetworkInterface iface : list) { allVmInterfaceStatistics.add(iface.getStatistics()); } } getDbFacade().getVmNetworkStatisticsDao().updateAllInBatch(allVmInterfaceStatistics); getDbFacade().getDiskImageDynamicDao().updateAllInBatch(_vmDiskImageDynamicToSave.values()); getDbFacade().getLunDao().updateAllInBatch(vmLunDisksToSave); saveVmDevicesToDb(); saveVmGuestAgentNetworkDevices(); getVdsEventListener().addExternallyManagedVms(_externalVmsToAdd); }