Source:
protected Pair<VDS, VDSStatus> evaluatePowerManagementSituation(List<VDS> pmDownHosts, List<VDS> pmMaintenanceHosts, List<VDS> emptyHosts, Map<String, String> parameters) { final int requiredReserve = tryParseWithDefault(parameters.get("HostsInReserve"), Config .<Integer> getValue(ConfigValues.HostsInReserve)); String enableAutoPM = parameters.get("EnableAutomaticHostPowerManagement"); if (enableAutoPM == null) { enableAutoPM = Config.<String> getValue(ConfigValues.EnableAutomaticHostPowerManagement); } if (enableAutoPM.compareTo("false") == 0) return null; if (requiredReserve > emptyHosts.size() && pmDownHosts.isEmpty() && pmMaintenanceHosts.isEmpty()) return null; else if (requiredReserve < emptyHosts.size() && pmMaintenanceHosts.size() > 1) { return new Pair<>(pmMaintenanceHosts.get(0), VDSStatus.Down); } else if (requiredReserve < emptyHosts.size()) { List<VDS> hostsWithAutoPM = LinqUtils.filter(emptyHosts, new Predicate<VDS>() { @Override public boolean eval(VDS vds) { return !vds.isDisablePowerManagementPolicy() && vds.getSpmStatus() != VdsSpmStatus.SPM && vds.getpm_enabled(); } }); return hostsWithAutoPM.isEmpty() ? null : new Pair<>(hostsWithAutoPM.get(0), VDSStatus.Maintenance); } else if (requiredReserve == emptyHosts.size() && pmMaintenanceHosts.isEmpty() == false) { return new Pair<>(pmMaintenanceHosts.get(0), VDSStatus.Down); } else if (requiredReserve > emptyHosts.size() && pmMaintenanceHosts.isEmpty() == false) { return new Pair<>(pmMaintenanceHosts.get(0), VDSStatus.Up); } else if (requiredReserve > emptyHosts.size() && pmMaintenanceHosts.isEmpty()) { return new Pair<>(pmDownHosts.get(0), VDSStatus.Up); } return null; }

Target:
protected Pair<VDS, VDSStatus> evaluatePowerManagementSituation(List<VDS> pmDownHosts, List<VDS> pmMaintenanceHosts, List<VDS> emptyHosts, Map<String, String> parameters) { final int requiredReserve = tryParseWithDefault(parameters.get("HostsInReserve"), Config .<Integer> getValue(ConfigValues.HostsInReserve)); String enableAutoPM = parameters.get("EnableAutomaticHostPowerManagement"); if (enableAutoPM == null) { enableAutoPM = Config.<String> getValue(ConfigValues.EnableAutomaticHostPowerManagement); } if (enableAutoPM.compareTo("false") == 0) { return null; } if (requiredReserve > emptyHosts.size() && pmDownHosts.isEmpty() && pmMaintenanceHosts.isEmpty()) return null; else if (requiredReserve < emptyHosts.size() && pmMaintenanceHosts.size() > 1) { return new Pair<>(pmMaintenanceHosts.get(0), VDSStatus.Down); } else if (requiredReserve < emptyHosts.size()) { List<VDS> hostsWithAutoPM = LinqUtils.filter(emptyHosts, new Predicate<VDS>() { @Override public boolean eval(VDS vds) { return !vds.isDisablePowerManagementPolicy() && vds.getSpmStatus() != VdsSpmStatus.SPM && vds.getpm_enabled(); } }); return hostsWithAutoPM.isEmpty() ? null : new Pair<>(hostsWithAutoPM.get(0), VDSStatus.Maintenance); } else if (requiredReserve == emptyHosts.size() && pmMaintenanceHosts.isEmpty() == false) { return new Pair<>(pmMaintenanceHosts.get(0), VDSStatus.Down); } else if (requiredReserve > emptyHosts.size() && pmMaintenanceHosts.isEmpty() == false) { return new Pair<>(pmMaintenanceHosts.get(0), VDSStatus.Up); } else if (requiredReserve > emptyHosts.size() && pmMaintenanceHosts.isEmpty()) { return new Pair<>(pmDownHosts.get(0), VDSStatus.Up); } return null; }