diff --git a/plugins/affinity-group-processors/explicit-dedication/src/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java b/plugins/affinity-group-processors/explicit-dedication/src/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java index 9343cd8d0c4..3489b57577e 100644 --- a/plugins/affinity-group-processors/explicit-dedication/src/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java +++ b/plugins/affinity-group-processors/explicit-dedication/src/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java @@ -276,7 +276,7 @@ public class ExplicitDedicationProcessor extends AffinityProcessorBase implement List hostList = _hostDao.findByClusterId(dr.getClusterId()); for (HostVO host : hostList) { DedicatedResourceVO dHost = _dedicatedDao.findByHostId(host.getId()); - if (dHost != null) { + if (dHost != null && !dedicatedResources.contains(dHost)) { avoidList.addHost(host.getId()); } else { includeList.addHost(host.getId()); @@ -291,7 +291,8 @@ public class ExplicitDedicationProcessor extends AffinityProcessorBase implement //add all cluster under this pod in includeList List clusterList = _clusterDao.listByPodId(dr.getPodId()); for (ClusterVO cluster : clusterList) { - if (_dedicatedDao.findByClusterId(cluster.getId()) != null) { + DedicatedResourceVO dCluster = _dedicatedDao.findByClusterId(cluster.getId()); + if (dCluster != null && !dedicatedResources.contains(dCluster)) { avoidList.addCluster(cluster.getId()); } else { includeList.addCluster(cluster.getId()); @@ -300,7 +301,8 @@ public class ExplicitDedicationProcessor extends AffinityProcessorBase implement //add all hosts inside this pod in includeList List hostList = _hostDao.findByPodId(dr.getPodId()); for (HostVO host : hostList) { - if (_dedicatedDao.findByHostId(host.getId()) != null) { + DedicatedResourceVO dHost = _dedicatedDao.findByHostId(host.getId()); + if (dHost != null && !dedicatedResources.contains(dHost)) { avoidList.addHost(host.getId()); } else { includeList.addHost(host.getId()); @@ -313,7 +315,8 @@ public class ExplicitDedicationProcessor extends AffinityProcessorBase implement //add all Pod under this data center in includeList List podList = _podDao.listByDataCenterId(dr.getDataCenterId()); for (HostPodVO pod : podList) { - if (_dedicatedDao.findByPodId(pod.getId()) != null) { + DedicatedResourceVO dPod = _dedicatedDao.findByPodId(pod.getId()); + if (dPod != null && !dedicatedResources.contains(dPod)) { avoidList.addPod(pod.getId()); } else { includeList.addPod(pod.getId()); @@ -321,7 +324,8 @@ public class ExplicitDedicationProcessor extends AffinityProcessorBase implement } List clusterList = _clusterDao.listClustersByDcId(dr.getDataCenterId()); for (ClusterVO cluster : clusterList) { - if (_dedicatedDao.findByClusterId(cluster.getId()) != null) { + DedicatedResourceVO dCluster = _dedicatedDao.findByClusterId(cluster.getId()); + if (dCluster != null && !dedicatedResources.contains(dCluster)) { avoidList.addCluster(cluster.getId()); } else { includeList.addCluster(cluster.getId()); @@ -330,7 +334,8 @@ public class ExplicitDedicationProcessor extends AffinityProcessorBase implement //add all hosts inside this in includeList List hostList = _hostDao.listByDataCenterId(dr.getDataCenterId()); for (HostVO host : hostList) { - if (_dedicatedDao.findByHostId(host.getId()) != null) { + DedicatedResourceVO dHost = _dedicatedDao.findByHostId(host.getId()); + if (dHost != null && !dedicatedResources.contains(dHost)) { avoidList.addHost(host.getId()); } else { includeList.addHost(host.getId());