From 70405bd2b4f785f06e045a9cff06c95dc443e5b7 Mon Sep 17 00:00:00 2001 From: Prachi Damle Date: Wed, 1 May 2013 14:34:33 -0700 Subject: [PATCH] Fixing issues while testing VM deployment. --- client/tomcatconf/applicationContext.xml.in | 4 +- .../deploy/DeploymentPlanningManagerImpl.java | 39 ++++++++++++------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in index cb2946331e4..ec65c1c6247 100644 --- a/client/tomcatconf/applicationContext.xml.in +++ b/client/tomcatconf/applicationContext.xml.in @@ -614,8 +614,6 @@ - - @@ -835,6 +833,8 @@ + + diff --git a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java index e380adc2c65..4a787835de4 100644 --- a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java +++ b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java @@ -362,12 +362,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy avoids.getPodsToAvoid(), avoids.getClustersToAvoid(), avoids.getHostsToAvoid(), avoids.getPoolsToAvoid()); - PlannerAvoidOutput.getDataCentersToAvoid().removeAll(PlannerAvoidInput.getDataCentersToAvoid()); - PlannerAvoidOutput.getPodsToAvoid().removeAll(PlannerAvoidInput.getPodsToAvoid()); - PlannerAvoidOutput.getClustersToAvoid().removeAll(PlannerAvoidInput.getClustersToAvoid()); - PlannerAvoidOutput.getHostsToAvoid().removeAll(PlannerAvoidInput.getHostsToAvoid()); - PlannerAvoidOutput.getPoolsToAvoid().removeAll(PlannerAvoidInput.getPoolsToAvoid()); - + resetAvoidSet(PlannerAvoidOutput, PlannerAvoidInput); dest = checkClustersforDestination(clusterList, vmProfile, plan, avoids, dc, getPlannerUsage(planner), PlannerAvoidOutput); @@ -375,11 +370,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy return dest; } // reset the avoid input to the planners - avoids.getDataCentersToAvoid().removeAll(PlannerAvoidOutput.getDataCentersToAvoid()); - avoids.getPodsToAvoid().removeAll(PlannerAvoidOutput.getPodsToAvoid()); - avoids.getClustersToAvoid().removeAll(PlannerAvoidOutput.getClustersToAvoid()); - avoids.getHostsToAvoid().removeAll(PlannerAvoidOutput.getHostsToAvoid()); - avoids.getPoolsToAvoid().removeAll(PlannerAvoidOutput.getPoolsToAvoid()); + resetAvoidSet(avoids, PlannerAvoidOutput); } else { return null; @@ -408,6 +399,24 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy return dest; } + private void resetAvoidSet(ExcludeList avoidSet, ExcludeList removeSet) { + if (avoidSet.getDataCentersToAvoid() != null && removeSet.getDataCentersToAvoid() != null) { + avoidSet.getDataCentersToAvoid().removeAll(removeSet.getDataCentersToAvoid()); + } + if (avoidSet.getPodsToAvoid() != null && removeSet.getPodsToAvoid() != null) { + avoidSet.getPodsToAvoid().removeAll(removeSet.getPodsToAvoid()); + } + if (avoidSet.getClustersToAvoid() != null && removeSet.getClustersToAvoid() != null) { + avoidSet.getClustersToAvoid().removeAll(removeSet.getClustersToAvoid()); + } + if (avoidSet.getHostsToAvoid() != null && removeSet.getHostsToAvoid() != null) { + avoidSet.getHostsToAvoid().removeAll(removeSet.getHostsToAvoid()); + } + if (avoidSet.getPoolsToAvoid() != null && removeSet.getPoolsToAvoid() != null) { + avoidSet.getPoolsToAvoid().removeAll(removeSet.getPoolsToAvoid()); + } + } + private PlannerResourceUsage getPlannerUsage(DeploymentPlanner planner) { if (planner instanceof DeploymentClusterPlanner) { return ((DeploymentClusterPlanner) planner).getResourceUsage(); @@ -619,8 +628,12 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy // remove any hosts/pools that the planners might have added // to get the list of hosts/pools that Allocators flagged as 'avoid' - allocatorAvoidOutput.getHostsToAvoid().removeAll(plannerAvoidOutput.getHostsToAvoid()); - allocatorAvoidOutput.getPoolsToAvoid().removeAll(plannerAvoidOutput.getPoolsToAvoid()); + if (allocatorAvoidOutput.getHostsToAvoid() != null && plannerAvoidOutput.getHostsToAvoid() != null) { + allocatorAvoidOutput.getHostsToAvoid().removeAll(plannerAvoidOutput.getHostsToAvoid()); + } + if (allocatorAvoidOutput.getPoolsToAvoid() != null && plannerAvoidOutput.getPoolsToAvoid() != null) { + allocatorAvoidOutput.getPoolsToAvoid().removeAll(plannerAvoidOutput.getPoolsToAvoid()); + } // if all hosts or all pools in the cluster are in avoid set after this // pass, then put the cluster in avoid set.