use of org.ovirt.engine.core.common.businessentities.comparators.VmsComparer in project ovirt-engine by oVirt.
the class MigrateVMActionRunner method sortCommands.
@Override
protected void sortCommands() {
List<CommandBase<?>> commands = getCommands();
final Map<Guid, VM> vms = new HashMap<>(commands.size());
for (CommandBase<?> cmd : commands) {
vms.put(cmd.getVmId(), vmDao.get(cmd.getVmId()));
}
Collections.sort(commands, Comparator.comparing((CommandBase<?> c) -> vms.get(c.getVmId()), new VmsComparer()).reversed());
}
use of org.ovirt.engine.core.common.businessentities.comparators.VmsComparer in project ovirt-engine by oVirt.
the class ClearNonResponsiveVdsVmsCommand method executeCommand.
@Override
protected void executeCommand() {
List<VM> vms = vmDao.getAllRunningForVds(getVdsId());
Collections.sort(vms, Collections.reverseOrder(new VmsComparer()));
List<Guid> autoStartVmIdsToRerun = new ArrayList<>();
for (VM vm : vms) {
if (vm.isAutoStartup()) {
autoStartVmIdsToRerun.add(vm.getId());
}
VDSReturnValue returnValue = runVdsCommand(VDSCommandType.SetVmStatus, new SetVmStatusVDSCommandParameters(vm.getId(), VMStatus.Down, VmExitStatus.Error));
// Write that this VM was shut down by host reboot or manual fence
if (returnValue != null && returnValue.getSucceeded()) {
logSettingVmToDown(vm);
}
runInternalActionWithTasksContext(ActionType.ProcessDownVm, new ProcessDownVmParameters(vm.getId(), true));
}
runVdsCommand(VDSCommandType.UpdateVdsVMsCleared, new UpdateVdsVMsClearedVDSCommandParameters(getVdsId()));
if (!autoStartVmIdsToRerun.isEmpty()) {
haAutoStartVmsRunner.addVmsToRun(autoStartVmIdsToRerun);
}
setSucceeded(true);
}
Aggregations