use of com.cloud.dc.PodCluster in project cloudstack by apache.
the class ResourceManagerImpl method listByDataCenter.
@Override
public List<PodCluster> listByDataCenter(final long dcId) {
final List<HostPodVO> pods = _podDao.listByDataCenterId(dcId);
final ArrayList<PodCluster> pcs = new ArrayList<PodCluster>();
for (final HostPodVO pod : pods) {
final List<ClusterVO> clusters = _clusterDao.listByPodId(pod.getId());
if (clusters.size() == 0) {
pcs.add(new PodCluster(pod, null));
} else {
for (final ClusterVO cluster : clusters) {
pcs.add(new PodCluster(pod, cluster));
}
}
}
return pcs;
}
use of com.cloud.dc.PodCluster in project cosmic by MissionCriticalCloud.
the class RecreateHostAllocator method allocateTo.
@Override
public List<Host> allocateTo(final VirtualMachineProfile vm, final DeploymentPlan plan, final Type type, final ExcludeList avoid, final int returnUpTo) {
List<Host> hosts = super.allocateTo(vm, plan, type, avoid, returnUpTo);
if (hosts != null && !hosts.isEmpty()) {
return hosts;
}
s_logger.debug("First fit was unable to find a host");
final VirtualMachine.Type vmType = vm.getType();
if (vmType == VirtualMachine.Type.User) {
s_logger.debug("vm is not a system vm so let's just return empty list");
return new ArrayList<>();
}
final DataCenter dc = _dcDao.findById(plan.getDataCenterId());
final List<PodCluster> pcs = _resourceMgr.listByDataCenter(dc.getId());
// basic network type for zone maps to direct untagged case
if (dc.getNetworkType().equals(NetworkType.Basic)) {
s_logger.debug("Direct Networking mode so we can only allow the host to be allocated in the same pod due to public ip address cannot change");
final List<VolumeVO> vols = _volsDao.findByInstance(vm.getId());
final VolumeVO vol = vols.get(0);
final long podId = vol.getPodId();
s_logger.debug("Pod id determined from volume " + vol.getId() + " is " + podId);
final Iterator<PodCluster> it = pcs.iterator();
while (it.hasNext()) {
final PodCluster pc = it.next();
if (pc.getPod().getId() != podId) {
it.remove();
}
}
}
final Set<Pair<Long, Long>> avoidPcs = new HashSet<>();
final Set<Long> hostIdsToAvoid = avoid.getHostsToAvoid();
if (hostIdsToAvoid != null) {
for (final Long hostId : hostIdsToAvoid) {
final Host h = _hostDao.findById(hostId);
if (h != null) {
avoidPcs.add(new Pair<>(h.getPodId(), h.getClusterId()));
}
}
}
for (final Pair<Long, Long> pcId : avoidPcs) {
s_logger.debug("Removing " + pcId + " from the list of available pods");
pcs.remove(new PodCluster(new HostPodVO(pcId.first()), pcId.second() != null ? new ClusterVO(pcId.second()) : null));
}
for (final PodCluster p : pcs) {
if (p.getPod().getAllocationState() != AllocationState.Enabled) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Pod name: " + p.getPod().getName() + ", podId: " + p.getPod().getId() + " is in " + p.getPod().getAllocationState().name() + " state, skipping this and trying other pods");
}
continue;
}
final Long clusterId = p.getCluster() == null ? null : p.getCluster().getId();
if (p.getCluster() != null && p.getCluster().getAllocationState() != AllocationState.Enabled) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Cluster name: " + p.getCluster().getName() + ", clusterId: " + clusterId + " is in " + p.getCluster().getAllocationState().name() + " state, skipping this and trying other pod-clusters");
}
continue;
}
final DataCenterDeployment newPlan = new DataCenterDeployment(plan.getDataCenterId(), p.getPod().getId(), clusterId, null, null, null);
hosts = super.allocateTo(vm, newPlan, type, avoid, returnUpTo);
if (hosts != null && !hosts.isEmpty()) {
return hosts;
}
}
s_logger.debug("Unable to find any available pods at all!");
return new ArrayList<>();
}
use of com.cloud.dc.PodCluster in project cosmic by MissionCriticalCloud.
the class ResourceManagerImpl method listByDataCenter.
@Override
public List<PodCluster> listByDataCenter(final long dcId) {
final List<HostPodVO> pods = _podDao.listByDataCenterId(dcId);
final ArrayList<PodCluster> pcs = new ArrayList<>();
for (final HostPodVO pod : pods) {
final List<ClusterVO> clusters = _clusterDao.listByPodId(pod.getId());
if (clusters.size() == 0) {
pcs.add(new PodCluster(pod, null));
} else {
for (final ClusterVO cluster : clusters) {
pcs.add(new PodCluster(pod, cluster));
}
}
}
return pcs;
}
use of com.cloud.dc.PodCluster in project cloudstack by apache.
the class RecreateHostAllocator method allocateTo.
@Override
public List<Host> allocateTo(VirtualMachineProfile vm, DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo) {
List<Host> hosts = super.allocateTo(vm, plan, type, avoid, returnUpTo);
if (hosts != null && !hosts.isEmpty()) {
return hosts;
}
s_logger.debug("First fit was unable to find a host");
VirtualMachine.Type vmType = vm.getType();
if (vmType == VirtualMachine.Type.User) {
s_logger.debug("vm is not a system vm so let's just return empty list");
return new ArrayList<Host>();
}
DataCenter dc = _dcDao.findById(plan.getDataCenterId());
List<PodCluster> pcs = _resourceMgr.listByDataCenter(dc.getId());
// basic network type for zone maps to direct untagged case
if (dc.getNetworkType().equals(NetworkType.Basic)) {
s_logger.debug("Direct Networking mode so we can only allow the host to be allocated in the same pod due to public ip address cannot change");
List<VolumeVO> vols = _volsDao.findByInstance(vm.getId());
VolumeVO vol = vols.get(0);
long podId = vol.getPodId();
s_logger.debug("Pod id determined from volume " + vol.getId() + " 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>>();
Set<Long> hostIdsToAvoid = avoid.getHostsToAvoid();
if (hostIdsToAvoid != null) {
for (Long hostId : hostIdsToAvoid) {
Host h = _hostDao.findById(hostId);
if (h != null) {
avoidPcs.add(new Pair<Long, Long>(h.getPodId(), h.getClusterId()));
}
}
}
for (Pair<Long, Long> pcId : avoidPcs) {
s_logger.debug("Removing " + pcId + " from the list of available pods");
pcs.remove(new PodCluster(new HostPodVO(pcId.first()), pcId.second() != null ? new ClusterVO(pcId.second()) : null));
}
for (PodCluster p : pcs) {
Long clusterId = p.getCluster() == null ? null : p.getCluster().getId();
DataCenterDeployment newPlan = new DataCenterDeployment(plan.getDataCenterId(), p.getPod().getId(), clusterId, null, null, null);
hosts = super.allocateTo(vm, newPlan, type, avoid, returnUpTo);
if (hosts != null && !hosts.isEmpty()) {
return hosts;
}
}
s_logger.debug("Unable to find any available pods at all!");
return new ArrayList<Host>();
}
Aggregations