domr cannot be recreated in a different pod

This commit is contained in:
Alex Huang 2010-10-12 16:16:49 -07:00
parent 63352f55ff
commit eb60dc690c
1 changed files with 16 additions and 0 deletions

View File

@ -18,6 +18,7 @@
package com.cloud.agent.manager.allocator.impl;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@ -37,7 +38,9 @@ import com.cloud.host.Host;
import com.cloud.service.ServiceOffering;
import com.cloud.storage.StoragePoolVO;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.StoragePoolDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.utils.Pair;
import com.cloud.utils.component.Inject;
import com.cloud.vm.VirtualMachine;
@ -51,6 +54,7 @@ public class RecreateHostAllocator extends FirstFitRoutingAllocator {
@Inject StoragePoolDao _poolDao;
@Inject ClusterDao _clusterDao;
@Inject AgentManager _agentMgr;
@Inject VolumeDao _volsDao;
@Override
public Host allocateTo(VmCharacteristics vm, ServiceOffering offering, Host.Type type, DataCenterVO dc, HostPodVO pod,
@ -68,6 +72,18 @@ public class RecreateHostAllocator extends FirstFitRoutingAllocator {
}
List<PodCluster> pcs = _agentMgr.listByDataCenter(dc.getId());
if (vmType == VirtualMachine.Type.DomainRouter) {
s_logger.debug("VM is a domain router so we can only allow the host to be allocated in the same pod due to problems with the DHCP only domR");
long podId = sp.getPodId();
s_logger.debug("Pod id determined is " + podId);
Iterator<PodCluster> it = pcs.iterator();
while (it.hasNext()) {
PodCluster pc = it.next();
if (pc.getPod().getId() != podId) {
it.remove();
}
}
}
Set<Pair<Long, Long>> avoidPcs = new HashSet<Pair<Long, Long>>();
for (Host h : avoid) {
avoidPcs.add(new Pair<Long, Long>(h.getPodId(), h.getClusterId()));