@Override public String call(HostVO arg) { return arg.getClusterUuid(); } });
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(); }
/** * @return hostUuid list * * Just check it : * The current cluster is mounted only local storage * Specified local storage * * Negative impact * In the case of local + non-local and no ps specified (non-local is Disconnected/Disabled, or non-local capacity not enough), the allocated host may not have enough disks */ private List<String> getNeedCheckHostLocalStorageList(List<HostVO> candidates, HostAllocatorSpec spec){ String requiredPrimaryStorageUuid = spec.getRequiredPrimaryStorageUuid(); boolean isRequireNonLocalStorage = false; if(StringUtils.isNotEmpty(requiredPrimaryStorageUuid)){ isRequireNonLocalStorage = !LocalStorageUtils.isLocalStorage(requiredPrimaryStorageUuid); } List<String> result = new ArrayList<>(); for(HostVO hostVO : candidates){ boolean isOnlyAttachedLocalStorage = LocalStorageUtils.isOnlyAttachedLocalStorage(hostVO.getClusterUuid()); if(!isOnlyAttachedLocalStorage && isRequireNonLocalStorage){ continue; } if(!isOnlyAttachedLocalStorage && spec.isDryRun()){ continue; } result.add(hostVO.getUuid()); } return result; }
private boolean checkCpuModelOfHost() { List<String> hostUuidsInCluster = Q.New(HostVO.class) .select(HostVO_.uuid) .eq(HostVO_.clusterUuid, self.getClusterUuid()) .notEq(HostVO_.uuid, self.getUuid()) .listValues(); if (hostUuidsInCluster.isEmpty()) { return true; } Map<String, List<String>> cpuModelNames = KVMSystemTags.CPU_MODEL_NAME.getTags(hostUuidsInCluster); if (cpuModelNames != null && cpuModelNames.size() != 0) { String clusterCpuModelName = KVMSystemTags.CPU_MODEL_NAME.getTokenByTag( cpuModelNames.values().iterator().next().get(0), KVMSystemTags.CPU_MODEL_NAME_TOKEN ); String hostCpuModelName = KVMSystemTags.CPU_MODEL_NAME.getTokenByResourceUuid( self.getUuid(), KVMSystemTags.CPU_MODEL_NAME_TOKEN ); if (clusterCpuModelName != null && !clusterCpuModelName.equals(hostCpuModelName)) { return false; } } return true; }
if (!clusterHavingAllPs.isEmpty()) { for (HostVO h : tmp) { if (clusterHavingAllPs.contains(h.getClusterUuid())) { candidates.add(h);
private boolean checkQemuLibvirtVersionOfHost() { List<String> hostUuidsInCluster = Q.New(HostVO.class) .select(HostVO_.uuid) .eq(HostVO_.clusterUuid, self.getClusterUuid()) .notEq(HostVO_.uuid, self.getUuid()) .listValues();
@Transactional(readOnly = true) private boolean noStorageAccessible(){ // detach ps will delete PrimaryStorageClusterRefVO first. List<String> attachedPsUuids = Q.New(PrimaryStorageClusterRefVO.class) .select(PrimaryStorageClusterRefVO_.primaryStorageUuid) .eq(PrimaryStorageClusterRefVO_.clusterUuid, self.getClusterUuid()) .listValues(); long attachedPsCount = attachedPsUuids.size(); long inaccessiblePsCount = attachedPsCount == 0 ? 0 : Q.New(PrimaryStorageHostRefVO.class) .eq(PrimaryStorageHostRefVO_.hostUuid, self.getUuid()) .eq(PrimaryStorageHostRefVO_.status, PrimaryStorageHostStatus.Disconnected) .in(PrimaryStorageHostRefVO_.primaryStorageUuid, attachedPsUuids) .count(); return inaccessiblePsCount == attachedPsCount && attachedPsCount > 0; }
q.add(HostVO_.clusterUuid, Op.EQ, vo.getClusterUuid()); q.add(HostVO_.uuid, Op.NOT_EQ, vo.getUuid()); q.add(HostVO_.status, Op.NOT_EQ, HostStatus.Connecting); vo.getClusterUuid(), currentVersion, vo.getName(), vo.getManagementIp(), mineVersion)); return;
self.getUuid(), self.getClusterUuid())); return; if (KVMSystemTags.CHECK_CLUSTER_CPU_MODEL.hasTag(self.getClusterUuid())) { if (KVMSystemTags.CHECK_CLUSTER_CPU_MODEL .getTokenByResourceUuid(self.getClusterUuid(), KVMSystemTags.CHECK_CLUSTER_CPU_MODEL_TOKEN) .equals("true") && !checkCpuModelOfHost()) { complete.fail(operr("host [uuid:%s] cannot be added to cluster [uuid:%s] because cpu model name does not match", self.getUuid(), self.getClusterUuid())); return; self.getUuid(), self.getClusterUuid())); return;
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()); } }
private void handle(final APICreateVxlanVtepMsg msg) { APICreateVxlanVtepEvent evt = new APICreateVxlanVtepEvent(msg.getId()); HostVO host = Q.New(HostVO.class).eq(HostVO_.uuid, msg.getHostUuid()).find(); VtepVO vtep = new VtepVO(); vtep.setUuid(Platform.getUuid()); vtep.setClusterUuid(host.getClusterUuid()); vtep.setHostUuid(msg.getHostUuid()); vtep.setPoolUuid(msg.getPoolUuid()); vtep.setPort(VxlanNetworkPoolConstant.VXLAN_PORT); vtep.setType(VxlanNetworkPoolConstant.KVM_VXLAN_TYPE); vtep.setVtepIp(msg.getVtepIp()); vtep = dbf.persistAndRefresh(vtep); evt.setInventory(VtepInventory.valueOf(vtep)); PopulateVtepPeersMsg pmsg = new PopulateVtepPeersMsg(); pmsg.setPoolUuid(msg.getPoolUuid()); bus.makeTargetServiceIdByResourceUuid(pmsg, L2NetworkConstant.SERVICE_ID, msg.getPoolUuid()); bus.send(pmsg, new CloudBusCallBack(msg){ @Override public void run(MessageReply reply) { bus.publish(evt); } }); }
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()); } }