@Override public HostVO call(HostVO arg) { if (zoneUuids.contains(arg.getZoneUuid())) { return arg; } return null; } });
private List<HostVO> allocate(List<HostVO> candidates, String zoneUuid, String clusterUuid, String hostUuid, String hypervisorType) { List<HostVO> ret = new ArrayList<HostVO>(candidates.size()); for (HostVO h : candidates) { if (zoneUuid != null && !h.getZoneUuid().equals(zoneUuid)) { continue; } if (clusterUuid != null && !h.getClusterUuid().equals(clusterUuid)) { continue; } if (hostUuid != null && !h.getUuid().equals(hostUuid)) { continue; } if (hypervisorType != null && !h.getHypervisorType().equals(hypervisorType)) { continue; } ret.add(h); } return ret; }
@Override public void next(List<HostVO> candidates) { DebugUtils.Assert(candidates != null, "cannot pass null to next() method"); DebugUtils.Assert(!candidates.isEmpty(), "cannot pass empty candidates to next() method"); result = candidates; VmInstanceInventory vm = allocationSpec.getVmInstance(); logger.debug(String.format("[Host Allocation]: flow[%s] successfully found %s candidate hosts for vm[uuid:%s, name:%s]", lastFlow.getClass().getName(), result.size(), vm.getUuid(), vm.getName())); if (logger.isTraceEnabled()) { StringBuilder sb = new StringBuilder("[Host Allocation Details]:"); for (HostVO vo : result) { sb.append(String.format("\ncandidate host[name:%s, uuid:%s, zoneUuid:%s, clusterUuid:%s, hypervisorType:%s]", vo.getName(), vo.getUuid(), vo.getZoneUuid(), vo.getClusterUuid(), vo.getHypervisorType())); } logger.trace(sb.toString()); } if (it.hasNext()) { runFlow(it.next()); return; } done(); }
protected HostVO(HostVO vo) { this.setClusterUuid(vo.getClusterUuid()); this.setStatus(vo.getStatus()); this.setCreateDate(vo.getCreateDate()); this.setDescription(vo.getDescription()); this.setHypervisorType(vo.getHypervisorType()); this.setLastOpDate(vo.getLastOpDate()); this.setManagementIp(vo.getManagementIp()); this.setName(vo.getName()); this.setState(vo.getState()); this.setUuid(vo.getUuid()); this.setZoneUuid(vo.getZoneUuid()); this.setCapacity(vo.getCapacity()); } }
protected HostInventory(HostVO vo) { this.setStatus(vo.getStatus().toString()); this.setCreateDate(vo.getCreateDate()); this.setDescription(vo.getDescription()); this.setHypervisorType(vo.getHypervisorType()); this.setLastOpDate(vo.getLastOpDate()); this.setManagementIp(vo.getManagementIp()); this.setName(vo.getName()); this.setState(vo.getState().toString()); this.setUuid(vo.getUuid()); this.setZoneUuid(vo.getZoneUuid()); this.setClusterUuid(vo.getClusterUuid()); if (vo.getCapacity() != null) { this.setTotalCpuCapacity(vo.getCapacity().getTotalCpu()); this.setAvailableCpuCapacity(vo.getCapacity().getAvailableCpu()); this.setTotalMemoryCapacity(vo.getCapacity().getTotalMemory()); this.setAvailableMemoryCapacity(vo.getCapacity().getAvailableMemory()); this.setCpuSockets(vo.getCapacity().getCpuSockets()); this.setCpuNum(vo.getCapacity().getCpuNum()); } }