private boolean checkHostsSuitabilityForExplicitDedication(Long accountId, List<Long> domainIds, List<HostVO> hosts) { boolean suitable = true; for (HostVO host : hosts) { checkHostSuitabilityForExplicitDedication(accountId, domainIds, host.getId()); } return suitable; }
/** * Set retries for transiting the host into Maintenance */ protected void setHostMaintenanceRetries(HostVO host) { Integer retries = HostMaintenanceRetries.valueIn(host.getClusterId()); retryHostMaintenance.put(host.getId(), retries); s_logger.debug(String.format("Setting the host %s (%s) retries for Maintenance mode: %s", host.getId(), host.getName(), retries)); }
protected void saveGpuRecords(HostVO host) { HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails = host.getGpuGroupDetails(); if (groupDetails != null) { // Create/Update GPU group entries _hostGpuGroupsDao.persist(host.getId(), new ArrayList<String>(groupDetails.keySet())); // Create/Update VGPU types entries _vgpuTypesDao.persist(host.getId(), groupDetails); } }
@Override protected HashMap<String, Object> buildConfigParams(HostVO host) { HashMap<String, Object> params = super.buildConfigParams(host); params.put("hostId", host.getId()); params.put("ipaddress", host.getPrivateIpAddress()); params.put("vmDao", _vmDao); params.put("configDao", _configDao); return params; }
protected void saveHostTags(HostVO host) { List<String> hostTags = host.getHostTags(); if (hostTags == null || (hostTags != null && hostTags.isEmpty())) { return; } _hostTagsDao.persist(host.getId(), hostTags); }
/** * 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()); } }
/** * Sends VMs metrics to the configured graphite host. */ protected void sendVmMetricsToGraphiteHost(Map<Object, Object> metrics, HostVO host) { s_logger.debug(String.format("Sending VmStats of host %s to %s host %s:%s", host.getId(), externalStatsType, externalStatsHost, externalStatsPort)); try { GraphiteClient g = new GraphiteClient(externalStatsHost, externalStatsPort); g.sendMetrics(metrics); } catch (GraphiteException e) { s_logger.debug("Failed sending VmStats to Graphite host " + externalStatsHost + ":" + externalStatsPort + ": " + e.getMessage()); } }
@Override public void loadHostTags(HostVO host) { List<String> hostTags = _hostTagsDao.gethostTags(host.getId()); host.setHostTags(hostTags); }
@Override public void loadDetails(HostVO host) { Map<String, String> details = _detailsDao.findDetails(host.getId()); host.setDetails(details); }
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()])); }
@Override public void saveDetails(HostVO host) { Map<String, String> details = host.getDetails(); if (details == null) { return; } _detailsDao.persist(host.getId(), details); }
@Override public void cancelScheduledMigrations(final HostVO host) { WorkType type = host.getType() == HostVO.Type.Storage ? WorkType.Stop : WorkType.Migration; _haDao.deleteMigrationWorkItems(host.getId(), type, _serverId); }
private void removeStaleVmFromSource(VMInstanceVO vm, HostVO srcHost) { s_logger.debug("Since VM's storage was successfully migrated across VMware Datacenters, unregistering VM: " + vm.getInstanceName() + " from source host: " + srcHost.getId()); final UnregisterVMCommand uvc = new UnregisterVMCommand(vm.getInstanceName()); uvc.setCleanupVmFiles(true); try { _agentMgr.send(srcHost.getId(), uvc); } catch (final Exception e) { throw new CloudRuntimeException("Failed to unregister VM: " + vm.getInstanceName() + " from source host: " + srcHost.getId() + " after successfully migrating VM's storage across VMware Datacenters"); } }
@Override public void postDiscovery(List<HostVO> hosts, long msId) { if (_useServiceVM) { for (HostVO h : hosts) { _agentMgr.agentStatusTransitTo(h, Event.AgentDisconnected, msId); } } for (HostVO h : hosts) { associateTemplatesToZone(h.getId(), h.getDataCenterId()); } }
private <R extends InternalIdentity> void send(Command cmd, long physicalNetworkId, Class<R> resourceClass, R resource) throws ResourceUnavailableException { HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(physicalNetworkId); Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd); if (isFailure(answer)) { s_logger.error(cmd.getClass().getName() + " for " + resourceClass.getName() + " " + resource.getId() + " failed on Nuage VSD " + nuageVspHost.getDetail("hostname")); if (hasFailureDetails(answer)) { throw new ResourceUnavailableException(answer.getDetails(), resourceClass, resource.getId()); } } }
/** * Safely transit host into Maintenance mode */ protected boolean setHostIntoMaintenance(HostVO host) throws NoTransitionException { s_logger.debug("Host " + host.getUuid() + " entering in Maintenance"); resourceStateTransitTo(host, ResourceState.Event.InternalEnterMaintenance, _nodeId); ActionEventUtils.onCompletedActionEvent(CallContext.current().getCallingUserId(), CallContext.current().getCallingAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_MAINTENANCE_PREPARE, "completed maintenance for host " + host.getId(), 0); return true; }
private boolean checkIfHostIsDedicated(HostVO host) { long hostId = host.getId(); DedicatedResourceVO dedicatedHost = _dedicatedDao.findByHostId(hostId); DedicatedResourceVO dedicatedClusterOfHost = _dedicatedDao.findByClusterId(host.getClusterId()); DedicatedResourceVO dedicatedPodOfHost = _dedicatedDao.findByPodId(host.getPodId()); if (dedicatedHost != null || dedicatedClusterOfHost != null || dedicatedPodOfHost != null) { return true; } else { return false; } }
private Answer callCommand(Command cmd, Long zoneId) { HostVO globoDnsHost = getGloboDnsHost(zoneId); if (globoDnsHost == null) { throw new CloudRuntimeException("Could not find the GloboDNS resource"); } Answer answer = _agentMgr.easySend(globoDnsHost.getId(), cmd); if (answer == null || !answer.getResult()) { String msg = "Error executing command " + cmd; msg = answer == null ? msg : answer.getDetails(); throw new CloudRuntimeException(msg); } return answer; }
@Override public boolean updateNuageUnderlayVlanIpRange(long vlanIpRangeId, boolean enabled) { VlanVO staticNatVlan = _vlanDao.findById(vlanIpRangeId); HostVO nuageVspHost = getNuageVspHost(staticNatVlan.getPhysicalNetworkId()); EntityExistsCommand<Vlan> cmd = new EntityExistsCommand<Vlan>(Vlan.class, staticNatVlan.getUuid()); Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd); if (answer != null && !answer.getResult()) { _vlanDetailsDao.addDetail(staticNatVlan.getId(), NuageVspManager.nuageUnderlayVlanIpRangeDetailKey, String.valueOf(enabled), false); return true; } return false; }