diff --git a/server/src/com/cloud/capacity/CapacityManagerImpl.java b/server/src/com/cloud/capacity/CapacityManagerImpl.java index 14afd5e86f1..86f62945d37 100644 --- a/server/src/com/cloud/capacity/CapacityManagerImpl.java +++ b/server/src/com/cloud/capacity/CapacityManagerImpl.java @@ -82,7 +82,7 @@ public class CapacityManagerImpl implements CapacityManager , StateListener clusters = null; if (plan.getClusterId() != null) { ClusterVO cluster = _clusterDao.findById(plan.getClusterId()); @@ -116,6 +123,10 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner { clusters = _clusterDao.listByPodId(hostPod.getId()); } + if (_allocationAlgorithm != null && _allocationAlgorithm.equalsIgnoreCase("random")) { + Collections.shuffle(clusters); + } + for (ClusterVO clusterVO : clusters) { if (avoid.shouldAvoid(clusterVO)) { continue; @@ -127,7 +138,9 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner { } List hosts = _hostDao.listBy(Host.Type.Routing, clusterVO.getId(), hostPod.getId(), dc.getId()); - //Collections.shuffle(hosts); + if (_allocationAlgorithm != null && _allocationAlgorithm.equalsIgnoreCase("random")) { + Collections.shuffle(hosts); + } // We will try to reorder the host lists such that we give priority to hosts that have // the minimums to support a VM's requirements