private HypervisorType getHypervisorType(long hostId) { HostVO host = _hostDao.findById(hostId); if (host != null) return host.getHypervisorType(); return HypervisorType.None; }
private HypervisorType getHypervisorType(long hostId) { HostVO host = hostDao.findById(hostId); if (host != null) { return host.getHypervisorType(); } return HypervisorType.None; }
private HypervisorType getHypervisorType(long hostId) { HostVO host = _hostDao.findById(hostId); if (host != null) return host.getHypervisorType(); return HypervisorType.None; }
private boolean doUmanageHost(final long hostId) { final HostVO host = _hostDao.findById(hostId); if (host == null) { s_logger.debug("Cannot find host " + hostId + ", assuming it has been deleted, skip umanage"); return true; } if (host.getHypervisorType() == HypervisorType.KVM || host.getHypervisorType() == HypervisorType.LXC) { _agentMgr.easySend(hostId, new MaintainCommand()); } _agentMgr.disconnectWithoutInvestigation(hostId, Event.ShutdownRequested); return true; }
/** * Return the list of running hosts to which upload certificates for Direct Download */ private List<HostVO> getRunningHostsToUploadCertificate(HypervisorType hypervisorType) { return hostDao.listAllHostsByType(Host.Type.Routing) .stream() .filter(x -> x.getStatus().equals(Status.Up) && x.getHypervisorType().equals(hypervisorType)) .collect(Collectors.toList()); }
public long[] getNeighbors(Host agent) { List<Long> neighbors = new ArrayList<Long>(); List<HostVO> cluster_hosts = resourceManager.listHostsInClusterByStatus(agent.getClusterId(), Status.Up); for (HostVO host : cluster_hosts) { if (host.getId() == agent.getId() || (host.getHypervisorType() != Hypervisor.HypervisorType.KVM && host.getHypervisorType() != Hypervisor.HypervisorType.LXC)) { continue; } neighbors.add(host.getId()); } return ArrayUtils.toPrimitive(neighbors.toArray(new Long[neighbors.size()])); }
private String getNameOfClusteredFileSystem(HostVO hostVO) { HypervisorType hypervisorType = hostVO.getHypervisorType(); if (HypervisorType.XenServer.equals(hypervisorType)) { return "SRs"; } if (HypervisorType.VMware.equals(hypervisorType)) { return "datastores"; } return "clustered file systems"; }
@Override public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForceDeleteStorage) throws UnableDeleteHostException { LOGGER.debug("deleteHost: " + host); if (host.getType() != com.cloud.host.Host.Type.Routing || host.getHypervisorType() != HypervisorType.Ovm3) { return null; } resourceMgr.deleteRoutingHost(host, isForced, isForceDeleteStorage); return new DeleteHostAnswer(true); }
@Override public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForceDeleteStorage) throws UnableDeleteHostException { if (host.getType() != Host.Type.Routing || (host.getHypervisorType() != HypervisorType.KVM && host.getHypervisorType() != HypervisorType.LXC)) { return null; } _resourceMgr.deleteRoutingHost(host, isForced, isForceDeleteStorage); try { ShutdownCommand cmd = new ShutdownCommand(ShutdownCommand.DeleteHost, null); agentMgr.send(host.getId(), cmd); } catch (AgentUnavailableException e) { s_logger.warn("Sending ShutdownCommand failed: ", e); } catch (OperationTimedoutException e) { s_logger.warn("Sending ShutdownCommand failed: ", e); } return new DeleteHostAnswer(true); }
private void handleTargetsForVMware(long hostId, String storageAddress, int storagePort, String iScsiName) { HostVO host = _hostDao.findById(hostId); if (host.getHypervisorType() == HypervisorType.VMware) { ModifyTargetsCommand cmd = new ModifyTargetsCommand(); List<Map<String, String>> targets = new ArrayList<>(); Map<String, String> target = new HashMap<>(); target.put(ModifyTargetsCommand.STORAGE_HOST, storageAddress); target.put(ModifyTargetsCommand.STORAGE_PORT, String.valueOf(storagePort)); target.put(ModifyTargetsCommand.IQN, iScsiName); targets.add(target); cmd.setTargets(targets); cmd.setApplyToAllHostsInCluster(true); cmd.setAdd(false); cmd.setTargetTypeToRemove(ModifyTargetsCommand.TargetTypeToRemove.DYNAMIC); sendModifyTargetsCommand(cmd, hostId); } }
@Override public final DeleteHostAnswer deleteHost(final HostVO host, final boolean isForced, final boolean isForceDeleteStorage) throws UnableDeleteHostException { // assert if (host.getType() != Host.Type.Routing || host.getHypervisorType() != HypervisorType.Hyperv) { return null; } _resourceMgr.deleteRoutingHost(host, isForced, isForceDeleteStorage); return new DeleteHostAnswer(true); }
@Override public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForceDeleteStorage) throws UnableDeleteHostException { if (host.getType() != com.cloud.host.Host.Type.Routing || host.getHypervisorType() != HypervisorType.Ovm) { return null; } _resourceMgr.deleteRoutingHost(host, isForced, isForceDeleteStorage); return new DeleteHostAnswer(true); }
@Override public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForceDeleteStorage) throws UnableDeleteHostException { if (host.getType() != com.cloud.host.Host.Type.Routing || host.getHypervisorType() != HypervisorType.XenServer) { return null; } _resourceMgr.deleteRoutingHost(host, isForced, isForceDeleteStorage); return new DeleteHostAnswer(true); }
/** * Get running host IDs within the same hypervisor, cluster and datacenter than hostId. ID hostId is not included on the returned list */ protected List<Long> getRunningHostIdsInTheSameCluster(Long clusterId, long dataCenterId, HypervisorType hypervisorType, long hostId) { List<Long> list = hostDao.listByDataCenterIdAndHypervisorType(dataCenterId, hypervisorType) .stream() .filter(x -> x.getHypervisorType().equals(hypervisorType) && x.getStatus().equals(Status.Up) && x.getType().equals(Host.Type.Routing) && x.getClusterId().equals(clusterId) && x.getId() != hostId) .map(x -> x.getId()) .collect(Collectors.toList()); Collections.shuffle(list); return list; }
private boolean checkIfExisted(String guid) { QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class); sc.and(sc.entity().getGuid(), SearchCriteria.Op.EQ, guid); sc.and(sc.entity().getHypervisorType(), SearchCriteria.Op.EQ, HypervisorType.Ovm); List<HostVO> hosts = sc.list(); return !hosts.isEmpty(); }
private boolean checkIfExisted(String guid) { QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class); sc.and(sc.entity().getGuid(), SearchCriteria.Op.EQ, guid); sc.and(sc.entity().getHypervisorType(), SearchCriteria.Op.EQ, HypervisorType.Ovm3); List<HostVO> hosts = sc.list(); return !hosts.isEmpty(); }
protected void attachCluster(DataStore store) { // send down AttachPrimaryDataStoreCmd command to all the hosts in the // cluster List<EndPoint> endPoints = selector.selectAll(store); CreatePrimaryDataStoreCmd createCmd = new CreatePrimaryDataStoreCmd(store.getUri()); EndPoint ep = endPoints.get(0); HostVO host = hostDao.findById(ep.getId()); if (host.getHypervisorType() == HypervisorType.XenServer) { ep.sendMessage(createCmd); } endPoints.get(0).sendMessage(createCmd); AttachPrimaryDataStoreCmd cmd = new AttachPrimaryDataStoreCmd(store.getUri()); for (EndPoint endp : endPoints) { endp.sendMessage(cmd); } }
/** * Configure VNC access for host VMs which have failed migrating to another host while trying to enter Maintenance mode */ protected void configureVncAccessForKVMHostFailedMigrations(HostVO host, List<VMInstanceVO> failedMigrations) { if (host.getHypervisorType().equals(HypervisorType.KVM)) { _agentMgr.pullAgentOutMaintenance(host.getId()); setKVMVncAccess(host.getId(), failedMigrations); _agentMgr.pullAgentToMaintenance(host.getId()); } }
@Override public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForceDeleteStorage) throws UnableDeleteHostException { if (host.getType() != Host.Type.Routing || host.getHypervisorType() != HypervisorType.BareMetal) { return null; } List<VMInstanceVO> deadVms = _vmDao.listByLastHostId(host.getId()); for (VMInstanceVO vm : deadVms) { if (vm.getState() == State.Running || vm.getHostId() != null) { throw new CloudRuntimeException("VM " + vm.getId() + "is still running on host " + host.getId()); } _vmDao.remove(vm.getId()); } return new DeleteHostAnswer(true); }
@Override public List<HostVO> listAllUpAndEnabledHostsInOneZoneByHypervisor(final HypervisorType type, final long dcId) { final QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class); sc.and(sc.entity().getHypervisorType(), Op.EQ, type); sc.and(sc.entity().getDataCenterId(), Op.EQ, dcId); sc.and(sc.entity().getStatus(), Op.EQ, Status.Up); sc.and(sc.entity().getResourceState(), Op.EQ, ResourceState.Enabled); return sc.list(); }