@Override public StrategyPriority canHandle(Map<VolumeInfo, DataStore> volumeMap, Host srcHost, Host destHost) { if (srcHost.getHypervisorType() == HypervisorType.XenServer && destHost.getHypervisorType() == HypervisorType.XenServer) { return StrategyPriority.HYPERVISOR; } return StrategyPriority.CANT_HANDLE; }
@Override public StrategyPriority canHandle(Map<VolumeInfo, DataStore> volumeMap, Host srcHost, Host destHost) { if (srcHost.getHypervisorType() == HypervisorType.Hyperv && destHost.getHypervisorType() == HypervisorType.Hyperv) { return StrategyPriority.HYPERVISOR; } return StrategyPriority.CANT_HANDLE; }
@Override public final StrategyPriority canHandle(Map<VolumeInfo, DataStore> volumeMap, Host srcHost, Host destHost) { if (HypervisorType.KVM.equals(srcHost.getHypervisorType())) { return internalCanHandle(volumeMap); } return StrategyPriority.CANT_HANDLE; }
public void validateHAProviderConfigForResource(final Long resourceId, final HAResource.ResourceType resourceType, final HAProvider<HAResource> haProvider) { if (HAResource.ResourceType.Host.equals(resourceType)) { final Host host = hostDao.findById(resourceId); if (host.getHypervisorType() == null || haProvider.resourceSubType() == null || !host.getHypervisorType().toString().equals(haProvider.resourceSubType().toString())) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Incompatible haprovider provided for the resource of hypervisor type:" + host.getHypervisorType()); } } }
private boolean isVMActivtyOnHost(Host agent, DateTime suspectTime) throws StorageUnavailableException { if (agent.getHypervisorType() != Hypervisor.HypervisorType.KVM && agent.getHypervisorType() != Hypervisor.HypervisorType.LXC) { throw new IllegalStateException("Calling KVM investigator for non KVM Host of type " + agent.getHypervisorType()); } boolean activityStatus = true; HashMap<StoragePool, List<Volume>> poolVolMap = getVolumeUuidOnHost(agent); for (StoragePool pool : poolVolMap.keySet()) { //for each storage pool find activity List<Volume> volume_list = poolVolMap.get(pool); final CheckVMActivityOnStoragePoolCommand cmd = new CheckVMActivityOnStoragePoolCommand(agent, pool, volume_list, suspectTime); //send the command to appropriate storage pool Answer answer = storageManager.sendToPool(pool, getNeighbors(agent), cmd); if (answer != null) { activityStatus = ! answer.getResult(); } else { throw new IllegalStateException("Did not get a valid response for VM activity check for host " + agent.getId()); } } if (LOG.isDebugEnabled()){ LOG.debug("Resource active = " + activityStatus); } return activityStatus; }
private List<Host> getAllAgentBasedHosts() { final List<HostVO> allHosts = hostDao.listAll(); if (allHosts == null) { return new ArrayList<>(); } final List <Host> agentBasedHosts = new ArrayList<>(); for (final Host host : allHosts) { if (host == null || host.getResourceState() != ResourceState.Enabled) { continue; } if (host.getType() == Host.Type.Routing || host.getType() == Host.Type.ConsoleProxy || host.getType() == Host.Type.SecondaryStorage || host.getType() == Host.Type.SecondaryStorageVM) { if (host.getHypervisorType() != null && host.getHypervisorType() != Hypervisor.HypervisorType.KVM && host.getHypervisorType() != Hypervisor.HypervisorType.LXC) { continue; } agentBasedHosts.add(host); } } return agentBasedHosts; }
@Override public boolean checkIfHostReachMaxGuestLimit(Host host) { Long vmCount = _vmDao.countActiveByHostId(host.getId()); HypervisorType hypervisorType = host.getHypervisorType(); String hypervisorVersion = host.getHypervisorVersion(); Long maxGuestLimit = _hypervisorCapabilitiesDao.getMaxGuestsLimit(hypervisorType, hypervisorVersion); if (vmCount.longValue() >= maxGuestLimit.longValue()) { s_logger.info("Host name: " + host.getName() + ", hostId: " + host.getId() + " already reached max Running VMs(count includes system VMs), limit: " + maxGuestLimit + ", Running VM count: " + vmCount.longValue()); return true; } return false; }
@Override public boolean isVmAlive(com.cloud.vm.VirtualMachine vm, Host host) throws UnknownVM { LOGGER.debug("isVmAlive: " + vm.getHostName() + " on " + host.getName()); if (host.getHypervisorType() != Hypervisor.HypervisorType.Ovm3) { throw new UnknownVM(); } Status status = isAgentAlive(host); if (status == null) { return false; } return status == Status.Up ? true : false; }
private boolean canHandle(DeployDestination dest) { if (dest.getDataCenter().getNetworkType() == NetworkType.Basic && dest.getHost().getHypervisorType() == HypervisorType.BareMetal) { return true; } return false; }
@Override public boolean isEligible(final Host host) { if (outOfBandManagementService.isOutOfBandManagementEnabled(host)){ return !isInMaintenanceMode(host) && !isDisabled(host) && hostActivityChecker.getNeighbors(host).length > 0 && (Hypervisor.HypervisorType.KVM.equals(host.getHypervisorType()) || Hypervisor.HypervisorType.LXC.equals(host.getHypervisorType())); } return false; }
@Override public Boolean fenceOff(VirtualMachine vm, Host host) { if (host.getHypervisorType() != HypervisorType.Ovm) { s_logger.debug("Don't know how to fence non Ovm hosts " + host.getHypervisorType()); return null;
@Override public void processConnect(final Host agent, final StartupCommand cmd, final boolean forRebalance) throws ConnectionException { if (!(cmd instanceof StartupRoutingCommand)) { return; } if(s_logger.isDebugEnabled()) { s_logger.debug("Received startup command from hypervisor host. host id: " + agent.getId()); } _syncMgr.resetHostSyncState(agent.getId()); if (forRebalance) { s_logger.debug("Not processing listener " + this + " as connect happens on rebalance process"); return; } final Long clusterId = agent.getClusterId(); final long agentId = agent.getId(); if (agent.getHypervisorType() == HypervisorType.XenServer) { // only for Xen // initiate the cron job final ClusterVMMetaDataSyncCommand syncVMMetaDataCmd = new ClusterVMMetaDataSyncCommand(ClusterVMMetaDataSyncInterval.value(), clusterId); try { final long seq_no = _agentMgr.send(agentId, new Commands(syncVMMetaDataCmd), this); s_logger.debug("Cluster VM metadata sync started with jobid " + seq_no); } catch (final AgentUnavailableException e) { s_logger.fatal("The Cluster VM metadata sync process failed for cluster id " + clusterId + " with ", e); } } }
@Override public boolean setupVmForPvlan(boolean add, Long hostId, NicProfile nic) { if (!nic.getBroadCastUri().getScheme().equals("pvlan")) { return false; } String op = "add"; if (!add) { // "delete" would remove all the rules(if using ovs) related to this vm op = "delete"; } Network network = _networkDao.findById(nic.getNetworkId()); Host host = _hostDao.findById(hostId); String networkTag = _networkModel.getNetworkTag(host.getHypervisorType(), network); PvlanSetupCommand cmd = PvlanSetupCommand.createVmSetup(op, nic.getBroadCastUri(), networkTag, nic.getMacAddress()); Answer answer = null; try { answer = _agentMgr.send(hostId, cmd); } catch (OperationTimedoutException e) { s_logger.warn("Timed Out", e); return false; } catch (AgentUnavailableException e) { s_logger.warn("Agent Unavailable ", e); return false; } boolean result = true; if (answer == null || !answer.getResult()) { result = false; } return result; }
@Override public void processDeletHostEventAfter(Host host) { String errMsg = String.format("Prepare OCFS2 nodes failed after delete host %1$s (zone:%2$s, pod:%3$s, cluster:%4$s", host.getId(), host.getDataCenterId(), host.getPodId(), host.getClusterId()); if (host.getHypervisorType() != HypervisorType.Ovm) { return; } boolean hasOcfs2 = false; List<StoragePoolHostVO> poolRefs = _poolHostDao.listByHostId(host.getId()); for (StoragePoolHostVO poolRef : poolRefs) { StoragePoolVO pool = _poolDao.findById(poolRef.getPoolId()); if (pool.getPoolType() == StoragePoolType.OCFS2) { hasOcfs2 = true; break; } } if (hasOcfs2) { try { if (!prepareNodes(host.getClusterId())) { s_logger.warn(errMsg); } } catch (Exception e) { s_logger.error(errMsg, e); } } }
@Override public Status isAgentAlive(Host agent) { LOGGER.debug("isAgentAlive: " + agent.getName()); if (agent.getHypervisorType() != Hypervisor.HypervisorType.Ovm3) { return null; } CheckOnHostCommand cmd = new CheckOnHostCommand(agent); List<HostVO> neighbors = resourceMgr.listHostsInClusterByStatus(agent.getClusterId(), Status.Up); for (HostVO neighbor : neighbors) { if (neighbor.getId() == agent.getId() || neighbor.getHypervisorType() != Hypervisor.HypervisorType.Ovm3) { continue; } try { Answer answer = agentMgr.easySend(neighbor.getId(), cmd); if (answer != null) { return answer.getResult() ? Status.Down : Status.Up; } } catch (Exception e) { LOGGER.error("Failed to send command to host: " + neighbor.getId(), e); } } return null; } }
@Override public Status isAgentAlive(Host agent) { if (agent.getHypervisorType() != Hypervisor.HypervisorType.Hyperv) { return null; } CheckOnHostCommand cmd = new CheckOnHostCommand(agent); List<HostVO> neighbors = _resourceMgr.listHostsInClusterByStatus(agent.getClusterId(), Status.Up); for (HostVO neighbor : neighbors) { if (neighbor.getId() == agent.getId() || neighbor.getHypervisorType() != Hypervisor.HypervisorType.Hyperv) { continue; } try { Answer answer = _agentMgr.easySend(neighbor.getId(), cmd); if (answer != null) { return answer.getResult() ? Status.Down : Status.Up; } } catch (Exception e) { s_logger.debug("Failed to send command to host: " + neighbor.getId(), e); } } return null; } }
if (cmd instanceof StartupRoutingCommand) { List<HypervisorType> hypers = _resourceMgr.listAvailHypervisorInZone(agent.getId(), agent.getDataCenterId()); HypervisorType hostHyper = agent.getHypervisorType(); if (hypers.contains(hostHyper)) { return;
@Override public Status isAgentAlive(Host agent) { if (agent.getHypervisorType() != HypervisorType.XenServer) { return null; } CheckOnHostCommand cmd = new CheckOnHostCommand(agent); List<HostVO> neighbors = _resourceMgr.listAllHostsInCluster(agent.getClusterId()); for (HostVO neighbor : neighbors) { if (neighbor.getId() == agent.getId() || neighbor.getHypervisorType() != HypervisorType.XenServer) { continue; } Answer answer = _agentMgr.easySend(neighbor.getId(), cmd); if (answer != null && answer.getResult()) { CheckOnHostAnswer ans = (CheckOnHostAnswer)answer; if (!ans.isDetermined()) { s_logger.debug("Host " + neighbor + " couldn't determine the status of " + agent); continue; } // even it returns true, that means host is up, but XAPI may not work return ans.isAlive() ? null : Status.Down; } } return null; }
boolean computeSupportsVolumeClone = computeSupportsVolumeClone(destHost.getDataCenterId(), destHost.getHypervisorType());
_itMgr.replugNic(networkInNewPhysicalNet, _itMgr.toNicTO(nicProfile, host.getHypervisorType()), _itMgr.toVmTO(vmProfile), context, dest); } catch (ResourceUnavailableException | InsufficientCapacityException e) { throw new CloudRuntimeException("Migration of Nic failed", e);